def test_storageroom_model_comparison(): storageroom_dict = { 'code': uuid.uuid4(), 'size': 200, 'price': 10, 'longitude': -0.09998975, 'latitude': 51.75436293 } storageroom1 = StorageRoom.from_dict(storageroom_dict) storageroom2 = StorageRoom.from_dict(storageroom_dict) assert storageroom1 == storageroom2
def list(self, filters=None): if not filters: return self._entries result = [] result.extend(self._entries) for key, value in filters.items(): result = [e for e in result if self._check(e, key, value)] return [StorageRoom.from_dict(r) for r in result]
def test_storageroom_model_from_dict(): code = uuid.uuid4() storageroom = StorageRoom.from_dict({ 'code': code, 'size': 200, 'price': 10, 'longitude': '-0.09998975', 'latitude': '51.75436293' }) assert storageroom.code == code assert storageroom.size == 200 assert storageroom.price == 10 assert storageroom.longitude == -0.09998975 assert storageroom.latitude == 51.75436293
import json from unittest import mock from rentomatic.domain.storageroom import StorageRoom from rentomatic.shared import response_object as res first_storageroom_dict = { 'code': '3251a5bd-86be-428d-8ae9-6e51a8048c33', 'size': 200, 'price': 10, 'longitude': -0.09998975, 'latitude': 51.75436293 } first_storageroom_domain_model = StorageRoom.from_dict(first_storageroom_dict) storagerooms = [first_storageroom_domain_model] @mock.patch('rentomatic.use_cases.storageroom_use_cases.StorageRoomListUseCase' ) def test_get(mock_use_case, client): mock_use_case().execute.return_value = res.ResponseSuccess(storagerooms) http_response = client.simulate_get('/storagerooms') assert json.loads( http_response.content.decode('UTF-8')) == [first_storageroom_dict] assert http_response.status_code == 200 assert http_response.headers.get('mimetype') == 'application/json'
import json from unittest import mock from rentomatic.domain.storageroom import StorageRoom from rentomatic.shared import response_object as res storageroom1_dict = { 'code': '3251a5bd-86be-428d-8ae9-6e51a8048c33', 'size': 200, 'price': 10, 'longitude': -0.09998975, 'latitude': 51.75436293 } storageroom1_domain_model = StorageRoom.from_dict(storageroom1_dict) storagerooms = [storageroom1_domain_model] @mock.patch('rentomatic.use_cases.storageroom_use_case.StorageRoomListUseCase') def test_get(mock_use_case, client): mock_use_case().execute.return_value = res.ResponseSuccess(storagerooms) http_response = client.get('/storagerooms') assert json.loads( http_response.data.decode('UTF-8')) == [storageroom1_dict] assert http_response.status_code == 200 assert http_response.mimetype == 'application/json'
def storageroom_model(storageroom_dict): return StorageRoom.from_dict(storageroom_dict)