Пример #1
0
 def test_initialize_inventory(self):
     inventory = Inventory()
     self.assertEqual(inventory.accumulated_stats['RD'].sum_stat(), 0)
     self.assertEqual(inventory.accumulated_stats['Exploration'].sum_stat(),
                      0)
     self.assertEqual(inventory.get_passive_bonus().sum_stat(), 0)
     self.assertEqual(inventory.items, [])
     self.assertEqual(inventory.rawMaterials, 0)
Пример #2
0
 def test_modify_passive_bonus(self):
     inventory = Inventory()
     self.assertEqual(inventory.get_passive_bonus().sum_stat(), 0)
     inventory.increase_passive_bonus('Tech', 3)
     self.assertEqual(inventory.get_passive_bonus().sum_stat(), 3)
     inventory.increase_passive_bonus('Danger', -1)
     self.assertEqual(inventory.get_passive_bonus().sum_stat(), 2)
Пример #3
0
 def test_items(self):
     inventory = Inventory()
     self.assertEqual(inventory.items, [])
     inventory.add_item('bag')
     self.assertEqual(inventory.items, ['bag'])
     inventory.add_item('bag')
     self.assertEqual(inventory.items, ['bag'])
     inventory.remove_item('ball')
     self.assertEqual(inventory.items, ['bag'])
     inventory.remove_item('bag')
     self.assertEqual(inventory.items, [])
Пример #4
0
def fake_inventory_generator(length, faker):
    for x in range(length):
        yield Inventory(item_name='{} ({})'.format(faker.word(),
                                                   faker.color_name()),
                        price=faker.random_int(100, 99900),
                        qty=faker.random_int(0, 1000),
                        date=utcnow())
Пример #5
0
 def test_fragment_filename(self):
     inventory = Inventory()
     known_fragments = []
     self.assertEqual(get_fragment_filename(inventory, known_fragments, 'Poseidon'),
                      'gui/inventory/icons/frag_Poseidon_black')
     known_fragments.append('Poseidon')
     self.assertEqual(get_fragment_filename(inventory, known_fragments, 'Poseidon'),
                      'gui/inventory/icons/frag_Poseidon_orange')
     inventory.fragments.append('Poseidon')
     self.assertEqual(get_fragment_filename(inventory, known_fragments, 'Poseidon'),
                      'gui/inventory/icons/frag_Poseidon_color')
Пример #6
0
 def post(self):
     try:
         """
         adds or deminishes x quantity of the y product in the given z store
         JSON example:
         {
             "store_id":123,
             "product_id":234,
             "quantity":1(positive values if wants to be added, negative if diminished)
         }
         :returns example:
         {
             "success": True,
         }
         """
         inventory = Inventory()
         json = request.json
         inventory.modify_stock(json['store_id'], json['product_id'], json['quantity'])
         return {'success': True}
     except Exception as e:
         return {'success': False, 'Error': str(e)}
Пример #7
0
    def post(self):
        try:
            order = Order()
            order_product = OrderProduct()
            json = request.json
            inventory = Inventory()
            order_to_db = {
                'customer_id': json['customer_id'],
                'store_id': json['store_id'],
            }
            order_id = order.insert_order(order_to_db)
            for product in json['products']:

                store_inventory = inventory.get_product_availability_in_specific_store(product['product_id'], json['store_id'])
                if product['quantity'] > store_inventory[0]['quantity']:
                    return {'success': False, 'Error': 'product unavailable '+product['product_id']}
                product['order_id'] = order_id
                order_product.insert_order_product(product)
                inventory.modify_stock(json['store_id'], product['product_id'], int(product['quantity'])*-1)
            return {'success': True, 'product': json}
        except Exception as e:
            return {'success': False, 'Error': str(e)}
Пример #8
0
 def test_spend_stats(self):
     inventory = Inventory()
     self.assertEqual(inventory.accumulated_stats['RD'].sum_stat(), 0)
     self.assertEqual(inventory.accumulated_stats['Exploration'].sum_stat(),
                      0)
     inventory.accumulate_stats(Stats({'Tech': 3, 'Contract': 2}), 'RD')
     self.assertEqual(inventory.accumulated_stats['RD'].sum_stat(), 5)
     self.assertEqual(inventory.accumulated_stats['Exploration'].sum_stat(),
                      0)
     inventory.spend_stats(Stats({'Tech': 1}), 'RD')
     self.assertEqual(inventory.accumulated_stats['RD'].sum_stat(), 4)
     self.assertEqual(inventory.accumulated_stats['Exploration'].sum_stat(),
                      0)
Пример #9
0
 def get(self):
     try:
         """
         gets an specific store inventory, book inventory across all stores or all the inventory of all the stores 
         to get an store inventory:
             json example:
                 {
                     "store_id":123
                 }
         :returns example:
             {
                 "success":true,
                 "Inventory":[
                     {
                         "product_id":1,
                         "product_name": "Product_name_1",
                         "quantity":1
                     },
                     .
                     .
                     .
                 ]
             }
         to get product inventory across all stores:
             json example:
                 {
                     "product_id":123
                 }
         :returns example:
             {
                 "success": true,
                 "inventory": [
                     {
                         "product_id":123,
                         "store_id":1,
                         "quantity":1,
                         "product_name": "Product_name"
                     }
                 ]
             }
         to get an specific product on an specific store:
             json example:
                 {
                     "store_id":123,
                     "product_id":123
                 }
         :returns example:
             {
                 "success": true,
                 "inventory":[
                     {   
                         "product_id":123,
                         "store_id":123,
                         "quantity":123,
                         "product_name":"product_name"
                     }
                 ]
             }     
         to obtain all the inventory across all stores, simply send no JSON at all:
         :returns example
             {
                 "success": true,
                 inventory:
                 {
                     {
                         "1"(store_id):{
                             "store_name": "This_is_a_name",
                             "store_inventory":[
                                 {
                                     "product_name":5(quantity)
                                 },
                                 ...
                             ],
                             ...
                         }
                         ...
                     }
                 }
             }
         """
         inventory = Inventory()
         json = request.json
         ans = None
         if bool(json) or json is not None:
             if 'store_id' in json:
                 if 'product_id' in json:
                     ans = inventory.get_product_availability_in_specific_store(
                         json['product_id'], json['store_id'])
                 else:
                     ans = inventory.get_store_inventory(json['store_id'])
             elif 'product_id' in json:
                 ans = inventory.get_product_availability_all_stores(
                     json['product_id'])
         else:
             ans = inventory.get_all_inventory_all_stores()
         return {'success': True, 'inventory': ans}
     except Exception as e:
         return {'success': False, 'Error': str(e)}
Пример #10
0
def test_get_product_availability_in_specific_store():
    inventory = Inventory()
    inventory_info = inventory.get_product_availability_in_specific_store(1, 1)
    assert 'product_id' in inventory_info[0] or len(inventory_info) == 0
Пример #11
0
def test_get_product_availability_all_stores():
    inventory = Inventory()
    inventory_info = inventory.get_product_availability_all_stores(1)
    assert 'product_id' in inventory_info[0] or len(inventory_info) == 0
Пример #12
0
def test_get_store_inventory():
    inventory = Inventory()
    inventory_info = inventory.get_store_inventory(1)
    assert 'product_id' in inventory_info[0] or len(inventory_info) == 0
Пример #13
0
def test_modify_stock():
    inventory = Inventory()
    inventory_info = inventory.modify_stock(1, 1, 5)
    assert inventory_info['success']
def fx_inventory():
    return Inventory(item_name='{} ({})'.format(fake.word(),
                                                fake.color_name()),
                     price=fake.random_int(100, 99900),
                     qty=fake.random_int(0, 1000),
                     date=utcnow())
Пример #15
0
    def __init__(self, name='PanoGame'):

        # setup logging
        logging.config.fileConfig('game.cfg')
        self.log = logging.getLogger('pano')

        self.name = name

        self.config = ConfigVars()

        self.windowProperties = {}

        self.resources = ResourceLoader()

        self.inventory = Inventory(self)

        self.gameView = GameView(gameRef=self, title=name)

        self.inputMappings = InputActionMappings(self)

        self.i18n = i18n(self)

        self.music = MusicPlayer(self)

        self.soundsFx = SoundsPlayer(self)

        self.msn = Messenger(self)

        self.initialNode = None

        self.mouseMode = PanoConstants.MOUSE_UI_MODE

        self.paused = False
        self.isGameSequenceActive = False

        self.gameActions = GameActions(self)

        self.fsm = None

        self.gameTask = None

        self.console = None
        self.consoleVisible = False

        self.saveLoad = None
        self.saveRequest = None
        self.loadRequest = None
        self.persistence = None

        self.quitRequested = False

        # read the boot configuration
        self._readBootConfig()

        os.chdir(self.config.get(PanoConstants.CVAR_GAME_DIR))
        try:
            with open('Config.prc') as cfgFile:
                loadPrcFileData('game-config', cfgFile.read())
        except IOError:
            self.log.exception(
                'Could not find Config.prc in the game directory')
Пример #16
0
 def __init__(self):
     initial_inventory = get_inventory_details_from_file()
     self.inventory_list = Inventory(initial_inventory).inventory_list
Пример #17
0
from model.guest import GuestList
from model.inventory import Inventory, FileList
from model.couple import RelationshipList
from model.reward import RewardList
from model.daily_event import DailyEventList
from model.wardrobe import Wardrobe

player_background = ""
current_chapter = ""
guests = GuestList()
inventory = Inventory()
relationships = RelationshipList()
rewards = RewardList()
daily_events = DailyEventList()
wardrobe = Wardrobe()

UI_permissions = {'ledger': False,
                  'items': False,
                  'guests': False,
                  'rd': False,
                  'exploration': False,
                  'fragments': False,
                  'files': False,
                  'file_profile': False,
                  'file_mementos': False,
                  'file_tech': False,
                  'file_contracts': False,
                  'file_artifacts': False}

# permanent variables
Пример #18
0
def test_get_all_inventory_all_stores():
    inventory = Inventory()
    inventory_info = inventory.get_all_inventory_all_stores()
    assert isinstance(inventory_info, dict)