Beispiel #1
0
    def test__preprocess_query_results__multiple_casts_with_end_event(self):

        zone = RaidZone(id=1, name="TestZone")
        boss = RaidBoss(zone=zone, id=10, name="TestBoss")
        boss.add_event(spell_id=100, until={"spell_id": 200})

        query_result = {
            'report': {
                'events': {
                    'data': [
                        {'timestamp': 100, 'type': 'cast', 'abilityGameID': 100},
                        {'timestamp': 110, 'type': 'cast', 'abilityGameID': 200},
                        {'timestamp': 200, 'type': 'cast', 'abilityGameID': 100},
                        {'timestamp': 230, 'type': 'cast', 'abilityGameID': 200},
                    ]
                }
            }
        }

        processed = boss.preprocess_query_results(query_result)

        casts = utils.get_nested_value(processed, "report", "events", "data") or []
        assert len(casts) == 2
        assert casts[0].get("duration") == 10
        assert casts[1].get("duration") == 30
Beispiel #2
0
async def get_boss(boss_slug: str):
    """Get a single Boss.

    Args:
        boss_slug (string): name of the boss

    """
    boss = RaidBoss.get(full_name_slug=boss_slug)
    if not boss:
        return "Invalid Boss.", 404
    return boss.as_dict()
Beispiel #3
0
async def get_boss_spells(boss_slug: str):
    """Get Spells for a given Boss.

    Args:
        boss_slug (string): name of the boss

    """
    boss = RaidBoss.get(full_name_slug=boss_slug)
    if not boss:
        return "Invalid Boss.", 404

    return {spell.spell_id: spell.as_dict() for spell in boss.all_abilities}
Beispiel #4
0
def test_raid_boss():
    # create a raid boss instance, so we have something to test againt
    zone = RaidZone(id=1, name="TestZone")
    boss = RaidBoss(id=RAID_BOSS_ID, zone=zone, name="TestBoss")
    return boss
 def boss(self) -> RaidBoss:
     return RaidBoss.get(full_name_slug=self.boss_slug)
Beispiel #6
0
 def add_boss(self, **kwargs) -> RaidBoss:
     """Add a new RaidBoss to this zone."""
     boss = RaidBoss(zone=self, **kwargs)
     self.bosses.append(boss)
     return boss
Beispiel #7
0
 def raid_boss(self) -> RaidBoss:
     return RaidBoss.get(id=self.boss_id)