Example #1
0
    def test_when_offset_is_a_positive_number(self):
        offset = "20"
        validator = Validator("", "", "Coventry University", "", "", "0", 100, offset, "en")

        expected_result = 20
        output_result, output_error_object = validator.validate_offset()

        self.assertEqual(expected_result, output_result)
        self.assertEqual([], output_error_object)
Example #2
0
    def test_when_offset_is_not_a_number(self):
        offset = "twenty"
        validator = Validator("", "", "Coventry University", "", "", "0", 100, offset, "en")

        expected_result = 0
        expected_error_object = [
            {
                "error": "offset value needs to be a number",
                "error_values": [{"offset": offset}],
            }
        ]
        output_result, output_error_object = validator.validate_offset()

        self.assertEqual(expected_result, output_result)
        self.assertEqual(expected_error_object, output_error_object)
Example #3
0
    def test_when_offset_is_a_negative_number(self):
        offset = "-20"
        validator = Validator("", "", "Coventry University", "", "", "0", 100, offset, "en")

        expected_result = -20
        expected_error_object = [
            {
                "error": "offset needs to be a positive number, offset cannot be lower than 0",
                "error_values": [{"offset": offset}],
            }
        ]
        output_result, output_error_object = validator.validate_offset()

        self.assertEqual(expected_result, output_result)
        self.assertEqual(expected_error_object, output_error_object)