def test_pve_achievements_key_missing(): jack = Character('jack') response = { 'achievements' : {'garbage' : 'some more garbage'}, 'quests_completed' : { 'quests' : [] }, 'achievements_statistics' : { 'categories' : [ {'id' : 14807, 'sub_categories' : [ {'id' : 15409, 'statistics' : []}]}]}} jack.world_quests_total = 30 Section.pve(jack, response, None) assert jack.world_quests_total == 30
def test_pve_empty_achievements(): jack = Character('jack') response = { 'achievements' : None, 'quests_completed' : { 'quests' : [] }, 'achievements_statistics' : None} jack.world_quests_total = 30 Section.pve(jack, response, None) assert jack.world_quests_total == 30
def test_update_snapshot_do_not_add_on_missing_dungeons(): clegg = Character('clegg', realm=Realm('kiljaeden', Region('us'))) now = datetime.datetime(2019, 8, 5) Utility.set_refresh_timestamp(now) clegg.world_quests_total = 0 update_snapshots(clegg) assert 2019 in clegg.snapshots assert 31 not in clegg.snapshots[2019]
def test_pve_achievements_missing_id_old_value_greater_than_new(): jack = Character('jack') response = { 'achievements' : { 'achievements' : [ {'criteria' : {'child_criteria' : [{'amount' : 10}]}}, {'id' : 12597, 'criteria' : {'child_criteria' : [{'amount' : 30}]}}, {'criteria' : {'child_criteria' : [{'amount' : 40}]}}]}, 'quests_completed' : { 'quests' : [] }, 'achievements_statistics' : { 'categories' : [ {'id' : 14807, 'sub_categories' : [ {'id' : 15409, 'statistics' : []}]}]}} jack.world_quests_total = 30 Section.pve(jack, response, None) assert jack.world_quests_total == 30
def test_update_snapshot_fill_missing_on_new_week(mocker): mock_fill_missing_snapshots = mocker.patch('altaudit.processing._fill_missing_snapshots') clegg = Character('clegg', realm=Realm('kiljaeden', Region('us'))) now = datetime.datetime(2019, 8, 5) clegg.snapshots[2019] = { 30 : Snapshot() } clegg.world_quests_total = 0 clegg.dungeons_total = 0 Utility.set_refresh_timestamp(now) update_snapshots(clegg) mock_fill_missing_snapshots.assert_called_once_with(clegg)
def test_get_snapshots_negative_dungeons(): jack = Character('jack', realm=Realm('kiljaeden', Region('us'))) jack.snapshots = { 2019 : { 32 : Snapshot() } } jack.snapshots[2019][32].world_quests = 300 jack.snapshots[2019][32].dungeons = 20 jack.world_quests_total = 320 jack.dungeons_total = 18 now = datetime.datetime(2019, 8, 7) Utility.set_refresh_timestamp(now) _get_snapshots(jack) assert jack.dungeons_weekly == 0 assert jack.snapshots[2019][32].dungeons == 18
def test_update_snapshot_capture_existing_totals(): clegg = Character('clegg', realm=Realm('kiljaeden', Region('us'))) now = datetime.datetime(2019, 8, 5) clegg.world_quests_total = 300 clegg.dungeons_total = 40 clegg.mplus_weekly_highest = 13 clegg.snapshots[2019] = { 30 : Snapshot() } Utility.set_refresh_timestamp(now) update_snapshots(clegg) assert clegg.snapshots[2019][31].world_quests == 300 assert clegg.snapshots[2019][31].dungeons == 40 assert clegg.snapshots[2019][31].highest_mplus == None assert clegg.snapshots[2019][30].highest_mplus == 13