mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-07-05 09:01:36 +02:00
finished documenmtation of steptests and test
This commit is contained in:
@ -17,7 +17,8 @@ class Test(unittest.TestCase):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""
|
"""
|
||||||
Base test class for unit tests.
|
Base test class for unit tests that provides base functions to be overwritten that are automatically called by
|
||||||
|
the StepTests class.
|
||||||
"""
|
"""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ class MaintainerTest(Test):
|
|||||||
def tick_step(self, state) -> List[TickResult]:
|
def tick_step(self, state) -> List[TickResult]:
|
||||||
for maintainer in state.entities[M.MAINTAINERS]:
|
for maintainer in state.entities[M.MAINTAINERS]:
|
||||||
|
|
||||||
# has valid actionresult
|
# has valid action result
|
||||||
self.assertIsInstance(maintainer.state, ActionResult)
|
self.assertIsInstance(maintainer.state, ActionResult)
|
||||||
# self.assertEqual(maintainer.state.validity, True)
|
# self.assertEqual(maintainer.state.validity, True)
|
||||||
# print(f"state validity {maintainer.state.validity}")
|
# print(f"state validity {maintainer.state.validity}")
|
||||||
|
@ -309,6 +309,9 @@ class Gamestate(object):
|
|||||||
|
|
||||||
class StepTests:
|
class StepTests:
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
|
"""
|
||||||
|
The StepTests class is responsible for calling all tests and their respective hooks at the right time.
|
||||||
|
"""
|
||||||
if args:
|
if args:
|
||||||
self.tests = list(args)
|
self.tests = list(args)
|
||||||
else:
|
else:
|
||||||
@ -326,6 +329,12 @@ class StepTests:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def do_all_init(self, state, lvl_map) -> bool:
|
def do_all_init(self, state, lvl_map) -> bool:
|
||||||
|
"""
|
||||||
|
Iterate all **Tests** that override the *on_check_done* hook.
|
||||||
|
|
||||||
|
:return: valid
|
||||||
|
:rtype: bool
|
||||||
|
"""
|
||||||
for test in self.tests:
|
for test in self.tests:
|
||||||
if test_init_printline := test.on_init(state, lvl_map):
|
if test_init_printline := test.on_init(state, lvl_map):
|
||||||
state.print(test_init_printline)
|
state.print(test_init_printline)
|
||||||
@ -335,10 +344,6 @@ class StepTests:
|
|||||||
"""
|
"""
|
||||||
Iterate all **Tests** that override the *tick_step* hook.
|
Iterate all **Tests** that override the *tick_step* hook.
|
||||||
|
|
||||||
:return: List of Results
|
|
||||||
""" """
|
|
||||||
Iterate all **Tests** that override the *on_check_done* hook.
|
|
||||||
|
|
||||||
:return: List of Results
|
:return: List of Results
|
||||||
"""
|
"""
|
||||||
test_results = list()
|
test_results = list()
|
||||||
|
Reference in New Issue
Block a user