def setUp(self) -> None:
        self.user1 = ep.users_create().json()
        self.user2 = ep.users_create().json()
        ep.users_credit_add(self.user1['user_id'], 100)
        self.item1 = ep.stock_create(20).json()
        ep.stock_add(self.item1["item_id"], 3)
        self.item2 = ep.stock_create(10).json()
        ep.stock_add(self.item2["item_id"], 3)
        self.order1 = ep.orders_create(self.user1['user_id']).json()
        self.order2 = ep.orders_create(self.user2['user_id']).json()
        self.order3 = ep.orders_create(self.user2['user_id']).json()

        # First order will have item 1 two times and item 2 once, total price is 50
        ep.orders_add_item(self.order1['order_id'], self.item1['item_id'])
        ep.orders_add_item(self.order1['order_id'], self.item1['item_id'])
        ep.orders_add_item(self.order1['order_id'], self.item2['item_id'])

        # Order 2 has total price of 20
        ep.orders_add_item(self.order2['order_id'], self.item1['item_id'])
示例#2
0
 def setUp(self) -> None:
     self.price = uniform(0, 100)
     self.item_id = ep.stock_create(self.price).json()['item_id']
     self.res = ep.stock_find(self.item_id)
     self.stock_item = self.res.json()
     self.old_amount = self.stock_item['stock']
     self.rand_int_pos = randint(0, 100)
     self.rand_int_neg = randint(-100, -1)
     self.rand_float_pos = uniform(0, 100)
     self.rand_float_neg = uniform(-100, -1)
示例#3
0
    def test_stock_create(self):
        price = uniform(0, 100)
        res = ep.stock_create(price)
        item_id = res.json()['item_id']
        try:
            uuid_obj = UUID(item_id, version=4)
        except ValueError:
            return False

        self.assertTrue(res.ok)
        self.assertEqual(str(uuid_obj), item_id)
    def setUp(self) -> None:
        self.user1 = ep.users_create().json()
        self.user2 = ep.users_create().json()
        self.order1 = ep.orders_create(self.user1['user_id']).json()
        self.order2 = ep.orders_create(self.user2['user_id']).json()

        self.price = uniform(0, 100)
        self.balance_sufficient = self.price
        self.balance_insufficient = uniform(0, self.price - 1.0)

        self.item1 = ep.stock_create(self.price).json()
        ep.users_credit_add(self.user1['user_id'], self.balance_sufficient)
        ep.users_credit_add(self.user2['user_id'], self.balance_insufficient)

        ep.orders_add_item(self.order1['order_id'], self.item1['item_id'])
        ep.orders_add_item(self.order2['order_id'], self.item1['item_id'])
示例#5
0
 def setUp(self):
     self.item_id = ep.stock_create(5.5).json()['item_id']
     self.item_id2 = ep.stock_create(1).json()['item_id']
     self.user_id = ep.users_create().json()['user_id']
     self.order_id = ep.orders_create(self.user_id).json()['order_id']