def test__eq__fail_on_id(self): """ Tests __eq__ - fails on id """ L1 = Location("Endor", 1, "Endor", "Z", "Y", "X", "W", -1, 1, 9001) L2 = Location("Endor", 1, "Endor", "Z", "Y", "X", "W", -1, 1, 9001) L2.id = 4 assert L1 != L2
def __fill_db(self, cnt): location = Location(address='Some address') location.id = 1 db.session.add(location) routers = {} for i in range(cnt): router = Router( model=app.config['ROUTER_MODELS'][i % len( app.config['ROUTER_MODELS'])], location_id=location.id, ) db.session.add(router) db.session.commit() routers[router.id] = router return routers
def test_router_post(self, model, location_id, status_code, content): with self.app as context: location = Location(address='Some address') location.id = location_id db.session.add(location) response = context.post( '/api/routers', data=json.dumps(content), content_type='application/json', ) assert response.status_code == status_code, response.data if status_code == HTTPStatus.CREATED: data = json.loads(response.data.decode('utf8')) assert data['router']['model'] == model assert data['router']['location_id'] == location_id assert data['router']['state'] == 'deactivated' assert data['router']['location_id'] == location_id
def test_router_put(self, model, state, location_id, content): with self.app as context: location = Location(address='Some address') location.id = 1 db.session.add(location) router = Router(model=app.config['ROUTER_MODELS'][0], location_id=1) db.session.add(router) db.session.commit() response = context.put(f'/api/routers/{router.id}', data=json.dumps(content), content_type='application/json') assert response.status_code == HTTPStatus.OK, response.data data = json.loads(response.data.decode('utf8')) data['router'] == router.data() response = context.get(f'/api/routers/{router.id}') data = json.loads(response.data.decode('utf8')) assert data['router'] == router.data()