Exemplo n.º 1
0
def order_dtos():
    order_dtos = [
        OrderDto(order_id=1,
                 user_id=1,
                 item_id=1,
                 brand_id=1,
                 form_id=1,
                 section_id=1,
                 count=10,
                 pending_count=0,
                 out_of_stock=0),
        OrderDto(order_id=2,
                 user_id=2,
                 item_id=2,
                 brand_id=2,
                 form_id=1,
                 section_id=2,
                 count=10,
                 pending_count=5,
                 out_of_stock=0),
        OrderDto(order_id=3,
                 user_id=2,
                 item_id=2,
                 brand_id=2,
                 form_id=2,
                 section_id=2,
                 count=5,
                 pending_count=5,
                 out_of_stock=5)

        ]
    return order_dtos
Exemplo n.º 2
0
def get_user_order_dtos():
    order_dtos = [
        OrderDto(order_id=1,
                 user_id=1,
                 item_id=1,
                 brand_id=1,
                 form_id=1,
                 section_id=1,
                 count=10,
                 pending_count=5,
                 out_of_stock=0),
        OrderDto(order_id=2,
                 user_id=1,
                 item_id=2,
                 brand_id=2,
                 form_id=1,
                 section_id=2,
                 count=2,
                 pending_count=0,
                 out_of_stock=0),
        OrderDto(order_id=3,
                 user_id=1,
                 item_id=3,
                 brand_id=3,
                 form_id=1,
                 section_id=2,
                 count=5,
                 pending_count=2,
                 out_of_stock=0)# i have doubt at out of stock 

        ]
    return order_dtos
Exemplo n.º 3
0
def test_get_user_brand_dtos_wit_valid_detailsreturn_dtos(create_users,
                                                          create_brands,
                                                          create_items,
                                                          create_orders,
                                                          create_sections,
                                                          create_forms):

    # Arrange
    user_id = 1
    order1 = OrderDto(
        order_id=1,
        user_id=1,
        item_id=1,
        brand_id=1,
        form_id=1,
        section_id= 1,
        count=10,
        pending_count=5,
        out_of_stock=0)
    order2 = OrderDto(
        order_id=2,
        user_id=1,
        item_id=2,
        brand_id=2,
        form_id=2,
        section_id= 1,
        count=10,
        pending_count=5,
        out_of_stock=0)

    brand1 = BrandDto(brand_id=1,
                     name="brand1",
                     min_quantity=1,
                     max_quantity=5,
                     price_per_item=100)
    brand2= BrandDto(brand_id=2,
                     name="brand2",
                     min_quantity=2,
                     max_quantity=8,
                     price_per_item=200)
    
    order_dtos = [order1, order2]
    
    expected_list = [brand1, brand2]

    storage = FormStorageImplementation()

    # Act
    actual_list = storage.get_user_brand_dtos(order_dtos)

    # Assert
    assert actual_list == expected_list
Exemplo n.º 4
0
def test_get_order_dtos_with_valid_details_return_dtos(
        create_users, create_brands, create_items, create_orders,
        create_sections, create_forms):

    # Arrange
    user_id = 1
    form_id = 1

    expected_order_dtos = [
        OrderDto(order_id=1,
                 user_id=1,
                 item_id=1,
                 brand_id=1,
                 form_id=1,
                 section_id=1,
                 count=10,
                 pending_count=5,
                 out_of_stock=0)
    ]

    storage = FormStorageImplementation()

    # Act
    actual_order_dtos = storage.get_order_dtos(user_id=user_id,
                                               form_id=form_id)

    # Assert
    assert actual_order_dtos == expected_order_dtos
Exemplo n.º 5
0
    def _convert_order_objs_to_dtos(self, order_objs) -> List[OrderDto]:
        order_dtos_list = []

        for order in order_objs:
            dto = OrderDto(order_id=order.id,
                           user_id=order.user_id,
                           item_id=order.item_id,
                           brand_id=order.brand_id,
                           form_id=order.form_id,
                           section_id=order.section_id,
                           count=order.count,
                           pending_count=order.pending_count,
                           out_of_stock=order.out_of_stock)
            order_dtos_list.append(dto)
        return order_dtos_list
Exemplo n.º 6
0
def test_get_user_item_dtos_with_valid_details_return_dtos(
        create_users, create_brands, create_items, create_orders,
        create_sections, create_forms):

    # Arrange
    order1 = OrderDto(order_id=1,
                      user_id=1,
                      item_id=1,
                      brand_id=1,
                      form_id=1,
                      section_id=1,
                      count=10,
                      pending_count=5,
                      out_of_stock=0)
    order2 = OrderDto(order_id=2,
                      user_id=1,
                      item_id=2,
                      brand_id=2,
                      form_id=2,
                      section_id=1,
                      count=10,
                      pending_count=5,
                      out_of_stock=0)

    item1 = ItemDto(item_id=1, name="item1", description="item1")
    item2 = ItemDto(item_id=2, name="item2", description="item2")

    order_dtos = [order1, order2]
    expected_list = [item1, item2]
    storage = FormStorageImplementation()

    # Act
    actual_list = storage.get_user_item_dtos(order_dtos)

    # Assert
    assert actual_list == expected_list
Exemplo n.º 7
0
    create_users,
    create_sections,
    add_multiple_items_to_section,
    add_multiple_sections_to_form,
    adding_brands_to_items)

    return data




order1 = OrderDto(
        order_id=1,
        user_id=1,
        item_id=1,
        brand_id=1,
        form_id=1,
        section_id= 1,
        count=10,
        pending_count=5,
        out_of_stock=0)
order2 = OrderDto(
        order_id=1,
        user_id=1,
        item_id=2,
        brand_id=2,
        form_id=2,
        section_id= 1,
        count=10,
        pending_count=5,
        out_of_stock=0)