Fixed healing and started working on item collection tracking
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import requests
|
||||
|
||||
from src.gui.modules.views.list_view import icon
|
||||
from src.utils import async_request
|
||||
|
||||
|
||||
def test_get_weapon_icon_ignores_missing_weapon(monkeypatch):
|
||||
called = []
|
||||
monkeypatch.setattr(icon.async_request, 'get', lambda url: called.append(url))
|
||||
|
||||
assert icon.get_weapon_icon(None) is None
|
||||
assert called == []
|
||||
|
||||
|
||||
def test_async_request_catches_request_errors(monkeypatch):
|
||||
queued = []
|
||||
|
||||
def raise_connection_error(_url, timeout=None):
|
||||
raise requests.ConnectionError('dns failed')
|
||||
|
||||
class FakeQueue:
|
||||
def put(self, item):
|
||||
queued.append(item)
|
||||
|
||||
monkeypatch.setattr(async_request.requests, 'get', raise_connection_error)
|
||||
monkeypatch.setattr(async_request, '_queue', FakeQueue())
|
||||
|
||||
async_request._async_req('https://example.invalid/icon')
|
||||
|
||||
assert queued[0].key == 'https://example.invalid/icon'
|
||||
assert queued[0].value is None
|
||||
@@ -0,0 +1,37 @@
|
||||
from src.stats.combat_stats import CombatStats
|
||||
|
||||
|
||||
class VisibleAll:
|
||||
def test(self, _name):
|
||||
return True
|
||||
|
||||
|
||||
def test_self_healing_counts_while_in_combat():
|
||||
stats = CombatStats(VisibleAll())
|
||||
stats.on_player_appeared(0, 'Healer')
|
||||
stats.on_enter_combat(0)
|
||||
|
||||
stats.on_health_received(0, 0, 100.0)
|
||||
|
||||
combat_healing = stats.players_healing()
|
||||
total_healing = stats.players_total_healing()
|
||||
|
||||
assert combat_healing[0].name == 'Healer'
|
||||
assert combat_healing[0].value == 100.0
|
||||
assert total_healing[0].value == 100.0
|
||||
|
||||
|
||||
def test_total_healing_includes_post_combat_healing():
|
||||
stats = CombatStats(VisibleAll())
|
||||
stats.on_player_appeared(0, 'Healer')
|
||||
stats.on_enter_combat(0)
|
||||
stats.on_health_received(0, 0, 100.0)
|
||||
stats.on_leave_combat(0)
|
||||
|
||||
stats.on_health_received(0, 0, 50.0)
|
||||
|
||||
combat_healing = stats.players_healing()
|
||||
total_healing = stats.players_total_healing()
|
||||
|
||||
assert combat_healing[0].value == 100.0
|
||||
assert total_healing[0].value == 150.0
|
||||
Reference in New Issue
Block a user