def test_invalid_limit(self, ctx, device_manager: DeviceManager): # When... with raises(IntMustBePositive): device_manager.search(ctx, limit=-1, offset=1, username=TEST_USERNAME, terms='blabla')
def test_happy_path(self, ctx, mock_device_repository: MagicMock, sample_device: Device, device_manager: DeviceManager): # Given... terms = 'blah blah blah' mock_device_repository.search_device_by = MagicMock( return_value=([sample_device], 1)) # When... result, count = device_manager.search(ctx, limit=10, offset=1, username=TEST_USERNAME, terms=terms) # Expect... assert [sample_device] == result assert 1 == count mock_device_repository.search_device_by.assert_called_once_with( ctx, limit=10, offset=1, username=TEST_USERNAME, terms=terms)