Esempio n. 1
0
 def test_EmailValidation_ShouldAcceptCorrectEmailAddress(self):
     address = Address()
     addressValidation = AddressValidation()
     address.Email = "*****@*****.**"
     address.Street = "Pasdaran Golestane dovom"
     result = addressValidation.validate(address)
     assert result is None
Esempio n. 2
0
    def test_ObjectIdValidation_ShouldNotAcceptIncorrectObjectId(self):
        employee = Employee()
        employee.Name = "Hooman"
        employee.Office.Code = -1
        employee.Office.UnitNumber = -100
        employee.Office.FloorNo = 10
        employee.Office.SectionNo = 5
        employee.Addresses.append(Address._getAddressInstance())
        employee.Addresses.append(Address._getAddressInstance())
        employeeValidation = EmployeeValidation()
        result = employeeValidation.validate(employee)
        assert result is None
        try:
            employee._id = "12345a"
            result = employeeValidation.validate(employee)
            assert result is not None
        except ValidationException as ex:
            assert ex.Errors

        try:
            employee._id = "12zxh"
            result = employeeValidation.validate(employee)
            assert result is not None
        except ValidationException as ex:
            assert ex.Errors
Esempio n. 3
0
 def test_OnlyStringValidation_ShouldAcceptStringWhichOnlyContainsAlphabeticalCharacterWithSpaces(self):
     address = Address()
     addressValidation = AddressValidation()
     address.Email = "*****@*****.**"
     address.Street = "خیابان آزادي کوچه رها"
     addressValidation.validate(address)
     address.street = "azadi st raha ave"
     result = addressValidation.validate(address)
     assert result is None
Esempio n. 4
0
 def test_SizeValidation_ShouldGuranteeStringSizeShouldNotBeLowerThanMinValue(self):
     try:
         address = Address()
         addressValidation = AddressValidation()
         address.Email = "*****@*****.**"
         address.Street = "Pasdaran"
         result = addressValidation.validate(address)
         assert result is not None
     except ValidationException as ex:
         assert ex.Errors
Esempio n. 5
0
 def test_SizeValidation_ShouldGuranteeStringSizeShouldNotBeHigherThanMaxValue(self):
     try:
         address = Address()
         addressValidation = AddressValidation()
         address.Email = "*****@*****.**"
         address.Street = "Pasdaran golestane dovom pelake 57 zange 2"
         result = addressValidation.validate(address)
         assert result is not None
     except ValidationException as ex:
         assert ex.Errors
Esempio n. 6
0
    def test_CustomValidation_ShouldValidateItemsInListBasedOnSpecifiedValidationInstance(self):
        try:
            employee = Employee()
            employee.Name = "Hooman"
            employee.Office.Code = 11
            employee.Office.UnitNumber = 15
            employee.Office.FloorNo = -10
            employee.Office.SectionNo = 55

            address1 = Address()
            address1.Email = "hooman.frgmail.com"
            address1.Street = "Pasdaran"

            address2 = Address()
            address2.Email = "hooman.fryahoo.com"
            address2.Street = "golestan dovom pelake panjaho haft zange dovom"

            address3 = Address()
            address3.Email = "hooman.frhotmail.com"
            address3.Street = "pelak"

            employee.Phones.append(-1235)
            employee.Phones.append(-867)
            employee.Phones.append(0)

            employee.Addresses.append(address1)
            employee.Addresses.append(address2)
            employee.Addresses.append(address3)

            employeeValidation = EmployeeValidation()

            result = employeeValidation.validate(employee)
            assert result is not None
        except ValidationException as ex:
            assert ex.Errors
Esempio n. 7
0
 def test_CustomValidation_ShouldAcceptDateWhichObserveCustomValidation(self):
     employee = Employee()
     employee.Name = "Hooman"
     employee.Office.Code = -1
     employee.Office.UnitNumber = -100
     employee.Office.FloorNo = 10
     employee.Office.SectionNo = 5
     employee.Addresses.append(Address._getAddressInstance())
     employee.Addresses.append(Address._getAddressInstance())
     employeeValidation = EmployeeValidation()
     result = employeeValidation.validate(employee)
     assert result is None
Esempio n. 8
0
 def test_SizeValidation_ShouldAcceptValueWhichIsAvailableInMaxMinBoundry(self):
     employee = Employee()
     employee.Name = "Hooman"
     employee.Office.Code = -1
     employee.Office.UnitNumber = -100
     employee.Office.FloorNo = 10
     employee.Office.SectionNo = 5
     employee.Addresses.append(Address._getAddressInstance())
     employee.Addresses.append(Address._getAddressInstance())
     employeeValidation = EmployeeValidation()
     result = employeeValidation.validate(employee)
     assert result is None
Esempio n. 9
0
 def test_ManualValidation_ShouldReturnValidationErrorWithSpecifiedCode(self):
     try:
         employee = Employee()
         employee.Name = "Hooman"
         employee.Office.Code = -1
         employee.Office.UnitNumber = -100
         employee.Office.FloorNo = 10
         employee.Office.SectionNo = 753
         employee.Addresses.append(Address._getAddressInstance())
         employee.Addresses.append(Address._getAddressInstance())
         employeeValidation = EmployeeValidation()
         result = employeeValidation.validate(employee)
         assert result is not None
     except ValidationException as ex:
         assert ex.Errors
Esempio n. 10
0
 def test_CustomValidation_ShouldReturnErrorForRegisteredCustomValidation(self):
     try:
         employee = Employee()
         employee.Name = "Hooman"
         employee.Office.Code = 0
         employee.Office.UnitNumber = 10
         employee.Office.FloorNo = -10
         employee.Office.SectionNo = 0
         employee.Addresses.append(Address._getAddressInstance())
         employee.Addresses.append(Address._getAddressInstance())
         employeeValidation = EmployeeValidation()
         result = employeeValidation.validate(employee)
         assert result is not None
     except ValidationException as ex:
         assert ex.Errors
Esempio n. 11
0
 def test_NullValidation_ShouldNotAcceptItemWithValueOfNone(self):
     try:
         employee = Employee()
         employee.Name = None
         employee.Office.Code = -1
         employee.Office.UnitNumber = -100
         employee.Office.FloorNo = 10
         employee.Office.SectionNo = 5
         employee.Addresses.append(Address._getAddressInstance())
         employee.Addresses.append(Address._getAddressInstance())
         employeeValidation = EmployeeValidation()
         result = employeeValidation.validate(employee)
         assert result is not None
     except ValidationException as ex:
         assert ex.Errors
Esempio n. 12
0
    def test_TextSizeValidation_ShouldAcceptTextWhichItsCountOfWordsIsAvailableInMaxMinBoundry(self):
        address = Address()
        addressValidation = AddressValidation()
        address.Email = "*****@*****.**"
        address.Street = """alsdkfjasdk
lkdjfalkf
lkjdfalskfj
akjfdakjdf"""
        result = addressValidation.validate(address)
        assert result is None
        address.Street = "Pasdaran golestane dovom pelake panjahohaft"
        anotehrResult = addressValidation.validate(address)
        assert anotehrResult is None
        address.Street = "Pasdaran golestane dovom"
        andAnotehrResult = addressValidation.validate(address)
        assert andAnotehrResult is None
Esempio n. 13
0
 def test_SizeValidation_ShouldGuranteeValueShouldNotBeHigherThanMaxValue(self):
     try:
         employee = Employee()
         employee.Name = "Hooman"
         employee.Office.Code = -1
         employee.Office.UnitNumber = -100
         employee.Office.FloorNo = 10
         employee.Office.SectionNo = 5
         employee.Addresses.append(Address._getAddressInstance())
         employee.Addresses.append(Address._getAddressInstance())
         employee.Addresses.append(Address._getAddressInstance())
         employeeValidation = EmployeeValidation()
         result = employeeValidation.validate(employee)
         assert result is not None
     except ValidationException as ex:
         assert ex.Errors
Esempio n. 14
0
    def test_OnlyStringValidation_ShouldNotAcceptStringWhichContainsNotAlphabeticalCharacter(self):
        address = Address()
        addressValidation = AddressValidation()
        try:
            address.Email = "*****@*****.**"
            address.Street = "?????? ????? ???? 2"
            result = addressValidation.validate(address)
            assert result is not None
        except ValidationException as ex:
            assert ex.Errors

        try:
            address.Street = "Pasdaran-golestane dovom"

            result = addressValidation.validate(address)
            assert result is not None
        except ValidationException as ex:
            assert ex.Errors
Esempio n. 15
0
 def test_sizeValidation_ShouldAcceptTextWhichItsCountOfCharactersIsAvailableInMaxMinBoundry(self):
     employee = Employee()
     employee.Name = "Hooman"
     employee.Office.Code = -1
     employee.Office.UnitNumber = -100
     employee.Office.FloorNo = 10
     employee.Office.SectionNo = 5
     employee.Addresses.append(Address._getAddressInstance())
     employee.Addresses.append(Address._getAddressInstance())
     employeeValidation = EmployeeValidation()
     result = employeeValidation.validate(employee)
     assert result is None
     try:
         employee.Name = "ho"
         result = employeeValidation.validate(employee)
         assert result is not None
     except ValidationException as ex:
         assert ex.Errors
Esempio n. 16
0
 def test_ObjectIdValidation_ShouldAcceptCorrectObjectId(self):
     employee = Employee()
     employee.Name = "Hooman"
     employee.Office.Code = -1
     employee.Office.UnitNumber = -100
     employee.Office.FloorNo = 10
     employee.Office.SectionNo = 5
     employee.Addresses.append(Address._getAddressInstance())
     employee.Addresses.append(Address._getAddressInstance())
     employeeValidation = EmployeeValidation()
     result = employeeValidation.validate(employee)
     assert result is None
     try:
         employee._id = "58fafa353ae7282b18041c1e"
         result = employeeValidation.validate(employee)
         assert result is None
     except ValidationException as ex:
         assert ex.Errors
Esempio n. 17
0
    def test_EmailValidation_ShouldNotAcceptIncorrectEmailAddress(self):
        address = Address()
        addressValidation = AddressValidation()

        try:

            address.Email = "hooman.frgmail.com"
            address.Street = "Pasdaran Golestane dovom"
            result = addressValidation.validate(address)
            assert result is not None
        except ValidationException as ex:
            assert ex.Errors

        try:
            address.Email = "hooman.fr@gmailcom"

            result = addressValidation.validate(address)
            assert result is not None
        except ValidationException as ex:
            assert ex.Errors