def test_raises_bad_request_if_required_data_is_missing(self):
        data = {}
        request = request_factory.get_request(
            data=data,
            context_params={'crud_action': CrudActions.CREATE_DETAIL})

        response = self.validation.validate_request_data(request)

        assert_that(response.is_success, equal_to(False))
        assert_that(response.reason, equal_to(error_types.InvalidData))
        assert_that(len(response.data), equal_to(2))
        assert_that(response.data, has_items('name', 'is_active'))
    def test_raises_bad_request_if_required_data_is_missing(self):
        data = {}
        request = request_factory.get_request(
            data=data,
            context_params={'crud_action': CrudActions.CREATE_DETAIL})

        response = self.validation.validate_request_data(request)

        assert_that(response.is_success, equal_to(False))
        assert_that(response.reason, equal_to(error_types.InvalidData))
        assert_that(len(response.data), equal_to(2))
        assert_that(response.data, has_items('name', 'is_active'))
 def test_raises_bad_request_if_field_greater_than_max_length(self):
     data = {
         'name': 'John Smith',
         'is_active': True,
         'country': 'United States'
     }
     request = request_factory.get_request(
         data=data,
         context_params={'crud_action': CrudActions.UPDATE_DETAIL})
     response = self.validation.validate_request_data(request)
     assert_that(response.is_success, equal_to(False))
     assert_that(response.reason, equal_to(error_types.InvalidData))
     assert_that(len(response.data), equal_to(2))
     assert_that(response.data, has_items('name', 'country'))
 def test_raises_bad_request_if_field_greater_than_max_length(self):
     data = {
         'name': 'John Smith',
         'is_active': True,
         'country': 'United States'
     }
     request = request_factory.get_request(
         data=data,
         context_params={'crud_action': CrudActions.UPDATE_DETAIL})
     response = self.validation.validate_request_data(request)
     assert_that(response.is_success, equal_to(False))
     assert_that(response.reason, equal_to(error_types.InvalidData))
     assert_that(len(response.data), equal_to(2))
     assert_that(response.data, has_items('name', 'country'))
Esempio n. 5
0
    def test_find_all_two_lines(self):
        name1 = 'Pascal'
        name2 = 'George'

        line_sip1 = self.add_usersip(name=name1)
        line1 = self.add_line(protocolid=line_sip1.id,
                              name=name1)
        line_sip1 = self.add_usersip(name=name2)
        line2 = self.add_line(protocolid=line_sip1.id,
                              name=name2)

        lines = line_dao.find_all()

        assert_that(lines, has_length(2))
        assert_that(lines, has_items(
            all_of(
                has_property('id', line1.id),
                has_property('name', name1)),
            all_of(
                has_property('id', line2.id),
                has_property('name', name2))
        ))
Esempio n. 6
0
 def testMismatchDescriptionShowsFirstUnmetMatcherAndActualArgument(self):
     self.assert_mismatch_description(
         "a sequence containing 'a' was <42>", has_items("a", "b"), 42
     )
Esempio n. 7
0
 def testSuccessfulMatchDoesNotGenerateMismatchDescription(self):
     self.assert_no_mismatch_description(has_items("a", "b"), self._sequence("a", "b"))
Esempio n. 8
0
 def testHasAReadableDescription(self):
     self.assert_description(
         "(a sequence containing 'a' and a sequence containing 'b')", has_items("a", "b")
     )
Esempio n. 9
0
 def testNoMatchIfCollectionDoesntSatisfyAllMatchers(self):
     self.assert_does_not_match(
         "missing 'a'", has_items("a", "b", "c"), self._sequence("e", "c", "b", "d")
     )
Esempio n. 10
0
 def testShouldMatchCollectionContainingAllItemsPlusExtras(self):
     self.assert_matches(
         "all items plus extras",
         has_items("a", "b", "c"),
         self._sequence("e", "c", "b", "a", "d"),
     )
Esempio n. 11
0
 def testShouldMatchCollectionContainingAllItemsInDifferentOrder(self):
     self.assert_matches(
         "all items in different order", has_items("a", "b", "c"), self._sequence("c", "b", "a")
     )
Esempio n. 12
0
 def testProvidesConvenientShortcutForMatchingWithEqualTo(self):
     self.assert_matches(
         "Values automatically wrapped with equal_to",
         has_items("a", "b", "c"),
         self._sequence("a", "b", "c"),
     )
Esempio n. 13
0
 def testShouldMatchCollectionContainingAllItems(self):
     self.assert_matches(
         "contains all items",
         has_items(equal_to("a"), equal_to("b"), equal_to("c")),
         self._sequence("a", "b", "c"),
     )
Esempio n. 14
0
 def testDescribeMismatch(self):
     self.assert_describe_mismatch("a sequence containing 'a' was <42>", has_items("a", "b"), 42)