-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from alvarofpp/issue-8
Issue 8
- Loading branch information
Showing
10 changed files
with
137 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,7 @@ | |
venv/* | ||
dist/* | ||
build/* | ||
validate_docbr/__pycache__/* | ||
*/__pycache__/* | ||
site/* | ||
tests/* | ||
# Egg metadata | ||
*.egg-info |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import unittest | ||
|
||
import tests.test_cpf | ||
import tests.test_cns | ||
import tests.test_cnpj | ||
|
||
|
||
def suite(): | ||
loader = unittest.TestLoader() | ||
suite = unittest.TestSuite() | ||
|
||
suite.addTests(loader.loadTestsFromModule(tests.test_cpf)) | ||
suite.addTests(loader.loadTestsFromModule(tests.test_cns)) | ||
suite.addTests(loader.loadTestsFromModule(tests.test_cnpj)) | ||
|
||
return suite | ||
|
||
|
||
if __name__ == '__main__': | ||
runner = unittest.TextTestRunner() | ||
runner.run(suite()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import unittest | ||
import validate_docbr as docbr | ||
|
||
|
||
class TestCnpj(unittest.TestCase): | ||
def setUp(self): | ||
""" Inicia novo objeto em todo os testes """ | ||
self.cnpj = docbr.CNPJ() | ||
|
||
def test_generate(self): | ||
""" Verifica se o método generate """ | ||
# generate, generate(mask=True) | ||
cnpjs = [self.cnpj.generate() for i in range(10000)]\ | ||
+ [self.cnpj.generate(mask=True) for i in range(10000)] | ||
self.assertIsInstance(cnpjs, list) | ||
self.assertTrue(len(cnpjs) == 20000) | ||
|
||
def test_generate_list(self): | ||
""" Verifica se o método generate_list """ | ||
# generate_list | ||
cnpjs = self.cnpj.generate_list(10000)\ | ||
+ self.cnpj.generate_list(10000, True)\ | ||
+ self.cnpj.generate_list(10000, True, True) | ||
self.assertIsInstance(cnpjs, list) | ||
self.assertTrue(len(cnpjs) == 30000) | ||
|
||
def test_validate(self): | ||
""" Verifica se o método validate """ | ||
# validate | ||
for cnpj in self.cnpj.generate_list(10000): | ||
self.assertTrue(self.cnpj.validate(cnpj)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import unittest | ||
import validate_docbr as docbr | ||
|
||
|
||
class TestCns(unittest.TestCase): | ||
def setUp(self): | ||
""" Inicia novo objeto em todo os testes """ | ||
self.cns = docbr.CNS() | ||
|
||
def test_generate(self): | ||
""" Verifica se o método generate """ | ||
# generate, generate(mask=True) | ||
cnss = [self.cns.generate() for i in range(10000)]\ | ||
+ [self.cns.generate(mask=True) for i in range(10000)] | ||
self.assertIsInstance(cnss, list) | ||
self.assertTrue(len(cnss) == 20000) | ||
|
||
def test_generate_list(self): | ||
""" Verifica se o método generate_list """ | ||
# generate_list | ||
cnss = self.cns.generate_list(10000)\ | ||
+ self.cns.generate_list(10000, True)\ | ||
+ self.cns.generate_list(10000, True, True) | ||
self.assertIsInstance(cnss, list) | ||
self.assertTrue(len(cnss) == 30000) | ||
|
||
def test_validate(self): | ||
""" Verifica se o método validate """ | ||
# validate | ||
for cns in self.cns.generate_list(10000): | ||
self.assertTrue(self.cns.validate(cns)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import unittest | ||
import validate_docbr as docbr | ||
|
||
|
||
class TestCpf(unittest.TestCase): | ||
def setUp(self): | ||
""" Inicia novo objeto em todo os testes """ | ||
self.cpf = docbr.CPF() | ||
|
||
def test_generate(self): | ||
""" Verifica se o método generate """ | ||
# generate, generate(mask=True) | ||
cpfs = [self.cpf.generate() for i in range(10000)]\ | ||
+ [self.cpf.generate(mask=True) for i in range(10000)] | ||
self.assertIsInstance(cpfs, list) | ||
self.assertTrue(len(cpfs) == 20000) | ||
|
||
def test_generate_list(self): | ||
""" Verifica se o método generate_list """ | ||
# generate_list | ||
cpfs = self.cpf.generate_list(10000)\ | ||
+ self.cpf.generate_list(10000, True)\ | ||
+ self.cpf.generate_list(10000, True, True) | ||
self.assertIsInstance(cpfs, list) | ||
self.assertTrue(len(cpfs) == 30000) | ||
|
||
def test_validate(self): | ||
""" Verifica se o método validate """ | ||
# validate | ||
for cpf in self.cpf.generate_list(10000): | ||
self.assertTrue(self.cpf.validate(cpf)) | ||
|
||
def test_special_case(self): | ||
""" Verifica os casos especiais de CPF """ | ||
cpfs_repeated_digits = [ | ||
'000.000.000-00', | ||
'111.111.111-11', | ||
'222.222.222-22', | ||
'333.333.333-33', | ||
'444.444.444-44', | ||
'555.555.555-55', | ||
'666.666.666-66', | ||
'777.777.777-77', | ||
'888.888.888-88', | ||
'999.999.999-99', | ||
] | ||
# Entrada consideradas invalidas | ||
for cpf in cpfs_repeated_digits: | ||
self.assertFalse(self.cpf.validate(cpf)) | ||
# Entrada consideradas validas | ||
self.cpf.repeated_digits = True | ||
for cpf in cpfs_repeated_digits: | ||
self.assertTrue(self.cpf.validate(cpf)) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.