Esempio n. 1
0
 def test_crud_create_read_delete(self):
     with self.app_context():
         itm = ItemModel("0001", "U00000000", "Details of an order")
         self.assertListEqual(
             ItemModel.find_by_order_uuid_and_user_id(order_uuid="1",
                                                      user_id="U00000000"),
             [])
         itm.save_to_db()
         self.assertEqual(
             len(
                 ItemModel.find_by_order_uuid_and_user_id(
                     order_uuid="1", user_id="U00000000")), 1)
         itm.delete_from_db()
         self.assertListEqual(
             ItemModel.find_by_order_uuid_and_user_id(order_uuid="1",
                                                      user_id="U00000000"),
             [])
Esempio n. 2
0
 def test_crud_create_read_delete_multi(self):
     with self.app_context():
         itm = ItemModel("2", "U00000001", "Details of an order 😂")
         self.assertListEqual(
             ItemModel.find_by_order_uuid_and_user_id(order_uuid="2",
                                                      user_id="U00000001"),
             [])
         itm.save_to_db()
         self.assertEqual(
             len(
                 ItemModel.find_by_order_uuid_and_user_id(
                     order_uuid="2", user_id="U00000001")), 1)
         found_item = ItemModel.find_by_order_uuid_and_user_id(
             order_uuid="2", user_id="U00000001")[0]
         self.assertEqual(found_item.order_id, 2)
         self.assertEqual(found_item.user_id, "U00000001")
         self.assertEqual(found_item.details, "Details of an order 😂")
         itm.delete_from_db()
         self.assertListEqual(
             ItemModel.find_by_order_uuid_and_user_id(order_uuid="2",
                                                      user_id="U00000001"),
             [])