Example #1
0
    def test_multiple_invalid_properties_raise_multiple_errors(self):
        invalid_record = {
            "_id": "dbl_boff_0000000000000001",
            "name": "big_boff",
            "downtime": "def",
            "uptime": "abc"
        }

        errors = validate_record_schema(
            invalid_record,
            self.schema_with_two_requirements
        )

        assert_that(
            errors[0],
            contains_string(
                "'abc' is not of type 'integer'")
        )
        assert_that(
            errors[1],
            contains_string(
                "'def' is not of type 'integer'")
        )
        assert_that(
            len(errors),
            2
        )
    def test_invalid_property_raises_validation_error(self):
        invalid_record = {
            "_id": "dbl_boff_0000000000000001",
            "name": "big_boff",
            "_timestamp": "555"
        }

        errors = validate_record_schema(invalid_record, self.schema)

        assert_that(errors[0], contains_string("'555' is not a 'date-time'"))
        assert_that(len(errors), is_(1))
    def test_missing_property_returns_error(self):
        invalid_record = {
            "_id": "dbl_boff_0000000000000001",
            "name": "big_boff",
        }

        errors = validate_record_schema(invalid_record, self.schema)

        assert_that(errors[0],
                    contains_string("_timestamp' is a required property"))
        assert_that(len(errors), 0)
Example #4
0
    def test_valid_property_does_not_raise_exception(self):
        valid_record = {
            "_timestamp": "2014-06-12T00:00:00+0000"
        }

        assert_that(
            validate_record_schema(
                valid_record,
                self.schema
            ), is_([])
        )
    def test_multiple_missing_properties_raise_multiple_errors(self):
        invalid_record = {
            "_id": "dbl_boff_0000000000000001",
            "name": "big_boff",
            "_timestamp": "555"
        }

        errors = validate_record_schema(invalid_record,
                                        self.schema_with_two_requirements)

        assert_that(errors[0],
                    contains_string("uptime' is a required property"))
        assert_that(errors[1],
                    contains_string("downtime' is a required property"))
        assert_that(len(errors), 2)
    def test_multiple_invalid_properties_raise_multiple_errors(self):
        invalid_record = {
            "_id": "dbl_boff_0000000000000001",
            "name": "big_boff",
            "downtime": "def",
            "uptime": "abc"
        }

        errors = validate_record_schema(invalid_record,
                                        self.schema_with_two_requirements)

        assert_that(errors[0],
                    contains_string("'abc' is not of type 'integer'"))
        assert_that(errors[1],
                    contains_string("'def' is not of type 'integer'"))
        assert_that(len(errors), 2)
Example #7
0
    def test_missing_property_returns_error(self):
        invalid_record = {
            "_id": "dbl_boff_0000000000000001",
            "name": "big_boff",
        }

        errors = validate_record_schema(
            invalid_record,
            self.schema
        )

        assert_that(
            errors[0],
            contains_string("_timestamp' is a required property")
        )
        assert_that(
            len(errors),
            0
        )
Example #8
0
    def test_invalid_property_raises_validation_error(self):
        invalid_record = {
            "_id": "dbl_boff_0000000000000001",
            "name": "big_boff",
            "_timestamp": "555"
        }

        errors = validate_record_schema(
            invalid_record,
            self.schema
        )

        assert_that(
            errors[0],
            contains_string(
                "'555' is not a 'date-time'")
        )
        assert_that(
            len(errors),
            is_(1)
        )
Example #9
0
    def test_multiple_missing_properties_raise_multiple_errors(self):
        invalid_record = {
            "_id": "dbl_boff_0000000000000001",
            "name": "big_boff",
            "_timestamp": "555"
        }

        errors = validate_record_schema(
            invalid_record,
            self.schema_with_two_requirements
        )

        assert_that(
            errors[0],
            contains_string("uptime' is a required property")
        )
        assert_that(
            errors[1],
            contains_string("downtime' is a required property")
        )
        assert_that(
            len(errors),
            2
        )
    def test_valid_property_does_not_raise_exception(self):
        valid_record = {"_timestamp": "2014-06-12T00:00:00+0000"}

        assert_that(validate_record_schema(valid_record, self.schema), is_([]))