Example #1
0
    def test_search_with_valid_direction(self, device_dao_search):
        expected = Mock(SearchResult)

        device_dao_search.return_value = expected

        result = device_services.search(direction='desc')

        self.assertEquals(result, expected)
        device_dao_search.assert_called_once_with(direction='desc')
Example #2
0
    def test_search_with_skip_at_0(self, device_dao_search):
        expected = Mock(SearchResult)

        device_dao_search.return_value = expected

        result = device_services.search(skip=0)

        self.assertEquals(result, expected)
        device_dao_search.assert_called_once_with(skip=0)
Example #3
0
    def test_search_with_valid_order(self, device_dao_search):
        expected = Mock(SearchResult)

        device_dao_search.return_value = expected

        result = device_services.search(order='ip')

        self.assertEquals(result, expected)
        device_dao_search.assert_called_once_with(order='ip')
Example #4
0
    def test_search(self, device_dao_search):
        expected = Mock(SearchResult)

        device_dao_search.return_value = expected

        result = device_services.search()

        self.assertEquals(result, expected)
        device_dao_search.assert_called_once_with()
Example #5
0
    def test_search_with_search(self, device_dao_search):
        search_term = 'toto'
        device = Mock(Device)

        expected = [device]

        device_dao_search.return_value = expected

        result = device_services.search(search=search_term)

        self.assertEquals(result, expected)
        device_dao_search.assert_called_once_with(search=search_term)
Example #6
0
    def test_search_with_search(self, device_dao_search):
        search_term = 'toto'
        device = Mock(Device)

        expected = [device]

        device_dao_search.return_value = expected

        result = device_services.search(search=search_term)

        self.assertEquals(result, expected)
        device_dao_search.assert_called_once_with(search=search_term)
Example #7
0
def list():
    search_parameters = extract_search_parameters(request.args)
    search_result = device_services.search(**search_parameters)
    result = formatter.list_to_api(search_result.items, search_result.total)
    return make_response(result, 200)
Example #8
0
def list():
    search_parameters = extract_search_parameters(request.args)
    search_result = device_services.search(**search_parameters)
    result = formatter.list_to_api(search_result.items, search_result.total)
    return make_response(result, 200)