Ejemplo n.º 1
0
def test_swap_items_from_my_empty_returns_false():
    fatimah = Vendor(inventory=[])

    item_d = Item(category="electronics")
    item_e = Item(category="decor")

    jolie = Vendor(inventory=[item_d, item_e])

    nobodys_item = Item(category="clothing")

    result = fatimah.swap_items(jolie, nobodys_item, item_d)

    assert len(fatimah.inventory) is 0
    assert len(jolie.inventory) is 2
    assert result is False
Ejemplo n.º 2
0
def test_swap_items_from_their_empty_returns_false():
    item_a = Item(category="clothing")
    item_b = Item(category="clothing")
    item_c = Item(category="clothing")
    fatimah = Vendor(inventory=[item_a, item_b, item_c])

    jolie = Vendor(inventory=[])

    nobodys_item = Item(category="clothing")

    result = fatimah.swap_items(jolie, item_b, nobodys_item)

    assert len(fatimah.inventory) is 3
    assert len(jolie.inventory) is 0
    assert result is False
Ejemplo n.º 3
0
def test_swap_by_newest_from_their_empty_returns_false():
    item_a = Item(age=3)
    item_b = Item(age=1)
    item_c = Item(age=2)
    fatimah = Vendor(inventory=[item_a, item_b, item_c])

    jolie = Vendor(inventory=[])

    nobodys_item = Item(age=3)

    result = fatimah.swap_by_newest(jolie, item_b, nobodys_item)

    assert len(fatimah.inventory) is 3
    assert len(jolie.inventory) is 0
    assert result is False
Ejemplo n.º 4
0
def test_swap_by_newest_from_my_empty_returns_false():
    fatimah = Vendor(inventory=[])

    item_d = Item(age=4)
    item_e = Item(age=5)
    item_f = Item(age=2)
    jolie = Vendor(inventory=[item_d, item_e, item_f])

    nobodys_item = Item(age=3)

    result = fatimah.swap_by_newest(jolie, nobodys_item, item_f)

    assert len(fatimah.inventory) is 0
    assert len(jolie.inventory) is 3
    assert result is False
Ejemplo n.º 5
0
def test_swap_first_item_from_my_empty_returns_false():
    fatimah = Vendor(
        inventory=[]
    )

    item_d = Item(category="electronics")
    item_e = Item(category="decor")
    jolie = Vendor(
        inventory=[item_d, item_e]
    )

    result = fatimah.swap_first_item(jolie)

    assert len(fatimah.inventory) is 0
    assert len(jolie.inventory) is 2
    assert result is False
def test_item_overrides_to_string():
    # arrange
    item = Item()  # item = ""
    # act
    stringified_item = str(item)
    # assert
    assert stringified_item == "Hello World!"
Ejemplo n.º 7
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 
Ejemplo n.º 8
0
 def __init__(
     self,
     inventory=[]
 ):  # if the vendor has a list use it, if not, use the default empty list
     # if not inventory: # take optional inventory by checking if the inventory is valid, (has a list of things)
     #     # self.inventory = [] # create list
     # else:
     self.inventory = inventory
     self.item = Item()
Ejemplo n.º 9
0
def test_items_can_be_assigned_age():
    item = Item(age = 1)
    clothing = Clothing(age = 1)
    decor = Decor(age = 1)
    electronics = Electronics(age = 1)
    assert item.age == 1 
    assert clothing.age == 1
    assert decor.age == 1
    assert electronics.age == 1
Ejemplo n.º 10
0
def test_swap_items_when_their_item_is_missing_returns_false():
    item_a = Item(category="clothing")
    item_b = Item(category="clothing")
    item_c = Item(category="clothing")
    fatimah = Vendor(inventory=[item_a, item_b, item_c])

    item_d = Item(category="electronics")
    item_e = Item(category="decor")
    jolie = Vendor(inventory=[item_d, item_e])

    result = fatimah.swap_items(jolie, item_b, item_c)

    assert len(fatimah.inventory) is 3
    assert item_d not in fatimah.inventory
    assert item_a in fatimah.inventory
    assert item_b in fatimah.inventory
    assert item_c in fatimah.inventory
    assert len(jolie.inventory) is 2
    assert item_d in jolie.inventory
    assert item_e in jolie.inventory
    assert result is False
Ejemplo n.º 11
0
def test_swap_first_item_returns_true():
    item_a = Item(category="clothing")
    item_b = Item(category="clothing")
    item_c = Item(category="clothing")
    fatimah = Vendor(inventory=[item_a, item_b, item_c])

    item_d = Item(category="electronics")
    item_e = Item(category="decor")
    jolie = Vendor(inventory=[item_d, item_e])

    result = fatimah.swap_first_item(jolie)

    assert len(fatimah.inventory) == 3
    assert item_a not in fatimah.inventory
    assert item_b in fatimah.inventory
    assert item_c in fatimah.inventory
    assert item_d in fatimah.inventory
    assert len(jolie.inventory) == 2
    assert item_d not in jolie.inventory
    assert item_e in jolie.inventory
    assert item_a in jolie.inventory
    assert result
Ejemplo n.º 12
0
def test_swap_by_newest_returns_true():
    item_a = Item(age=1)
    item_b = Item(age=2)
    item_c = Item(age=3)
    fatimah = Vendor(inventory=[item_a, item_b, item_c])

    item_d = Item(age=1)
    item_e = Item(age=5)
    jolie = Vendor(inventory=[item_d, item_e])

    result = fatimah.swap_by_newest(jolie)

    assert len(fatimah.inventory) is 3
    assert item_a not in fatimah.inventory
    assert item_b in fatimah.inventory
    assert item_c in fatimah.inventory
    assert item_d in fatimah.inventory
    assert len(jolie.inventory) is 2
    assert item_d not in jolie.inventory
    assert item_e in jolie.inventory
    assert item_a in jolie.inventory
    assert result is True
Ejemplo n.º 13
0
def test_swap_first_item_returns_true():
    item_a = Item(category="clothing")
    item_b = Item(category="clothing")
    item_c = Item(category="clothing")
    fatimah = Vendor(inventory=[item_a, item_b, item_c])

    item_d = Item(category="electronics")
    item_e = Item(category="decor")
    jolie = Vendor(inventory=[item_d, item_e])

    result = fatimah.swap_first_item(jolie)

    assert len(
        fatimah.inventory) is 3  # so replace fatimah's first val w jolie's
    assert item_a not in fatimah.inventory
    assert item_b in fatimah.inventory
    assert item_c in fatimah.inventory
    assert item_d in fatimah.inventory
    assert len(jolie.inventory) is 2  # and vice versa
    assert item_d not in jolie.inventory
    assert item_e in jolie.inventory
    assert item_a in jolie.inventory
    assert result is True
Ejemplo n.º 14
0
def test_swap_items_returns_true(
):  # passing; shows that swap logic is working
    item_a = Item(category="clothing")
    item_b = Item(category="clothing")
    item_c = Item(category="clothing")
    fatimah = Vendor(inventory=[item_a, item_b, item_c])

    item_d = Item(category="electronics")
    item_e = Item(category="decor")
    jolie = Vendor(inventory=[item_d, item_e])

    result = fatimah.swap_items(jolie, item_b, item_d)

    assert len(fatimah.inventory) is 3
    assert item_b not in fatimah.inventory
    assert item_a in fatimah.inventory
    assert item_c in fatimah.inventory
    assert item_d in fatimah.inventory
    assert len(jolie.inventory) is 2
    assert item_d not in jolie.inventory
    assert item_e in jolie.inventory
    assert item_b in jolie.inventory
    assert result is True
Ejemplo n.º 15
0
def test_get_min_age():
    item_a = Decor(condition=3.5)
    item_b = Electronics(condition=3.5)
    item_c = Clothing(condition=3.5, age=9.0)
    item_d = Item(condition=3.5, age=1.0)
    item_e = Clothing(condition=3.5, age=6.0)

    kate = Vendor(
        inventory=[item_a, item_b, item_c, item_d, item_e]
    )

    result = kate.get_min_age()

    assert result.category == "Electronics"
    assert result.age == pytest.approx(0.0)
Ejemplo n.º 16
0
def test_swap_by_newest():
    item_a = Item(age=3)
    item_b = Item(age=1)
    item_c = Item(age=2)
    fatimah = Vendor(inventory=[item_a, item_b, item_c])

    item_d = Item(age=4)
    item_e = Item(age=5)
    item_f = Item(age=2)
    jolie = Vendor(inventory=[item_d, item_e, item_f])

    result = fatimah.swap_by_newest(business_partner=jolie,
                                    my_newest_item=item_b,
                                    their_newest_item=item_f)

    assert result is True
    assert len(fatimah.inventory) is 3
    assert len(jolie.inventory) is 3
    assert item_b not in fatimah.inventory
    assert item_f in fatimah.inventory
    assert item_f not in jolie.inventory
    assert item_b in jolie.inventory
Ejemplo n.º 17
0
 def __init__(self, condition=0, age=1):
     Item.__init__(self, condition, age, "Electronics")
Ejemplo n.º 18
0
 def __init__(self, condition=0, age=1):
     Item.__init__(self, condition, age, "Decor")
Ejemplo n.º 19
0
def test_item_overrides_to_string(
):  # passing; shows that item overrides string
    item = Item()
    stringified_item = str(item)
    assert stringified_item == "Hello World!"
Ejemplo n.º 20
0
 def __init__(self, condition=0, age=1):
     Item.__init__(self, condition, age, "Clothing")
Ejemplo n.º 21
0
import pytest
from swap_meet.vendor import Vendor
from swap_meet.item import Item


item_a = Item(category="clothing")
item_b = Item(category="electronics")
item_c = Item(category="clothing")
vendor = Vendor(
    inventory=[item_a, item_b, item_c]
)

items = vendor.get_by_category("clothing")
Ejemplo n.º 22
0
 def __init__(self, inventory=[]):
     self.inventory = inventory
     self.item = Item()
Ejemplo n.º 23
0
# item_d = Item(category="electronics")
# item_e = Item(category="decor")
# jolie = Vendor(
#     inventory=[item_d, item_e]
# )

#result = fatimah.swap_items(jolie, item_a, item_d)

# print(result)
#print(jolie.inventory)
# print(vars(jolie.inventory[0])) # prints out {'category': 'decor'}


### wave 4 ### 

item_a = Item(category="clothing")
item_b = Item(category="clothing")
item_c = Item(category="clothing")
fatimah = Vendor(
    inventory=[item_a, item_b, item_c]
)

item_d = Item(category="electronics")
item_e = Item(category="decor")
jolie = Vendor(
    inventory=[item_d, item_e]
)

result = fatimah.swap_first_item(jolie)
print(result)
Ejemplo n.º 24
0
 def __init__(self, condition=0):
     Item.__init__(self, "Decor", condition)
Ejemplo n.º 25
0
 def __init__(self, condition=0):
     Item.__init__(self, "Clothing", condition)
Ejemplo n.º 26
0
def test_item_overrides_to_string():
    item = Item()

    stringified_item = str(item)

    assert stringified_item == "Hello World!"
Ejemplo n.º 27
0
 def __init__(self, condition=0):
     Item.__init__(self, "Electronics", condition)
def test_items_have_blank_default_category():
    item = Item()
    assert item.category == ""