Exemple #1
0
 def test_format_postcode1(self):
     """ Unit test to test formatting of the Postcode
         Positive case
     """
     postcode_inst = PostCodes(10)
     num = postcode_inst.format_postcode('PO167GZ')
     assert num == 'PO16 7GZ'
     print("Formatted Postcode: " + num + "\nTest1: Successful")
Exemple #2
0
    def test_validate_postcode1(self):
        """ Unit test for validating of the Postcode
            Positive case
        """
        postcode_inst = PostCodes(10)

        num = postcode_inst.validate_postcode('PO167GZ')
        assert num == True
        print('Test6: Successful')
Exemple #3
0
    def test_validate_postcode6(self):
        """ Unit test for validating of the Postcode
            Negative case
        """
        postcode_inst = PostCodes(10)

        # The final two letters do not use the letters CIKMOV
        num = postcode_inst.validate_postcode('PO167GV')
        assert num == False
        print('Test11: Successful')
Exemple #4
0
    def test_validate_postcode5(self):
        """ Unit test for validating of the Postcode
            Negative case
        """
        postcode_inst = PostCodes(10)

        # The letters IJZ are not used in the second position
        num = postcode_inst.validate_postcode('VI1A 1BB')
        assert num == False
        print('Test10: Successful')
Exemple #5
0
    def test_validate_postcode4(self):
        """ Unit test for validating of the Postcode
            Negative case
        """
        postcode_inst = PostCodes(10)

        # Only letters to appear in the fourth position are ABEHMNPRVWXY
        num = postcode_inst.validate_postcode('AA9C 0AX')
        assert num == False
        print('Test9: Successful')
Exemple #6
0
    def test_validate_postcode3(self):
        """ Unit test for validating of the Postcode
            Negative case
        """
        postcode_inst = PostCodes(10)

        # Only letters to appear in the third position are ABCDEFGHJKPSTUW
        num = postcode_inst.validate_postcode('A9X 0AX')
        assert num == False
        print('Test8: Successful')
Exemple #7
0
    def test_validate_postcode2(self):
        """ Unit test for validating of the Postcode
            Negative case
        """
        postcode_inst = PostCodes(10)

        # The letters QVX are not used in the first position
        num = postcode_inst.validate_postcode('VC1A 1BB')
        assert num == False
        print('Test7: Successful')
Exemple #8
0
 def test_format_postcode2(self):
     """ Unit test for formatting of the Postcode
         Checks for special characters in the Postcode and throws an exception
     """
     postcode_inst = PostCodes(10)
     try:
         postcode_inst.format_postcode('PO16 #7GZ')
     except TypeError:
         print("Expected an exception.\n"
               "Postcode contains special character.\n"
               "Test2: Successful")
Exemple #9
0
 def test_validate_component_postcode2(self):
     """ Unit test to validate the different
         components of the Postcode
         Negative case
     """
     postcode_inst = PostCodes(10)
     num = postcode_inst.validate_postcode_components('PO167GZ')
     assert num.postcode_area == 'PO' and num.postcode_district == '16'\
            and num.postcode_sector == '7' and num.postcode_unit == 'GZ'
     print("Postcode Area: " + num.postcode_area + "\nPostcode district: " + num.postcode_district + \
           "\nPostcode sector: " + num.postcode_sector + "\nPostcode Unit: " + num.postcode_unit + \
           "\nTest5: Successful")
Exemple #10
0
 def test_format_postcode3(self):
     """ Unit test to test formatting of the Postcode
         Checks for length of Postcode and throws an exception
         if the the length doesn't lie between 6 and 8
     """
     postcode_inst = PostCodes(10)
     try:
         postcode_inst.format_postcode('PO167')
     except TypeError:
         print("Expected an exception.\n"
               "Length of the Postcode should be between 6 and 8.\n"
               "Test3: Successful")