Exemplo n.º 1
0
def test_swap_newest_by_category():
    item_a = Decor(age=2)
    item_b = Electronics(age=1)
    item_c = Decor(age=1)
    tai = Vendor(
        inventory=[item_a, item_b, item_c]
    )

    item_d = Clothing(age=2)
    item_e = Decor(age=3)
    item_f = Clothing(age=1)
    jesse = Vendor(
        inventory=[item_d, item_e, item_f]
    )

    result = tai.swap_newest_by_category(
        other=jesse,
        my_priority="Clothing",
        their_priority="Decor"
    )

    assert result
    assert len(tai.inventory) == 3
    assert len(jesse.inventory) == 3
    assert item_a in tai.inventory
    assert item_b in tai.inventory
    assert item_c not in tai.inventory
    assert item_f in tai.inventory
    assert item_d in jesse.inventory
    assert item_e in jesse.inventory
    assert item_f not in jesse.inventory
    assert item_c in jesse.inventory
Exemplo n.º 2
0
def test_swap_newest_by_category():
    item_a = Decor(age=41)
    item_b = Electronics(age=32)
    item_c = Decor(age=28)
    tanae = Vendor(
        inventory=[item_a, item_b, item_c]
    )

    item_d = Clothing(age=48)
    item_e = Decor(age=17)
    item_f = Clothing(age=23)
    jenda = Vendor(
        inventory=[item_d, item_e, item_f]
    )

    result = tanae.swap_newest_by_category(
        other=jenda,
        my_priority="Clothing",
        their_priority="Decor"
    )

    assert result is True
    assert len(tanae.inventory) is 3
    assert len(jenda.inventory) is 3
    assert item_c not in tanae.inventory
    assert item_f in tanae.inventory
    assert item_f not in jenda.inventory
    assert item_c in jenda.inventory
Exemplo n.º 3
0
def test_swap_by_newest():
    item_a = Decor(age="Vintage")
    item_b = Electronics(age="New")
    item_c = Decor(age="New")
    tai = Vendor(
        inventory=[item_a, item_b, item_c]
    )

    item_d = Clothing(age="Vintage")
    item_e = Decor(age="New")
    item_f = Clothing(age="New")
    jesse = Vendor(
        inventory=[item_d, item_e, item_f]
    )

    result = tai.swap_by_newest(
        other=jesse,
        my_priority="Clothing",
        their_priority="Decor"
    )

    assert result is True
    assert len(tai.inventory) == 3
    assert len(jesse.inventory) == 3
    assert item_c not in tai.inventory
    assert item_f in tai.inventory
    assert item_f not in jesse.inventory
    assert item_c in jesse.inventory
Exemplo n.º 4
0
def test_swap_best_by_category():
    item_a = Decor(condition=2.0)
    item_b = Electronics(condition=4.0)
    item_c = Decor(condition=4.0)
    tai = Vendor(
        inventory=[item_a, item_b, item_c]
    )

    item_d = Clothing(condition=2.0)
    item_e = Decor(condition=4.0)
    item_f = Clothing(condition=4.0)
    jesse = Vendor(
        inventory=[item_d, item_e, item_f]
    )

    result = tai.swap_best_by_category(
        other=jesse,
        my_priority="Clothing",
        their_priority="Decor"
    )

    assert result is True
    assert len(tai.inventory) is 3
    assert len(jesse.inventory) is 3
    assert item_c not in tai.inventory
    assert item_f in tai.inventory
    assert item_f not in jesse.inventory
    assert item_c in jesse.inventory
Exemplo n.º 5
0
def test_swap_newest_by_category_no_other_match_is_false():
    item_a = Decor()
    item_b = Electronics()
    item_c = Decor()
    tai = Vendor(
        inventory=[item_c, item_b, item_a]
    )

    item_d = Clothing()
    item_e = Decor()
    item_f = Clothing()
    jesse = Vendor(
        inventory=[item_f, item_e, item_d]
    )

    result = tai.swap_newest_by_category(
        other=jesse,
        my_priority="Electronics",
        their_priority="Decor"
    )

    assert not result
    assert len(tai.inventory) == 3
    assert len(jesse.inventory) == 3
    assert item_a in tai.inventory
    assert item_b in tai.inventory
    assert item_c in tai.inventory
    assert item_d in jesse.inventory
    assert item_e in jesse.inventory
    assert item_f in jesse.inventory
Exemplo n.º 6
0
def test_swap_by_newest_return_true():
    item_a = Electronics(condition=3.5, age=7.0)
    item_b = Item(condition=3.5, age=5.0)
    item_c = Decor(condition=3.5, age=2.0)

    jesse = Vendor(
        inventory=[item_a, item_b, item_c]
        )
        
    item_d = Item(condition=3.5, age=7.0)
    item_e = Decor(condition=3.5, age=3.0)
    item_f = Clothing(condition=3.5, age=9.0)

    mai = Vendor(
        inventory=[item_d, item_e, item_f]
    )

    result = jesse.swap_by_newest(mai)

    assert result is True
    assert len(mai.inventory) is 3
    assert len(jesse.inventory) is 3
    assert item_c not in jesse.inventory
    assert item_a in jesse.inventory
    assert item_e not in mai.inventory
    assert item_f in mai.inventory
Exemplo n.º 7
0
def test_swap_best_by_category_reordered():
    item_a = Decor(condition=2.0)
    item_b = Electronics(condition=4.0)
    item_c = Decor(condition=4.0)
    tai = Vendor(inventory=[item_c, item_b, item_a])

    item_d = Clothing(condition=2.0)
    item_e = Decor(condition=4.0)
    item_f = Clothing(condition=4.0)
    jesse = Vendor(inventory=[item_f, item_e, item_d])

    result = tai.swap_best_by_category(other=jesse,
                                       my_priority="Clothing",
                                       their_priority="Decor")

    assert result
    assert len(tai.inventory) == 3
    assert len(jesse.inventory) == 3
    assert item_a in tai.inventory
    assert item_b in tai.inventory
    assert item_c not in tai.inventory
    assert item_f in tai.inventory
    assert item_d in jesse.inventory
    assert item_e in jesse.inventory
    assert item_f not in jesse.inventory
    assert item_c in jesse.inventory
Exemplo n.º 8
0
def test_best_by_category_no_matches_is_none():
    item_a = Decor(condition=2.0)
    item_b = Decor(condition=2.0)
    item_c = Decor(condition=4.0)
    tai = Vendor(inventory=[item_a, item_b, item_c])

    best_item = tai.get_best_by_category("Electronics")

    assert best_item is None
Exemplo n.º 9
0
def test_newest_by_category_no_matches_is_none():
    item_a = Decor(age=2.0)
    item_b = Decor(age=2.0)
    item_c = Decor(age=4.0)
    tai = Vendor(inventory=[item_a, item_b, item_c])

    newest_item = tai.get_newest_by_category("Electronics")

    assert newest_item is None
Exemplo n.º 10
0
def test_get_min_age():
    item_a = Clothing(age = 1)
    item_b = Clothing(age = 4)
    item_c = Decor(age = 2)
    item_d = Decor(age = 3.5)
    tai = Vendor(inventory = [item_a,item_b,item_c, item_d])
    newest_item = tai.get_min_age()
    
    assert newest_item.age == 1
Exemplo n.º 11
0
def test_get_newest():
    item_a = Clothing(age=0)
    item_b = Decor(age=5)
    item_c = Clothing(age=6)
    item_d = Decor(age=2)
    sal = Vendor(inventory=[item_a, item_b, item_c, item_d])

    newest_item = sal.get_newest()

    assert newest_item.category == "Clothing"
    assert newest_item.age == 0
Exemplo n.º 12
0
def test_newest_by_category_no_matches_is_none():
    item_a = Decor(age=67)
    item_b = Decor(age=27)
    item_c = Decor(age=8)
    clara = Vendor(
        inventory=[item_a, item_b, item_c]
    )

    best_item = clara.get_newest_by_category("Electronics")

    assert best_item is None
def test_best_by_edge_no_matches_is_none():
    item_a = Electronics(edge=1.0)
    item_b = Decor(edge=2.0)
    item_c = Electronics(edge=4.0)
    item_d = Decor(edge=5.0)
    item_e = Electronics(edge=3.0)
    mary = Vendor(inventory=[item_a, item_b, item_c, item_d, item_e])

    newest_item = mary.get_best_by_edge("Clothing")

    assert newest_item is None
Exemplo n.º 14
0
def test_find_newest_item():
    item_a = Clothing(condition=4, age=datetime.datetime(2021, 2, 1))
    item_b = Decor(condition=4, age=datetime.datetime(2021, 3, 1))
    item_c = Clothing(condition=4, age=datetime.datetime(2021, 4, 1))
    item_d = Decor(condition=4, age=datetime.datetime(2021, 5, 1))
    item_e = Clothing(condition=4, age=datetime.datetime(2021, 6, 1))
    tai = Vendor(inventory=[item_a, item_b, item_c, item_d, item_e])

    newest_item = tai.find_newest_item()

    assert newest_item == item_e
Exemplo n.º 15
0
def test_get_newest():
    item_a = Clothing(age=2)
    item_b = Decor(age=14)
    item_c = Clothing(age=20)
    item_d = Decor(age=5)
    item_e = Clothing(age=85)
    tai = Vendor(inventory=[item_a, item_b, item_c, item_d, item_e])

    best_item = tai.get_newest()

    assert best_item.age == 2
Exemplo n.º 16
0
def test_best_by_category():
    item_a = Clothing(condition=2.0)
    item_b = Decor(condition=2.0)
    item_c = Clothing(condition=4.0)
    item_d = Decor(condition=5.0)
    item_e = Clothing(condition=3.0)
    tai = Vendor(inventory=[item_a, item_b, item_c, item_d, item_e])

    best_item = tai.get_best_by_category("Clothing")

    assert best_item.category == "Clothing"
    assert best_item.condition == pytest.approx(4.0)
Exemplo n.º 17
0
def test_get_by_newest():
    item_a = Clothing(age=2)
    item_b = Decor(age=2)
    item_c = Clothing(age=4)
    item_d = Decor(age=5)
    item_e = Clothing(age=1)
    tai = Vendor(inventory=[item_a, item_b, item_c, item_d, item_e])

    newest_item = tai.get_by_newest()

    # get_by_newest(self, friend)
    assert newest_item == item_e
def test_best_by_edge():
    item_a = Electronics(edge=1.0)
    item_b = Decor(edge=2.0)
    item_c = Electronics(edge=4.0)
    item_d = Decor(edge=5.0)
    item_e = Electronics(edge=3.0)
    mary = Vendor(inventory=[item_a, item_b, item_c, item_d, item_e])

    newest_item = mary.get_best_by_edge("Electronics")

    assert newest_item.category == "Electronics"
    assert newest_item.edge == pytest.approx(1.0)
Exemplo n.º 19
0
def test_get_newest():
    item_a = Clothing(age=2)
    item_b = Decor(age=3)
    item_c = Clothing(age=4)
    item_d = Decor(age=5)
    item_e = Clothing(age=3)
    tai = Vendor(inventory=[item_a, item_b, item_c, item_d, item_e])

    newest_item = tai.get_newest()

    assert newest_item.category == "Clothing"
    assert newest_item.age == pytest.approx(2)
Exemplo n.º 20
0
def test_newest_by_category():
    item_a = Clothing(age=2.0)
    item_b = Decor(age=3.0)
    item_c = Clothing(age=1.0)
    item_d = Decor(age=5.0)
    item_e = Clothing(age=3.0)
    tai = Vendor(inventory=[item_a, item_b, item_c, item_d, item_e])

    newest_item = tai.get_newest_by_category("Clothing")

    assert newest_item.category == "Clothing"
    assert newest_item.age == pytest.approx(1.0)
Exemplo n.º 21
0
def test_get_newest_returns_youngest():
    item_a = Clothing(age=6)
    item_b = Decor(age=2)
    item_c = Clothing(age=1)
    item_d = Decor(age=10)
    item_e = Clothing(age=3)
    tai = Vendor(inventory=[item_a, item_b, item_c, item_d, item_e])

    newest_item = tai.get_newest()

    assert newest_item == item_c
    assert newest_item.age == 1
Exemplo n.º 22
0
def test_newest_by_category():
    item_a = Clothing(age=17)
    item_b = Decor(age=23)
    item_c = Clothing(age=45)
    item_d = Decor(age=56)
    item_e = Clothing(age=37)
    clara = Vendor(
        inventory=[item_a, item_b, item_c, item_d, item_e]
    )

    best_item = clara.get_newest_by_category("Clothing")

    assert best_item.category == "Clothing"
    assert best_item.age == pytest.approx(17)
def test_get_newest_by_category():
    item_a = Clothing(condition=None, age=2)
    item_b = Decor(condition=None, age=2)
    item_c = Clothing(condition=None, age=4)
    item_d = Decor(condition=None, age=5)
    item_e = Clothing(condition=None, age=3)
    tai = Vendor(
        inventory=[item_a, item_b, item_c, item_d, item_e]
    )

    best_item = tai.get_newest_by_category("Clothing")

    assert best_item.category == "Clothing"
    assert best_item.age == 4
Exemplo n.º 24
0
def test_swap_by_newest_no_matches_is_none():
    item_a = Decor(age=2.0)
    item_b = Decor(age=1.0)
    item_c = Decor(age=4.0)
    item_d = Decor(age=8.0)

    tai = Vendor(inventory=[item_a, item_b, item_c])
    ta = Vendor(inventory=[item_d])
    is_swap = tai.swap_by_newest(ta)

    assert is_swap is not False
    assert item_d in tai.inventory
    assert item_b in ta.inventory
    assert item_a not in ta.inventory
def test_items_have_condition_descriptions_that_are_the_same_regardless_of_type(
):
    # arrange
    items = [
        Clothing(condition=5),
        Decor(condition=5),
        Electronics(condition=5)
    ]
    # act
    five_condition_description = items[0].condition_description()

    # assert
    assert type(five_condition_description) == str

    for item in items:
        assert item.condition_description() == five_condition_description

    items[0].condition = 1
    one_condition_description = items[0].condition_description()
    assert type(one_condition_description) == str

    for item in items:
        item.condition = 1
        assert item.condition_description() == one_condition_description

    assert one_condition_description != five_condition_description
Exemplo n.º 26
0
def test_swap_by_newest_empty_other_inventory():
    item_a = Decor(year=2001)
    item_b = Electronics(year=1937)
    item_c = Decor(year=2016)
    madison = Vendor(inventory=[item_a, item_b, item_c])

    jesse = Vendor(inventory=[])

    result = madison.swap_by_newest(other_vendor=jesse, )

    assert result is False
    assert len(madison.inventory) is 3
    assert len(jesse.inventory) is 0
    assert item_a in madison.inventory
    assert item_b in madison.inventory
    assert item_c in madison.inventory
Exemplo n.º 27
0
def test_get_newest_by_category():
    item_a = Clothing(age=0)
    item_b = Decor(age=2)
    item_c = Clothing(age=3)
    item_d = Decor(age=1)
    item_e = Clothing(age=2)
    tai = Vendor(
        inventory=[item_a, item_b, item_c, item_d, item_e]
    )

    newest_clothing_item = tai.get_newest_by_category("Clothing")
    newest_decor_item = tai.get_newest_by_category("Decor")

    assert newest_clothing_item.category == "Clothing"
    assert newest_clothing_item.age == pytest.approx(0.0)
    assert newest_decor_item.category == "Decor"
    assert newest_decor_item.age == pytest.approx(1.0)
Exemplo n.º 28
0
def test_items_have_condition_as_float():
    items = [
        Clothing(condition=3.5),
        Decor(condition=3.5),
        Electronics(condition=3.5)
    ]
    for item in items:
        assert item.condition == pytest.approx(3.5)
Exemplo n.º 29
0
def test_swap_by_newest_does_not_change_anything_if_vendor_has_no_inventory():
    item_a = Clothing(condition=4, age=datetime.datetime(2021, 2, 1))
    item_b = Decor(condition=4, age=datetime.datetime(2021, 3, 1))
    item_c = Clothing(condition=4, age=datetime.datetime(2021, 4, 1))
    item_d = Decor(condition=4, age=datetime.datetime(2021, 5, 1))
    item_e = Clothing(condition=4, age=datetime.datetime(2021, 6, 1))
    tai = Vendor(inventory=[item_a, item_b, item_c, item_d, item_e])
    other_vendor = Vendor(inventory=[])

    tai.swap_by_newest(other_vendor)

    assert item_a in tai.inventory
    assert item_b in tai.inventory
    assert item_c in tai.inventory
    assert item_d in tai.inventory
    assert item_e in tai.inventory
    assert len(other_vendor.inventory) == 0
Exemplo n.º 30
0
def test_items_have_expected_default_age():
    item = Item()
    clothing = Clothing()
    decor = Decor()
    electronics = Electronics()
    assert item.age == Item.DEFAULT_ITEM_AGE 
    assert clothing.age == Item.DEFAULT_ITEM_AGE 
    assert decor.age == Item.DEFAULT_ITEM_AGE 
    assert electronics.age == Item.DEFAULT_ITEM_AGE