Esempio n. 1
0
class TestUserResource(unittest.TestCase):

    def setUp(self):
        self.service = Mock()
        self.proxy = LineServiceProxy(self.service)
        self.items = [sentinel.item1, sentinel.item2]

    def test_when_q_param_sent_then_lines_searched_by_name(self):
        self.service.find_all_by_name.return_value = self.items
        expected_result = SearchResult(items=self.items, total=2)

        result = self.proxy.search({'q': 'myfullname'})

        self.service.find_all_by_name.assert_called_once_with('myfullname')
        assert_that(result, equal_to(expected_result))

    def test_when_no_params_sent_then_all_lines_returned(self):
        self.service.find_all.return_value = self.items
        expected_result = SearchResult(items=self.items, total=2)

        result = self.proxy.search({})

        self.service.find_all.assert_called_once_with()
        assert_that(result, equal_to(expected_result))
Esempio n. 2
0
 def setUp(self):
     self.service = Mock()
     self.proxy = LineServiceProxy(self.service)
     self.items = [sentinel.item1, sentinel.item2]