Esempio n. 1
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. 2
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. 3
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. 4
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. 5
0
 def test_SizeValidation_ShouldGuranteeValueShouldNotBeLowerThanMinValue(self):
     try:
         employee = Employee()
         employee.Name = "Hooman"
         employee.Office.Code = -1
         employee.Office.UnitNumber = -100
         employee.Office.FloorNo = 10
         employee.Office.SectionNo = 5
         employeeValidation = EmployeeValidation()
         result = employeeValidation.validate(employee)
         assert result is not None
     except ValidationException as ex:
         assert ex.Errors
Esempio n. 6
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. 7
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. 8
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. 9
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. 10
0
    def test_OnlyPersianValidation_ShouldNotAcceptNotPersianString(self):
        employee = Employee()
        only_persian_validation = PersianEmployeeValidation()
        try:
            employee.Name = "آقایmr"
            result = only_persian_validation.validate(employee)
            assert result is not None
        except ValidationException as ex:
            assert ex.Errors

        try:
            employee.Name = "mis aj"
            result = only_persian_validation.validate(employee)
            assert result is not None
        except ValidationException as ex:
            assert ex.Errors
Esempio n. 11
0
    def test_OnlyEnglishValidation_ShouldNotAcceptNotEnglishString(self):
        employee = Employee()
        only_english_validation = EnglishEmployeeValidation()
        try:
            employee.Name = "آقایmr"
            result = only_english_validation.validate(employee)
            assert result is not None
        except ValidationException as ex:
            assert ex.Errors

        try:
            employee.Name = " رضوان"
            result = only_english_validation.validate(employee)
            assert result is not None
        except ValidationException as ex:
            assert ex.Errors
Esempio n. 12
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. 13
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. 14
0
 def test_OnlyPersianValidation_ShouldAcceptStringWhichOnlyContainsPersianAlphabeticalCharacterWithSpaces(self):
     employee = Employee()
     employee.name = "رضوان آژ"
     only_persian_validation = PersianEmployeeValidation()
     result = only_persian_validation.validate(employee)
     assert result is None
Esempio n. 15
0
 def test_OnlyEnglishValidation_ShouldAcceptStringWhichOnlyContainsEnglishAlphabeticalCharacterWithSpaces(self):
     employee = Employee()
     employee.name = "Rezvan aj"
     only_english_validation = EnglishEmployeeValidation()
     result = only_english_validation.validate(employee)
     assert result is None