def test_store_creation(self): store = StoreModel('test_store') self.assertEqual(store.name, 'test_store')
def delete(self, name): if StoreModel.find_store_by_name(name): store = StoreModel(name) store.delete_from_db() return {'success': 'store deleted successfully'} return {'error': 'store not found'}, 404
def test_create_store_items_empty(self): store = StoreModel('test') self.assertListEqual(store.items.all(), [])
def test_store_json(self): store = StoreModel('test store') expected = {'name': 'test store', 'items': []} self.assertDictEqual(store.json(), expected)
def test_store_json_empty_items(self): with self.app_context(): store = StoreModel('test-store') expected = {'name': 'test-store', 'items': []} self.assertDictEqual(store.json(), expected)
def test_store_json(self): store = StoreModel("test") expected = {"name": "test", "items": []} self.assertDictEqual(store.json(), expected)
def test_create_store(self): store = StoreModel('test') self.assertEqual( store.name, 'test', "The name of the store after creation does not equal 'test'")
def test_store_json(self): store = StoreModel("test") expected = {"id": None, 'name': "test", 'items': []} self.assertEqual(store.json(), expected)
def test_store_model_crud(self): self.store_model = StoreModel(6, 'TestProduct', 19.99) self.assertIsNone(self.store_model.find_by_product('TestProduct')) self.assertIsNotNone(self.store_model.find_by_product('car_1'))
def test_create_store(self): store = StoreModel("test") self.assertEqual( store.name, "test", "The store name store creation does not equal the constructor argument." )
def test_create_store(self): store = StoreModel('test') self.assertEqual(store.name, 'test', "Name of store is not equal to constructors argument")
def post(self,name): if StoreModel.find_by_name(name): return {'message':"a store with name '{}' already there".format(name)},400 store=StoreModel(name) store.save_to_db()
def post(self, name): if StoreModel.find_by_name(name): return {'message': 'There is a store like this in the DB'}, 400 new_store = StoreModel(name) new_store.save_to_db() return new_store.json()
def test_create_store_item_empty(self): store = StoreModel('test') self.assertListEqual(store.items.all(), [], "items is not empty when creating store")
def test_create_store(self): store = StoreModel("Test Store") self.assertEqual(store.name, "Test Store")
def setUp(self): self.store = StoreModel('Test name') return super(TestStore, self).setUp()
def test_create_duplicate_store(self): with self.app() as client: with self.app_context(): StoreModel('test').save_to_db() resp = client.post('/store/test') self.assertEqual(resp.status_code, 400)
def test_store_json(self): # this is checking the database returns entry store = StoreModel('test') expected = {'id': None, 'name': 'test', 'items': []} self.assertDictEqual(store.json(), expected)
def post(self, name): if StoreModel.find_by_name(name): return {'message': 'a store with name already exists'} store = StoreModel(name) store.save_to_db() return store.json()
def test_create_store(self): store = StoreModel('test') self.assertEqual(store.name, 'test', "The name of the store after creation does not equal the constructor argument.")
def test_create_store(self): store = StoreModel('Test') self.assertEqual(store.name, 'Test')
def test_json(self): store = StoreModel("Test Store") expected = {"id": None, "name": "Test Store", "items": []} self.assertEqual(expected, store.json())
def test_create_store_with_no_item(self): store = StoreModel('test store') self.assertListEqual(store.items.all(), [])
def post(self, name): if StoreModel.find_by_name(name): return {"message": "store already exits"}, 400 store = StoreModel(name) store.save_to_db() return store.json()
def post(self, name): if StoreModel.find_store_by_name(name): return {'error': "A store with the name '{}' is already exists".format(name)}, 400 store = StoreModel(name) store.save_to_db() return store.json(), 201
def test_constructor(self): s = StoreModel('Test') self.assertEqual(s.name, 'Test')
def test_store_json_empty_item_list(self): store = StoreModel('test') expected = {'name': 'test', 'items': []} self.assertDictEqual(store.json(), expected)
def test_create_store(self): store = StoreModel('Test') self.assertEqual( store.name, 'Test', "The name of the store doesn't match the constructor argument.")
def test_create_store(self): store = StoreModel('test') self.assertListEqual( store.items.all(), [], "The store's items length was not 0 even though no items were added." )
def test_create_store_items_empty(self): store = StoreModel('test_store') self.assertListEqual( store.items.all(), [], "the newly create store should have no items, but has.")