def setUp(self): app = flask_app.app app.config['TESTING'] = True app.config['WTF_CSRF_ENABLED'] = False app.config['DEBUG'] = False self.app = app.test_client() self.store_provider = StoreProvider(self.test_orders, self.test_status) def configure_test_bindings(binder): binder.bind( StoreProvider, to=self.store_provider, ) return binder FlaskInjector(app=app, modules=[configure_test_bindings])
def configure_bindings(binder): binder.bind(StoreProvider, to=StoreProvider(test_orders, test_status)) return binder
def test_get_store_inventory(self): store_provider = StoreProvider({}, test_status) self.assertEqual(get(store_provider), test_status)
def test_delete_order_not_found(self): store_provider = StoreProvider(test_orders, {}) res = store_provider.delete_order_by_id(9) self.assertEqual(res, False)
def test_delete_order_by_id_successful(self): order_to_delete = test_orders[0] store_provider = StoreProvider(test_orders, {}) store_provider.delete_order_by_id(1) self.assertNotIn(order_to_delete, store_provider.orders)
def test_find_order_by_id_fail(self): store_provider = StoreProvider(test_orders, {}) self.assertEqual(store_provider.find_order_by_id(55), None)
def test_find_order_by_id_success(self): store_provider = StoreProvider(test_orders, {}) self.assertEqual(store_provider.find_order_by_id(3), test_orders[2])
def test_get_order_by_id_order_not_found(self): store_provider = StoreProvider(test_orders, {}) self.assertEqual(get_order_by_id(store_provider, 5), (None, 404))
def get(store_provider: StoreProvider): return store_provider.get_status()
def delete_order_by_id(store_provider: StoreProvider, order_id): if store_provider.delete_order_by_id(order_id): return None, 200 return None, 404
def get_order_by_id(store_provider: StoreProvider, order_id): order = store_provider.find_order_by_id(order_id) if order: return order, 200 return None, 404
def post_order(store_provider: StoreProvider, order): store_provider.add_order(order) return order