Loading cog/actions.py +14 −2 Original line number Diff line number Diff line Loading @@ -934,7 +934,7 @@ class Drop(Action): self.duser.display_name, self.args.amount, system.name) response = system.display() if system.is_deferred and (not globe.show_almost_done and not is_near_tick()): if check_system_deferred_and_globe(system, globe): response += self.deferred(system) elif system.is_fortified: response += self.finished(system) Loading Loading @@ -1068,7 +1068,7 @@ To unset override, simply set an empty list of systems. for name in process_system_args(self.args.system): system = cogdb.query.fort_find_system(self.session, name) lines.append(system.display()) if system.is_deferred and (not globe.show_almost_done and not is_near_tick()): if check_system_deferred_and_globe(system, globe): lines.append('This system is **almost done** and should stay **untouched** until further orders.\n') response = '\n'.join(lines) Loading Loading @@ -2189,6 +2189,18 @@ def is_near_tick(): return hours_left <= hours_to_tick def check_system_deferred_and_globe(system, globe): """Retrurn True IFF the system is deferred and conditions met for almost done messages. N.B. This includes system can't be priority or prep. Args: system: A System db object. globe: A Globe db object. """ return system.is_deferred and not system.is_priority and not system.is_prep\ and (not globe.show_almost_done and not is_near_tick()) def route_systems(systems): """ Take a series of FortSystem objects from local database and return them Loading cogdb/schema.py +5 −0 Original line number Diff line number Diff line Loading @@ -298,6 +298,11 @@ class FortSystem(Base): """ The system should be priority. """ return cls.notes.ilike("%priority%") @hybrid_property def is_prep(self): """ The system should be priority. """ return self.type == EFortType.prep @hybrid_property def is_skipped(self): """ The system should be skipped. """ Loading tests/cog/test_actions.py +14 −0 Original line number Diff line number Diff line Loading @@ -1945,3 +1945,17 @@ async def test_cmd_summary_no_perms(f_bot, f_dusers, f_fort_testbed): with pytest.raises(cog.exc.InvalidPerms): await action_map(msg, f_bot).execute() def test_check_system_deferred_and_globe(f_dusers, f_fort_testbed, f_global_testbed): fort = f_fort_testbed[1][0] prep = f_fort_testbed[1][-1] globe = f_global_testbed[0] globe.show_vote_goal = False assert cog.actions.check_system_deferred_and_globe(prep, globe) is False fort.notes = 'priority' assert cog.actions.check_system_deferred_and_globe(fort, globe) is False assert cog.actions.check_system_deferred_and_globe(fort, globe) is not cog.actions.is_near_tick() globe.show_vote_goal = True assert cog.actions.check_system_deferred_and_globe(fort, globe) is False tests/cogdb/test_schema.py +17 −0 Original line number Diff line number Diff line Loading @@ -299,6 +299,23 @@ def test_fortsystem_priority_expression(session, f_dusers, f_fort_testbed): assert [x[0] for x in priorities] == ["Othime"] def test_fortsystem_prep(f_dusers, f_fort_testbed): __import__('pprint').pprint(f_fort_testbed) system = f_fort_testbed[1][0] print(system) assert system.is_prep is False system = f_fort_testbed[1][-1] print(system, system.is_prep) assert system.is_prep is True def test_fortsystem_prep_expression(session, f_dusers, f_fort_testbed): preps = session.query(FortSystem.name).filter(FortSystem.is_prep).all() assert ['Rhea', 'PrepDone'] == [x[0] for x in preps] def test_fortsystem_skip(f_dusers, f_fort_testbed): system = f_fort_testbed[1][0] assert system.is_skipped is False Loading Loading
cog/actions.py +14 −2 Original line number Diff line number Diff line Loading @@ -934,7 +934,7 @@ class Drop(Action): self.duser.display_name, self.args.amount, system.name) response = system.display() if system.is_deferred and (not globe.show_almost_done and not is_near_tick()): if check_system_deferred_and_globe(system, globe): response += self.deferred(system) elif system.is_fortified: response += self.finished(system) Loading Loading @@ -1068,7 +1068,7 @@ To unset override, simply set an empty list of systems. for name in process_system_args(self.args.system): system = cogdb.query.fort_find_system(self.session, name) lines.append(system.display()) if system.is_deferred and (not globe.show_almost_done and not is_near_tick()): if check_system_deferred_and_globe(system, globe): lines.append('This system is **almost done** and should stay **untouched** until further orders.\n') response = '\n'.join(lines) Loading Loading @@ -2189,6 +2189,18 @@ def is_near_tick(): return hours_left <= hours_to_tick def check_system_deferred_and_globe(system, globe): """Retrurn True IFF the system is deferred and conditions met for almost done messages. N.B. This includes system can't be priority or prep. Args: system: A System db object. globe: A Globe db object. """ return system.is_deferred and not system.is_priority and not system.is_prep\ and (not globe.show_almost_done and not is_near_tick()) def route_systems(systems): """ Take a series of FortSystem objects from local database and return them Loading
cogdb/schema.py +5 −0 Original line number Diff line number Diff line Loading @@ -298,6 +298,11 @@ class FortSystem(Base): """ The system should be priority. """ return cls.notes.ilike("%priority%") @hybrid_property def is_prep(self): """ The system should be priority. """ return self.type == EFortType.prep @hybrid_property def is_skipped(self): """ The system should be skipped. """ Loading
tests/cog/test_actions.py +14 −0 Original line number Diff line number Diff line Loading @@ -1945,3 +1945,17 @@ async def test_cmd_summary_no_perms(f_bot, f_dusers, f_fort_testbed): with pytest.raises(cog.exc.InvalidPerms): await action_map(msg, f_bot).execute() def test_check_system_deferred_and_globe(f_dusers, f_fort_testbed, f_global_testbed): fort = f_fort_testbed[1][0] prep = f_fort_testbed[1][-1] globe = f_global_testbed[0] globe.show_vote_goal = False assert cog.actions.check_system_deferred_and_globe(prep, globe) is False fort.notes = 'priority' assert cog.actions.check_system_deferred_and_globe(fort, globe) is False assert cog.actions.check_system_deferred_and_globe(fort, globe) is not cog.actions.is_near_tick() globe.show_vote_goal = True assert cog.actions.check_system_deferred_and_globe(fort, globe) is False
tests/cogdb/test_schema.py +17 −0 Original line number Diff line number Diff line Loading @@ -299,6 +299,23 @@ def test_fortsystem_priority_expression(session, f_dusers, f_fort_testbed): assert [x[0] for x in priorities] == ["Othime"] def test_fortsystem_prep(f_dusers, f_fort_testbed): __import__('pprint').pprint(f_fort_testbed) system = f_fort_testbed[1][0] print(system) assert system.is_prep is False system = f_fort_testbed[1][-1] print(system, system.is_prep) assert system.is_prep is True def test_fortsystem_prep_expression(session, f_dusers, f_fort_testbed): preps = session.query(FortSystem.name).filter(FortSystem.is_prep).all() assert ['Rhea', 'PrepDone'] == [x[0] for x in preps] def test_fortsystem_skip(f_dusers, f_fort_testbed): system = f_fort_testbed[1][0] assert system.is_skipped is False Loading