Skip to content
Snippets Groups Projects
Commit 09f9cc89 authored by shinedday's avatar shinedday
Browse files

Fix Test : Agent -> test_run

parent d7a336e1
No related branches found
No related tags found
No related merge requests found
......@@ -72,6 +72,12 @@ class Agent:
"""
return self.__environment
def get_phase(self) -> Phase:
"""
return current phase of agent
"""
return self.__phase
def add_neighbour(self, agent: 'Agent') -> None:
"""
add agent into neighbours of current agent
......
......@@ -6,6 +6,7 @@ from unittest import TestCase, main
from pyAmakCore.classes.agent import Agent
from pyAmakCore.classes.amas import Amas
from pyAmakCore.classes.environment import Environment
from pyAmakCore.enumeration.agent_phase import Phase
from pyAmakCore.enumeration.executionPolicy import ExecutionPolicy
......@@ -14,15 +15,38 @@ class TestAgentRun(TestCase):
Test class for Agent run
"""
def test_run(self):
def test_run_one_phase(self):
"""
test that run() work and return correct phase with 1 phase policy
"""
Agent.reset_agent()
environment = Environment()
amas = Amas(environment)
amas.set_execution_policy(ExecutionPolicy.ONE_PHASE)
agent = Agent(amas)
self.assertEqual(agent.get_phase(), Phase.INITIALIZING)
agent.run()
self.assertEqual()
self.assertEqual(agent.get_phase(), Phase.DECISION_AND_ACTION_DONE)
agent.run()
self.assertEqual(agent.get_phase(), Phase.DECISION_AND_ACTION_DONE)
def test_run_two_phase(self):
"""
test that run() work and return correct phase with 2 phase policy
"""
Agent.reset_agent()
environment = Environment()
amas = Amas(environment)
amas.set_execution_policy(ExecutionPolicy.TWO_PHASES)
agent = Agent(amas)
self.assertEqual(agent.get_phase(), Phase.INITIALIZING)
agent.run()
self.assertEqual(agent.get_phase(), Phase.PERCEPTION_DONE)
agent.run()
self.assertEqual(agent.get_phase(), Phase.DECISION_AND_ACTION_DONE)
if __name__ == '__main__':
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment