Ejemplo n.º 1
0
    def test_raises_error_for_invalid_abn(self):
        """Test that an ABN must pass the ATO's validation algorithm."""
        invalid_abn = '53004085617'

        validator = AUBusinessNumberFieldValidator()

        self.assertRaises(ValidationError, lambda: validator(invalid_abn))
Ejemplo n.º 2
0
    def test_raises_error_for_too_short_abn(self):
        """Test an ABN with fewer than eleven digits is invalid."""
        invalid_abn = '5300408561'

        validator = AUBusinessNumberFieldValidator()

        self.assertRaises(ValidationError, lambda: validator(invalid_abn))
Ejemplo n.º 3
0
    def test_no_error_for_a_valid_abn(self):
        """Test a valid ABN does not cause an error."""
        valid_abn = '53004085616'

        validator = AUBusinessNumberFieldValidator()

        validator(valid_abn)
Ejemplo n.º 4
0
    def test_raises_error_for_abn_containing_a_letter(self):
        """Test an ABN containing a letter is invalid."""
        invalid_abn = '5300408561A'

        validator = AUBusinessNumberFieldValidator()

        self.assertRaises(ValidationError, lambda: validator(invalid_abn))
Ejemplo n.º 5
0
    def test_raises_error_for_whitespace(self):
        """Test an ABN can be valid when it contains whitespace."""

        # NB: Form field should strip the whitespace before regex validation is run.
        invalid_abn = '5300 4085 616'
        validator = AUBusinessNumberFieldValidator()
        self.assertRaises(ValidationError, lambda: validator(invalid_abn))