Skip to content

Commit

Permalink
refactor: do a small refactor on the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matheuscas committed Jan 16, 2024
1 parent c4332a9 commit b486182
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 30 deletions.
31 changes: 9 additions & 22 deletions tests/calculation_tests.py → tests/test_calculation.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
import sys
import unittest

if sys.version[0] == '2':
from pycpfcnpj import calculation as calc
else:
import os
import inspect
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0,parentdir)
import pycpfcnpj.calculation as calc
from pycpfcnpj import calculation as calc


class CalculationTests(unittest.TestCase):

"""docstring for CalculationTests"""

def setUp(self):
Expand All @@ -33,16 +23,16 @@ def test_cpf_calculate_first_digit_false(self):

def test_cpf_calculate_second_digit_true(self):
updated_cpf_number = self.first_part_cpf_number + \
calc.calculate_first_digit(
self.first_part_cpf_number)
calc.calculate_first_digit(
self.first_part_cpf_number)
correct_second_digit = '5'
self.assertEqual(correct_second_digit,
calc.calculate_second_digit(updated_cpf_number))

def test_cpf_calculate_second_digit_false(self):
updated_cpf_number = self.first_part_cpf_number + \
calc.calculate_first_digit(
self.first_part_cpf_number)
calc.calculate_first_digit(
self.first_part_cpf_number)
incorrect_second_digit = '7'
self.assertNotEqual(incorrect_second_digit,
calc.calculate_second_digit(updated_cpf_number))
Expand All @@ -61,19 +51,16 @@ def test_cnpj_calculate_first_digit_false(self):
def test_cnpj_calculate_second_digit_true(self):
correct_second_digit = '1'
updated_cnpj_number = self.first_part_cnpj_number + \
calc.calculate_first_digit(
self.first_part_cnpj_number)
calc.calculate_first_digit(
self.first_part_cnpj_number)
self.assertEqual(correct_second_digit,
calc.calculate_second_digit(updated_cnpj_number))

def test_cnpj_calculate_second_digit_false(self):
correct_second_digit = '2'
updated_cnpj_number = self.first_part_cnpj_number + \
calc.calculate_first_digit(
self.first_part_cnpj_number)
calc.calculate_first_digit(
self.first_part_cnpj_number)
self.assertNotEqual(correct_second_digit,
calc.calculate_second_digit(updated_cnpj_number))


if __name__ == '__main__':
unittest.main(verbosity=2)
4 changes: 0 additions & 4 deletions tests/cnpj_tests.py → tests/test_cnpj.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,3 @@ def test_validate_cnpj_with_alphabetic_characters(self):

def test_validate_cnpj_with_special_characters(self):
self.assertFalse(cnpj.validate(self.invalid_cnpj_with_special_character))


if __name__ == "__main__":
unittest.main(verbosity=2)
4 changes: 0 additions & 4 deletions tests/cpf_tests.py → tests/test_cpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,3 @@ def test_validate_cpf_with_alphabetic_characters(self):

def test_validate_cpf_with_special_characters(self):
self.assertFalse(cpf.validate(self.invalid_cpf_with_special_character))


if __name__ == "__main__":
unittest.main(verbosity=2)
File renamed without changes.
File renamed without changes.

0 comments on commit b486182

Please sign in to comment.