コード例 #1
0
ファイル: test_pve.py プロジェクト: clegg89/altaudit
def test_dungeons_and_raids_missing_stat_quantity(bfa_raids):
    jack = Character('jack', realm=Realm('kiljaeden', Region('us')))
    now = datetime.datetime(2019, 8, 8)
    bad_bfa_raids = copy.deepcopy(bfa_raids)
    del bad_bfa_raids[1]['quantity']
    response = { 'achievements' : { 'achievements' : [] },
            'quests_completed' : { 'quests' : [] },
            'achievements_statistics' : { 'categories' : [
                {'id' : 14807, 'sub_categories' : [
                    {'id' : 15409, 'statistics' : [
                        {'id' : 14392},
                        {'id' : 14395, 'quantity' : 8},
                        {'id' : 14404, 'quantity' : 9},
                        {'id' : 14389, 'quantity' : 10},
                        {'id' : 14398, 'quantity' : 11},
                        {'id' : 14205, 'quantity' : 12},
                        {'id' : 14401, 'quantity' : 13},
                        {'id' : 14407, 'quantity' : 14},
                        *bad_bfa_raids]}]}]}}

    Utility.set_refresh_timestamp(now)
    Section.pve(jack, response, None)

    assert jack.dungeons_total == 77
    assert jack.dungeons_each_total == "Halls of Atonement+0|Mists of Tirna Scithe+8|The Necrotic Wake+9|De Other Side+10|Plaguefall+11|Sanguine Depths+12|Spires of Ascension+13|Theater of Pain+14"
    assert jack.raids_raid_finder        == '0|0|0|0|0|0|0|0|0|0'
    assert jack.raids_raid_finder_weekly == '0|0|0|0|0|0|0|0|0|0'
    assert jack.raids_normal             == '0|1|1|1|1|1|1|1|1|1'
    assert jack.raids_normal_weekly      == '0|0|0|0|0|0|0|0|0|0'
    assert jack.raids_heroic             == '8|7|6|5|4|3|2|1|9|8'
    assert jack.raids_heroic_weekly      == '0|0|0|0|0|0|0|0|0|0'
    assert jack.raids_mythic             == '1|0|0|0|0|0|0|0|9|1'
    assert jack.raids_mythic_weekly      == '0|0|0|0|0|0|0|0|0|0'
コード例 #2
0
ファイル: test_pve.py プロジェクト: clegg89/altaudit
def test_dungeons_and_raids_missing_sub_categories_id(bfa_raids):
    jack = Character('jack', realm=Realm('kiljaeden', Region('us')))
    now = datetime.datetime(2019, 8, 8)
    response = { 'achievements' : { 'achievements' : [] },
            'quests_completed' : { 'quests' : [] },
            'achievements_statistics' : { 'categories' : [
                {'id' : 14807, 'sub_categories' : [
                    {'statistics' : [
                        {'id' : 12749, 'quantity' : 4},
                        {'id' : 12752, 'quantity' : 5},
                        {'id' : 12763, 'quantity' : 6},
                        {'id' : 12779, 'quantity' : 7},
                        {'id' : 12768, 'quantity' : 8},
                        {'id' : 12773, 'quantity' : 9},
                        {'id' : 12776, 'quantity' : 10},
                        {'id' : 12782, 'quantity' : 11},
                        {'id' : 12745, 'quantity' : 12},
                        {'id' : 12785, 'quantity' : 13},
                        {'id' : 13620, 'quantity' : 14},
                        *bfa_raids]}]}]}}

    Utility.set_refresh_timestamp(now)
    Section.pve(jack, response, None)

    assert jack.dungeons_total == 0
    assert jack.dungeons_each_total == "Halls of Atonement+0|Mists of Tirna Scithe+0|The Necrotic Wake+0|De Other Side+0|Plaguefall+0|Sanguine Depths+0|Spires of Ascension+0|Theater of Pain+0"
    assert jack.raids_raid_finder        == '0|0|0|0|0|0|0|0|0|0'
    assert jack.raids_raid_finder_weekly == '0|0|0|0|0|0|0|0|0|0'
    assert jack.raids_normal             == '0|0|0|0|0|0|0|0|0|0'
    assert jack.raids_normal_weekly      == '0|0|0|0|0|0|0|0|0|0'
    assert jack.raids_heroic             == '0|0|0|0|0|0|0|0|0|0'
    assert jack.raids_heroic_weekly      == '0|0|0|0|0|0|0|0|0|0'
    assert jack.raids_mythic             == '0|0|0|0|0|0|0|0|0|0'
    assert jack.raids_mythic_weekly      == '0|0|0|0|0|0|0|0|0|0'
コード例 #3
0
    def test_timestamp_set(self, mock_process_blizzard, mock_process_raiderio, mock_update_snapshots, mock_serialize, mocker):
        Utility.set_refresh_timestamp(datetime.datetime.utcnow()) # Prevent update_snapshots from failing
        mock_utility = mocker.patch('altaudit.audit.Utility')
        dt = mocker.MagicMock()
        dt.utcnow.return_value = datetime.datetime(2019, 8, 5)

        self.audit.refresh(dt)

        mock_utility.set_refresh_timestamp.assert_called_once_with(datetime.datetime(2019, 8, 5))
コード例 #4
0
def test_utility_region_timestamps():
    now = datetime.datetime(2019, 8, 8, 20, 31, 44, 0)

    Utility.set_refresh_timestamp(now)

    assert Utility.timestamp['us'] == 1565103600
    assert Utility.timestamp['eu'] == 1565161200
    assert Utility.timestamp['kr'] == 1565161200
    assert Utility.timestamp['tw'] == 1565161200
コード例 #5
0
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]
コード例 #6
0
def test_get_snapshots_year_not_present():
    jack = Character('jack', realm=Realm('kiljaeden', Region('us')))
    jack.snapshots = {}
    now = datetime.datetime(2019, 8, 7)
    Utility.set_refresh_timestamp(now)

    _get_snapshots(jack)

    assert jack.world_quests_weekly == None
    assert jack.dungeons_weekly == None
コード例 #7
0
def test_get_snapshots_snapshot_invalid_leave_as_none():
    jack = Character('jack', realm=Realm('kiljaeden', Region('us')))
    jack.snapshots = { 2019 : { 32 : Snapshot() } }
    # Values that should not be None are None. totals, snapshot values, etc.
    now = datetime.datetime(2019, 8, 7)
    Utility.set_refresh_timestamp(now)

    _get_snapshots(jack)

    assert jack.world_quests_weekly == None
    assert jack.dungeons_weekly == None
コード例 #8
0
def test_update_snapshot_fill_missing_not_on_existing_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] = { 31 : Snapshot() }

    Utility.set_refresh_timestamp(now)

    update_snapshots(clegg)

    mock_fill_missing_snapshots.assert_not_called()
コード例 #9
0
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)
コード例 #10
0
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
コード例 #11
0
def test_utility_region_prev_week_times_simple():
    now = datetime.datetime(2019, 8, 5, 20, 32, 34, 85)

    Utility.set_refresh_timestamp(now)

    assert Utility.prev_week_year['us'] == 2019
    assert Utility.prev_week_year['eu'] == 2019
    assert Utility.prev_week_year['kr'] == 2019
    assert Utility.prev_week_year['tw'] == 2019

    assert Utility.prev_week_week['us'] == 30
    assert Utility.prev_week_week['eu'] == 30
    assert Utility.prev_week_week['kr'] == 30
    assert Utility.prev_week_week['tw'] == 30
コード例 #12
0
def test_utility_region_times_before_reset():
    now = datetime.datetime(2019, 8, 5, 20, 32, 34, 85)

    Utility.set_refresh_timestamp(now)

    assert Utility.year['us'] == 2019
    assert Utility.year['eu'] == 2019
    assert Utility.year['kr'] == 2019
    assert Utility.year['tw'] == 2019

    assert Utility.week['us'] == 31
    assert Utility.week['eu'] == 31
    assert Utility.week['kr'] == 31
    assert Utility.week['tw'] == 31
コード例 #13
0
def test_utility_region_times_use_isocalendar():
    now = datetime.datetime(2020, 1, 3, 20, 44)

    Utility.set_refresh_timestamp(now)

    assert Utility.year['us'] == 2020
    assert Utility.year['eu'] == 2020
    assert Utility.year['kr'] == 2020
    assert Utility.year['tw'] == 2020

    assert Utility.week['us'] == 1
    assert Utility.week['eu'] == 1
    assert Utility.week['kr'] == 1
    assert Utility.week['tw'] == 1
コード例 #14
0
def test_utility_region_times_after_us_eu():
    now = datetime.datetime(2019, 8, 8, 20, 31, 44, 0)

    Utility.set_refresh_timestamp(now)

    assert Utility.year['us'] == 2019
    assert Utility.year['eu'] == 2019
    assert Utility.year['kr'] == 2019
    assert Utility.year['tw'] == 2019

    assert Utility.week['us'] == 32
    assert Utility.week['eu'] == 32
    assert Utility.week['kr'] == 32
    assert Utility.week['tw'] == 32
コード例 #15
0
def test_utility_region_prev_week_times_between_resets():
    now = datetime.datetime(2020, 1, 1, 0, 32, 34, 85)

    Utility.set_refresh_timestamp(now)

    assert Utility.prev_week_year['us'] == 2019
    assert Utility.prev_week_year['eu'] == 2019
    assert Utility.prev_week_year['kr'] == 2019
    assert Utility.prev_week_year['tw'] == 2019

    assert Utility.prev_week_week['us'] == 52
    assert Utility.prev_week_week['eu'] == 51
    assert Utility.prev_week_week['kr'] == 51
    assert Utility.prev_week_week['tw'] == 51
コード例 #16
0
def test_update_snapshot_no_overwrite_existing():
    clegg = Character('clegg', realm=Realm('kiljaeden', Region('us')))
    now = datetime.datetime(2019, 8, 5)
    clegg.snapshots[2019] = {}
    clegg.snapshots[2019][31] = Snapshot()
    clegg.snapshots[2019][31].world_quests = 5
    clegg.snapshots[2019][31].dungeons = 10
    clegg.snapshots[2019][31].highest_mplus = 13

    Utility.set_refresh_timestamp(now)

    update_snapshots(clegg)

    assert clegg.snapshots[2019][31].world_quests == 5
    assert clegg.snapshots[2019][31].dungeons == 10
    assert clegg.snapshots[2019][31].highest_mplus == 13
コード例 #17
0
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
コード例 #18
0
ファイル: test_pve.py プロジェクト: clegg89/altaudit
def test_raids_all_boss_difficulties(bfa_raids):
    jack = Character('jack', realm=Realm('kiljaeden', Region('us')))
    now = datetime.datetime(2019, 8, 8)
    response = { 'achievements' : { 'achievements' : [] },
            'quests_completed' : { 'quests' : [] },
            'achievements_statistics' : { 'categories' : [
                {'id' : 14807, 'sub_categories' : [
                    {'id' : 15409, 'statistics' : bfa_raids}]}]}}

    Utility.set_refresh_timestamp(now)
    Section.pve(jack, response, None)

    assert jack.raids_raid_finder        == '0|0|0|0|0|0|0|0|0|0'
    assert jack.raids_raid_finder_weekly == '0|0|0|0|0|0|0|0|0|0'
    assert jack.raids_normal             == '1|1|1|1|1|1|1|1|1|1'
    assert jack.raids_normal_weekly      == '0|0|0|0|0|0|0|0|0|0'
    assert jack.raids_heroic             == '8|7|6|5|4|3|2|1|9|8'
    assert jack.raids_heroic_weekly      == '0|0|0|0|0|0|0|0|0|0'
    assert jack.raids_mythic             == '1|0|0|0|0|0|0|0|9|1'
    assert jack.raids_mythic_weekly      == '0|0|0|0|0|0|0|0|0|0'
コード例 #19
0
ファイル: test_pve.py プロジェクト: clegg89/altaudit
def test_raids_missing_last_updated_timestamp(bfa_raids):
    jack = Character('jack', realm=Realm('kiljaeden', Region('us')))
    now = datetime.datetime(2019, 8, 8)
    bad_bfa_raids = copy.deepcopy(bfa_raids)
    entry_to_alter = next(entry for entry in bad_bfa_raids if entry['id'] == 14432)
    del entry_to_alter['last_updated_timestamp']
    response = { 'achievements' : { 'achievements' : [] },
            'quests_completed' : { 'quests' : [] },
            'achievements_statistics' : { 'categories' : [
                {'id' : 14807, 'sub_categories' : [
                    {'id' : 15409, 'statistics' : bad_bfa_raids}]}]}}

    Utility.set_refresh_timestamp(now)
    Section.pve(jack, response, None)

    assert jack.raids_raid_finder        == '0|0|0|0|0|0|0|0|0|0'
    assert jack.raids_raid_finder_weekly == '0|0|0|0|0|0|0|0|0|0'
    assert jack.raids_normal             == '1|1|1|1|1|1|1|1|1|1'
    assert jack.raids_normal_weekly      == '0|0|0|0|0|0|0|0|0|0'
    assert jack.raids_heroic             == '8|7|6|5|0|3|2|1|9|8'
    assert jack.raids_heroic_weekly      == '0|0|0|0|0|0|0|0|0|0'
    assert jack.raids_mythic             == '1|0|0|0|0|0|0|0|9|1'
    assert jack.raids_mythic_weekly      == '0|0|0|0|0|0|0|0|0|0'
コード例 #20
0
def test_metadata_timestamp():
    now = datetime.datetime(2019, 8, 11, 18, 1, 30)

    Utility.set_refresh_timestamp(now)

    assert Section.metadata()[0] == now
コード例 #21
0
def test_utility_refresh_time():
    now = datetime.datetime(2019, 8, 8, 20, 31, 44, 0)

    Utility.set_refresh_timestamp(now)

    assert Utility.refresh_time == now