-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(issue-98): Add SC2Action class * test(issue-98): Add units tests to SC2Action * refactor(issue-98): Fix typo in SC2Action unit tests * refactor(issue-98): Rename action_id to action #98 * refactor(issue-98): Rename action to action_function #99 Co-authored-by: Álvaro Paiva <[email protected]> --------- Co-authored-by: Álvaro Paiva <[email protected]>
- Loading branch information
1 parent
616f29b
commit 6d15f53
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import unittest | ||
|
||
from pysc2.lib import actions | ||
|
||
from urnai.actions.sc2_action import SC2Action | ||
|
||
_BUILD_REFINERY = actions.RAW_FUNCTIONS.Build_Refinery_pt | ||
_NO_OP = actions.FUNCTIONS.no_op | ||
|
||
class TestSC2Action(unittest.TestCase): | ||
|
||
def test_run(self): | ||
|
||
run_no_op = SC2Action.run(_NO_OP) | ||
run_build_refinery = SC2Action.run(_BUILD_REFINERY, 'now', 0) | ||
|
||
self.assertEqual(run_no_op.function, _NO_OP.id) | ||
self.assertEqual(run_no_op.arguments, []) | ||
|
||
self.assertEqual(run_build_refinery.function, _BUILD_REFINERY.id) | ||
self.assertEqual(run_build_refinery.arguments, [[actions.Queued['now']], [0]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from pysc2.lib.actions import FunctionCall | ||
|
||
|
||
class SC2Action: | ||
|
||
"""This class encapsulates the usage of actions from pysc2""" | ||
|
||
def run(action_function, *args) -> FunctionCall: | ||
return action_function(*args) |