Ejemplo n.º 1
0
 def testInventoryUpdate(self):
     """update_inventory should update magento inventory properly"""
     test_product_id = 16
     inventory_record = inventory.get_inventory('demo', [test_product_id])
     expected_quantity = float(inventory_record[0].qty) + 1
     inventory.update_inventory('demo', [{'cart_prod_id':test_product_id, 'qty':expected_quantity}])
     inventory_record = inventory.get_inventory('demo', [test_product_id])
     actual_quantity = float(inventory_record[0].qty)
     self.assertEqual(expected_quantity, actual_quantity)
Ejemplo n.º 2
0
    def testInventoryMassUpdateAsync(self):
        """update_inventory should properly mass-update magento inventory async"""
        # these products always fail the inventory update no matter what
        failing_product_ids = [54,83,98,103,119,120,123,126,158,163,164,165]

        test_product_ids = [16, 17, 18, 19, 20, 25, 26, 27, 28, 29, 31, 32, 34, 
            35, 36, 37, 38, 39, 41, 42, 44, 45, 46, 47, 48, 51, 52, 53, 
            84, 85, 86, 87, 88, 89, 90, 91, 92, 99, 100, 101, 102, 104, 
            105, 106, 107, 109, 110, 111, 117, 118, 121, 122, 124, 125, 
            127, 128, 129, 130, 131, 132, 133, 134, 137, 138, 139, 
            140, 141, 144, 145, 148, 149, 151, 152, 153, 154, 157, 
            159, 161, 162, 166, 167]
        inventory_updates = []
        inventory_expected_values = {}
            
        for product_id in test_product_ids:
            inventory_expected_values[product_id] = random.randint(1,1000)
            inventory_updates.append({'qty': inventory_expected_values[product_id], 'cart_prod_id': product_id})
        inventory.update_inventory('demo', inventory_updates, async=True)

        inventory_list = inventory.get_inventory('demo', test_product_ids)
        for inventory_record in inventory_list:
            expected_quantity = float(inventory_expected_values[ int(inventory_record.product_id) ])
            actual_quantity = float(inventory_record.qty)
            self.assertEqual(expected_quantity, actual_quantity, 
                'Got %s for product_id %s, expected %s' % 
                (actual_quantity, inventory_record.product_id, expected_quantity))
Ejemplo n.º 3
0
def get_lost_inventory_html():
    inv_df = pd.DataFrame(inventory.get_inventory('pd'))
    inv_df = inv_df[['IsLost', 'IsLostReason', 'name', 'model.name', 'IP_region_name', 'IP_city',
                     'DaysSinceCheckinBucket', 'DeviceValue']]
    inv_df = inv_df[inv_df['IsLost'] == 'True']
    return Response(inv_df.to_html()
                    )
Ejemplo n.º 4
0
    def test_successful_increment_wrap_ingredients(self, sys):
        name = "Pita"
        amount = 1

        inventory = get_inventory("wrapIngredients")
        for i in inventory:
            if i._name == name:
                amount_before = i._amount

        increment_wraps_ingredients(name, amount)

        inventory = get_inventory("wrapIngredients")
        for i in inventory:
            if i._name == name:
                amount_after = i._amount

        assert amount_after - amount_before == amount
Ejemplo n.º 5
0
    def test_successful_increment_burger_ingredients(self, sys):
        name = "English Muffin"
        amount = 1

        inventory = get_inventory("burgerIngredients")
        for i in inventory:
            if i._name == name:
                amount_before = i._amount

        increment_burger_ingredients(name, amount)

        inventory = get_inventory("burgerIngredients")
        for i in inventory:
            if i._name == name:
                amount_after = i._amount

        assert amount_after - amount_before == amount
Ejemplo n.º 6
0
    def test_successful_increment_drinks(self, sys):
        name = "Fanta Bottle"
        amount = 1

        inventory = get_inventory("drinks")
        for i in inventory:
            if i._name == name:
                amount_before = i._amount

        increment_drinks(name, amount)

        inventory = get_inventory("drinks")
        for i in inventory:
            if i._name == name:
                amount_after = i._amount

        assert amount_after - amount_before == amount
Ejemplo n.º 7
0
    def test_successful_increment_sides(self, sys):
        name = "Fries"
        amount = 1

        inventory = get_inventory("sides")
        for i in inventory:
            if i._name == name:
                amount_before = i._amount

        increment_sides(name, amount)

        inventory = get_inventory("sides")
        for i in inventory:
            if i._name == name:
                amount_after = i._amount

        assert amount_after - amount_before == amount
Ejemplo n.º 8
0
 def __init__(self):
     self.inventory = get_inventory()
     self.x = world.start_tile_location[0]
     self.y = world.start_tile_location[1]
     self.hp = 100
     self.gold = 100
     self.victory = False
     self.defence = 1
     self.mana = 100
Ejemplo n.º 9
0
    def test_unsuccessful_increment_drinks(self, sys):
        name = "Durian"
        amount = 1
        amount_before = None
        amount_after = None

        inventory = get_inventory("drinks")
        for i in inventory:
            if i._name == name:
                amount_before = i._amount

        increment_wraps_ingredients(name, amount)

        inventory = get_inventory("drinks")
        for i in inventory:
            if i._name == name:
                amount_after = i._amount

        assert amount_after == None
        assert amount_before == None
Ejemplo n.º 10
0
def side_inventory():
    return render_template('side_inventory.html',inventory = get_inventory("sides"))
Ejemplo n.º 11
0
def burger_inventory():
    return render_template('burger_inventory.html',inventory = get_inventory("burgerIngredients"))
Ejemplo n.º 12
0
def wrap_inventory():
    return render_template('wrap_inventory.html',inventory = get_inventory("wrapIngredients"))
Ejemplo n.º 13
0
def drink():
    return render_template('drink.html',drink_list = get_inventory("drinks"))
Ejemplo n.º 14
0
def main_inventory():
    return render_template('main_inventory.html',inventory1 = get_inventory("Ingredients"),
                                                inventory2 = get_inventory("Ingredients1"))
Ejemplo n.º 15
0
def new_wrap():
    return render_template('wrap.html',ingredient_list = get_inventory('Ingredients'),
                            ingredient_list2 = get_inventory('Ingredients1'),
                            ingredient_list3 = get_inventory('wrapIngredients'))
Ejemplo n.º 16
0
def side():
    return render_template('side.html',side_list = get_inventory("sides"))
Ejemplo n.º 17
0
def new_burger():
    return render_template('burger.html',ingredient_list = get_inventory('Ingredients'),
                            ingredient_list2 = get_inventory('Ingredients1'),
                            ingredient_list3 = get_inventory('burgerIngredients'))
Ejemplo n.º 18
0
def drink_inventory():
    return render_template('drink_inventory.html',inventory = get_inventory("drinks"))
Ejemplo n.º 19
0
def get_jamf_inventory_html():
    return Response(
        inventory.get_inventory('html')
    )
Ejemplo n.º 20
0
def fight_norman():
    global firsttime
    global your_hp
    global norm_health
    if firsttime == 0:
        firsttime += 1
        your_hp = 15
        norm_health = 20
    inventory.get_inventory()
    if inventory.held_item == "Fists":
        your_atk = random.randint(1, 2)
    elif inventory.held_item == "Gun":
        your_atk = random.randint(10, 15)
    elif inventory.held_item == "Crowbar":
        your_atk = random.randint(2, 4)
    elif inventory.held_item == "Starting pistol":
        your_atk = random.randrange(1, 9, 2)
    elif inventory.held_item == "Rusty Knife":
        your_atk = 0
    elif inventory.held_item == "Bow and arrow":
        your_atk = random.randrange(1, 8)
    elif inventory.held_item == "Manual Revolver":
        your_atk = random.randrange(1, 10, 3)
    elif inventory.held_item == "Umbrella":
        your_atk = random.randint(1, 3)
    elif inventory.held_item == "Hunting knife":
        your_atk = random.randint(3, 6)
    else:
        your_atk = 0
    f = False
    while f == False:
        if your_hp <= 0:
            read_text.read_letters(
                """\033[1;31;40m\n    Norman triumphs over you, resulting in the end of your life.
    Unfortunately Norman Bates was the last face you ever saw
    And his reign of terror will proceed to rage on.\n""")
            your_hp = 15
            norm_health = 20
            firsttime -= 1
            f = True
            retry.retry()
        read_text.read_letters(
            f"\033[1;37;40m\n    What would you like to do?:\n")
        print(
            f"\033[1;37;40m    (A)ttack Norman with {inventory.held_item}\n(D)istract Norman\n(R)eturn to reception\n"
        )
        answer = msvcrt.getch().decode().lower()
        if answer == "a":
            norm_health -= your_atk
            if your_atk == 0:
                read_text.read_letters(
                    f"\033[1;31;40m    Norman chuckles. You honestly thought your {inventory.held_item} would do something to me? FOOL\n     Norman took no damage from that attack and launches you back into the reception\n"
                )
                f = True
                motel_navigation.enter_reception()
            elif norm_health > 16:
                read_text.read_letters(
                    f"\033[1;31;40m    You hit Norman for {your_atk} damage\n    'I appreciate the effort but you've barely wounded me!'\n"
                )
                read_text.read_letters(
                    f"\033[1;31;40m    Norman has {norm_health} hp left\n")
                norm_atk = random.randint(1, 4)
                your_hp -= norm_atk
                read_text.read_letters(
                    f"\033[1;37;40m    Norman hits you for {norm_atk} hp,\n    Watch out, you only have {your_hp} hp left\n"
                )
            elif norm_health <= 16 and norm_health > 12:
                read_text.read_letters(
                    f"\033[1;31;40m\n    You hit Norman for {your_atk} damage\n    'You really think this is hurting me?' Norman exclaims\n"
                )
                read_text.read_letters(
                    f"\033[1;31;40m    Norman has {norm_health} hp left\n")
                norm_atk = random.randint(2, 5)
                your_hp -= norm_atk
                read_text.read_letters(
                    f"\033[1;37;40m    Norman hits you for {norm_atk} hp,\n    Watch out, you only have {your_hp} hp left\n"
                )
            elif norm_health <= 12 and norm_health > 6:
                read_text.read_letters(
                    f"\033[1;31;40m    You hit Norman for {your_atk} damage\n    'You're not doing a great job!' Normal stumbles as he proclaims\n"
                )
                read_text.read_letters(
                    f"\033[1;31;40m    Norman has {norm_health} hp left\n")
                norm_atk = random.randint(1, 5)
                your_hp -= norm_atk
                read_text.read_letters(
                    f"\033[1;37;40m    Norman hits you for {norm_atk} hp,\n    Watch out, you only have {your_hp} hp left\n"
                )
            elif norm_health <= 6 and norm_health >= 1:
                read_text.read_letters(
                    f"\033[1;31;40m    You hit Norman for {your_atk} damage\n    'I told you I'm not letting you leave here alive!' Normal shouts with murderous intent\n"
                )
                read_text.read_letters(
                    f"\033[1;31;40m    Norman has {norm_health} hp left\n")
                norm_atk = random.randint(2, 6)
                your_hp -= norm_atk
                read_text.read_letters(
                    f"\033[1;37;40m    Norman hits you for {norm_atk} hp,\n    Watch out, you only have {your_hp} hp left\n"
                )
            elif norm_health < 1:
                read_text.read_letters(
                    "\033[1;31;40\n    You hit Norman for the remainder of his health."
                )
                read_text.read_letters(
                    "\033[1;31;40m\n    'Impossible, you...    Can't...             L e a v e......'"
                )
                firsttime -= 1
                f = True
                retry.end()
        elif answer == "d":
            read_text.read_letters(
                "    Norman doesn't fall for your pitiful attempt to point and distract him,\n    He proceeds to launch you back into the reception.\n"
            )
            f = True
            motel_navigation.enter_reception()
        elif answer == "r":
            read_text.read_letters(
                "    You decide to return to the reception. Probably for the better..."
            )
            f = True
            motel_navigation.enter_reception()
Ejemplo n.º 21
0
 def test_get_inventory (self):
     #Valid characters (remember they take an ID to identify):
     assert get_inventory(1)
     assert get_inventory(2)
     assert len(get_inventory(1)) == 1
     assert len(get_inventory(2)) == 1
     #Invalid characters:
     assert not get_inventory("Username")
     assert not get_inventory("Username2")
     assert not get_inventory(None)
     assert not get_inventory(-1)
     assert not get_inventory(0)
     assert not get_inventory("")
     assert not get_inventory("Fake Char")
Ejemplo n.º 22
0
            break
        if USER_FORM == 'add':
            NAME = input('What is name of the item? ')
            NAME = NAME.upper().strip(' ')
            TYPE = input('What is item type? ')
            TYPE = TYPE.upper().strip(' ')
            PRICE = input('What is the price? ')
            add_item({'name': NAME, 'type': TYPE, 'price': PRICE})
            continue
        if USER_FORM == 'delete':
            DEL_ITEM = input('What is the name of the Item you' +
                             'wish to delete? ').upper().strip()
            remove_item_by_name(DEL_ITEM)
            continue
        if USER_FORM == 'list':
            print(get_inventory())
            continue

        while USER_FORM == 'find':
            FIND_OPT = input('Would you like to find by ' +
                             '(name/type/price/back)').lower().strip(' ')
            if FIND_OPT == 'name':
                FIND_NAME = input('What is the name of the item? ')
                find_item_by_name(FIND_NAME)
                continue
            if FIND_OPT == 'type':
                FIND_TYPE = input('What type of liqour or liqours? ')
                find_item_by_type(FIND_TYPE)
                continue
            if FIND_OPT == 'price':  # PRICE BLOCK
                PRICE_PNT = float(input('What is your price point?'))
Ejemplo n.º 23
0
def get_jamf_inventory_csv():
    return Response(
        inventory.get_inventory('csv'),
        mimetype="text/csv",
        headers={"Content-disposition": "attachment; filename=jamf_inventory.csv"}
    )