Exemplo n.º 1
0
    def fetch_vault(guardian, platform, sort=None):

        guardian, platform = PyGuardian.prechecks(guardian, platform)
        account = Requester(guardian, platform)
        vault_data = account.fetch_vault_info()
        vault_hashes = json_funcs.fetch_vault_hashes(vault_data)
        vault_items = InventoryManifest(vault_hashes)
        return vault_items.get_full_item_details(sort_by=sort)
Exemplo n.º 2
0
    def test_get_full_item_details_alternate_json_structure(
            self, mock_load, mock_open):
        manifest = InventoryManifest(self.test_eq_hashes)
        returned_items = manifest.get_full_item_details()

        self.assertTrue(returned_items)
        self.assertIsInstance(returned_items, list)
        self.assertIsInstance(returned_items[0], list)
        self.assertIsInstance(returned_items[0][0], str)
        self.assertIn(["Dummy name", "", ""], returned_items)
Exemplo n.º 3
0
    def test_get_full_item_details_eq_hashes(self):
        manifest = InventoryManifest(self.test_eq_hashes, self.test_data_file)
        items = manifest.get_full_item_details()

        self.assertTrue(items)
        self.assertIsInstance(items, list)
        self.assertIsInstance(items[0], list)
        self.assertIsInstance(items[0][0], str)
        self.assertEqual(len(self.test_eq_hashes[0]), len(items))
        self.assertIn(self.test_item_result, items)
Exemplo n.º 4
0
    def test_get_full_item_details_vault_sort_by_rarity(self):
        manifest = InventoryManifest(self.test_eq_hashes, self.test_data_file)
        returned_items = manifest.get_full_item_details(sort_by="tier")

        correctly_sorted_items = sorted(returned_items, key=itemgetter(2))
        incorrectly_sorted_items = sorted(returned_items, key=itemgetter(1))
        more_incorrectly_sorted_items = sorted(returned_items,
                                               key=itemgetter(0))

        self.assertTrue(returned_items)
        self.assertTrue(correctly_sorted_items)
        self.assertEqual(returned_items, correctly_sorted_items)
        self.assertNotEqual(returned_items, incorrectly_sorted_items)
        self.assertNotEqual(returned_items, more_incorrectly_sorted_items)
Exemplo n.º 5
0
    def fetch_eq(guardian, platform):

        try:
            guardian, platform = PyGuardian.prechecks(guardian, platform)
            account = Requester(guardian, platform)
            char_data = account.fetch_character_info()
            equip_data = account.fetch_character_equip_info()
            weapon_hashes = json_funcs.fetch_eq_hashes(equip_data, char_data)
            weapon_data = InventoryManifest(weapon_hashes)
            return weapon_data.get_full_item_details()

        except (APIException, APIUnavailableException) as ape:
            logger = PyGuardianLogger()
            logger.error(ape)
        finally:
            logging.shutdown()
Exemplo n.º 6
0
def fetch_character_eq_details(equipment_data: dict,
                               character_data: dict) -> List[list]:
    """

    :param equipment_data:
    :param character_data:
    :return:
    """
    check_response(equipment_data, character_data)

    characters = get_character_ids(ROOT_STR_1, character_data)

    character_items_lists = []
    for char in characters:
        item_hashes = extract_item_hashes(character_data, equipment_data, char)
        data = InventoryManifest(item_hashes)
        character_items_lists.append(data.get_full_item_details())

    return character_items_lists