示例#1
0
def get_form_brand_dtos():
    brand_dtos = [
        GetFormBrandDtoWithItemId(
            brand_id=1,
            name="HoneyBee",
            min_quantity=2,
            max_quantity=10,
            price_per_item=100,
            item_id=1),
        GetFormBrandDtoWithItemId(
            brand_id=2,
            name="KnockOut",
            min_quantity=2,
            max_quantity=11,
            price_per_item=200,
            item_id=1),
        GetFormBrandDtoWithItemId(
            brand_id=3,
            name="KingFisher",
            min_quantity=2,
            max_quantity=11,
            price_per_item=200,
            item_id=2)
        
        ]
    return brand_dtos
示例#2
0
def get_form_expected_form_details_dto():

    brand1= GetFormBrandDtoWithItemId(
            brand_id=1,
            name="HoneyBee",
            min_quantity=2,
            max_quantity=10,
            price_per_item=100,
            item_id=1)
    brand2 = GetFormBrandDtoWithItemId(
            brand_id=2,
            name="KnockOut",
            min_quantity=2,
            max_quantity=11,
            price_per_item=200,
            item_id=1)
    brand3 = GetFormBrandDtoWithItemId(
            brand_id=3,
            name="KingFisher",
            min_quantity=2,
            max_quantity=11,
            price_per_item=200,
            item_id=2)
        
    order1 = GetFormItemOrderDto(order_id=1,
                                 brand_id=1,
                                 ordered_count=10,
                                 out_of_stock=0)
    order2 = GetFormItemOrderDto(order_id=2,
                                 brand_id=3,
                                 ordered_count=10,
                                 out_of_stock=0)
    
    item1 = GetFormItemDto(item_id=1,
                           name="choco",
                           description="choco",
                           brands=[brand1, brand2],
                           order=order1)
    item2 = GetFormItemDto(item_id=2,
                           name="lace",
                           description="lace",
                           brands=[brand3],
                           order=order2)

    section1 = GetFormSectionDto(section_id=1,
                                 name="SECTION1",
                                 description="DESCRIP SECTION1",
                                 items=[item1, item2])

    section2 = GetFormSectionDto(section_id=2,
                                 name="SECTION2",
                                 description="DESCRIP SECTION2",
                                 items=[])
    
    get_form_dto = GetFormDto(form_id=1,
                              name="FORM1",
                              close_date=datetime.datetime(2020, 10, 10, 0, 0),
                              sections=[section1, section2])

    return get_form_dto
示例#3
0
def test_get_brand_dtos_with_valid_details_return_dtos(populate_data):

    # Arrange
    item_dtos = [
        GetFormItemDtoWithSectionId(
                item_id=1,
                name="item1",
                description="item1",
                section_id=1),
        GetFormItemDtoWithSectionId(
                item_id=2,
                name="item2",
                description="item2",
                section_id=1)]

    expected_brand_dtos = [
        GetFormBrandDtoWithItemId(
            brand_id=1,
            name="brand1",
            min_quantity=1,
            max_quantity=5,
            price_per_item=100,
            item_id=1),
        GetFormBrandDtoWithItemId(
            brand_id=2,
            name="brand2",
            min_quantity=2,
            max_quantity=8,
            price_per_item=200,
            item_id=1),
        GetFormBrandDtoWithItemId(
            brand_id=3,
            name="brand3",
            min_quantity=3,
            max_quantity=9,
            price_per_item=300,
            item_id=2)
    ]

    storage = FormStorageImplementation()

    # Act
    actual_brand_dtos = storage.get_brand_dtos(item_dtos=item_dtos)

    # Assert
    assert actual_brand_dtos == expected_brand_dtos
示例#4
0
    def _convert_brands_to_dtos(self, item_id, brand_objs):
        brand_dtos = []

        for brand in brand_objs:
            dto = GetFormBrandDtoWithItemId(
                brand_id=brand.id,
                name=brand.name,
                min_quantity=brand.min_quantity,
                max_quantity=brand.max_quantity,
                price_per_item=brand.price_per_item,
                item_id=item_id)
            brand_dtos.append(dto)
        return brand_dtos