예제 #1
0
def fetch_all_pos(connection):
    cursor = connection.cursor()
    cursor.execute(queries.get_all_pos())
    pos = []
    for row in cursor.fetchall():
        pos.append(PurchaseOrder(row))
    return pos
예제 #2
0
    def test_should_buy_not_remove_the_product_in_the_store_if_there_are_not_enough_items(self):
        # Creating the mock object
        store:Store = mock()

        # Stubbing
        when(store).are_there_enough_products("Bread", 15).thenReturn(False)

        # Execute
        purchase_order:PurchaseOrder = PurchaseOrder("Bread", 15)
        purchase_order.buy(store)

        # Verify
        verify(store, times=0).remove_products("Bread", 15)
예제 #3
0
    def test_should_buy_remove_the_product_in_the_store_if_there_are_enough_items(
            self):
        # Creating the mock object
        store: Store = MagicMock()

        # Stubbing
        store.are_there_enough_products.return_value = True

        # Execute
        purchase_order: PurchaseOrder = PurchaseOrder("Bread", 15)
        purchase_order.buy(store)

        # Verify
        store.remove_products.assert_called_once_with("Bread", 15)
예제 #4
0
    def test_shouldBuyWorkIfThereAreProductsTheFirstTimeButNotTheSeconeOne(self):
        # Creating the mock object
        store:Store = mock()

        # Stubbing
        when(store).are_there_enough_products("Bread", 15).thenReturn(True, False)

        # Execute
        purchase_order:PurchaseOrder = PurchaseOrder("Bread", 15)
        purchase_order.buy(store)
        purchase_order.buy(store)

        # Verify
        verify(store, times=2).are_there_enough_products("Bread", 15)
        verify(store, times=1).remove_products("Bread", 15)