HCE Project Python language Distributed Tasks Manager Application, Distributed Crawler Application and client API bindings.  2.0.0-chaika
Hierarchical Cluster Engine Python language binding
tests.test_drce_CommandExecutor.TestCommandExecutor Class Reference
Inheritance diagram for tests.test_drce_CommandExecutor.TestCommandExecutor:
Collaboration diagram for tests.test_drce_CommandExecutor.TestCommandExecutor:

Public Member Functions

def setUp (self)
 
def teEst_execute_request (self)
 
def test_let_out_timeout_exception (self)
 
def test_catch_convert_exception_msg_format (self)
 
def test_catch_convert_exception_cmd_format (self)
 

Public Attributes

 connect_mock
 
 cmd_executor
 

Detailed Description

Definition at line 25 of file test_drce_CommandExecutor.py.

Member Function Documentation

◆ setUp()

def tests.test_drce_CommandExecutor.TestCommandExecutor.setUp (   self)

Definition at line 28 of file test_drce_CommandExecutor.py.

28  def setUp(self):
29  self.connect_mock = MagicMock(spec=Connection)
30  self.cmd_executor = CommandExecutor(self.connect_mock, CommandConvertor())
31 
32 

◆ teEst_execute_request()

def tests.test_drce_CommandExecutor.TestCommandExecutor.teEst_execute_request (   self)

Definition at line 33 of file test_drce_CommandExecutor.py.

33  def teEst_execute_request(self):
34  response = Response([
35  "1",
36  """
37  {
38  "error_code":0,
39  "error_message" :"msg",
40  "time":10,
41  "state":1,
42  "pid":101,
43  "data":[
44  {"files":[{"name":"f1", "data":"data1", "action":12}],
45  "stdout":"out",
46  "stderror":"error",
47  "exit_status":5,
48  "node":"n1",
49  "time":100
50  }
51  ]
52  }
53  """ ])
54 
55  connect_mock_cfg = {"send.return_value": None,
56  "recv.return_value": response}
57  self.connect_mock.configure_mock(**connect_mock_cfg)
58 
59  #check
60  connect_expect_calls = [call.send(ANY), call.recv(ANY)]
61 
62  task_request = TaskCheckRequest("task_id", consts.EXTEND_STATUS_INFO)
63  task_response = self.cmd_executor.execute(task_request)
64 
65  self.connect_mock.assert_has_calls(connect_expect_calls)
66 
67  test_err_str = "json parsing is failed"
68  self.assertEqual(task_response.error_code, 0, test_err_str)
69  self.assertEqual(task_response.error_msg, "msg", test_err_str )
70  self.assertEqual(task_response.state, 1, test_err_str)
71  self.assertEqual(len(task_response.data), 1, test_err_str)
72  self.assertEqual(task_response.pid, 101, test_err_str)
73 
74 
75 
def execute(self, commands, nodes)
execute method execute incoming commands on nodes, keepts reult in responses and responsesDicts field...
Definition: NodeManager.py:63
Here is the call graph for this function:

◆ test_catch_convert_exception_cmd_format()

def tests.test_drce_CommandExecutor.TestCommandExecutor.test_catch_convert_exception_cmd_format (   self)

Definition at line 96 of file test_drce_CommandExecutor.py.

96  def test_catch_convert_exception_cmd_format(self):
97  self.connect_mock.send.return_value = None
98  self.connect_mock.recv.side_effect = CommandConvertorError("Boom")
99 
100  task_request = TaskCheckRequest("task_id", consts.EXTEND_STATUS_INFO)
101 
102  with self.assertRaises(CommandExecutorErr):
103  list(self.cmd_executor.execute(task_request))
104 
def execute(self, commands, nodes)
execute method execute incoming commands on nodes, keepts reult in responses and responsesDicts field...
Definition: NodeManager.py:63
Here is the call graph for this function:

◆ test_catch_convert_exception_msg_format()

def tests.test_drce_CommandExecutor.TestCommandExecutor.test_catch_convert_exception_msg_format (   self)

Definition at line 86 of file test_drce_CommandExecutor.py.

86  def test_catch_convert_exception_msg_format(self):
87  self.connect_mock.send.return_value = None
88  self.connect_mock.recv.side_effect = ResponseFormatErr("Boom")
89 
90  task_request = TaskCheckRequest("task_id", consts.EXTEND_STATUS_INFO)
91 
92  with self.assertRaises(CommandExecutorErr):
93  list(self.cmd_executor.execute(task_request))
94 
95 
def execute(self, commands, nodes)
execute method execute incoming commands on nodes, keepts reult in responses and responsesDicts field...
Definition: NodeManager.py:63
Here is the call graph for this function:

◆ test_let_out_timeout_exception()

def tests.test_drce_CommandExecutor.TestCommandExecutor.test_let_out_timeout_exception (   self)

Definition at line 76 of file test_drce_CommandExecutor.py.

76  def test_let_out_timeout_exception(self):
77  self.connect_mock.send.return_value = None
78  self.connect_mock.recv.side_effect = ConnectionTimeout("Boom")
79  task_request = TaskCheckRequest("task_id", consts.EXTEND_STATUS_INFO)
80 
81  with self.assertRaises(ConnectionTimeout):
82  list(self.cmd_executor.execute(task_request))
83 
84 
85 
def execute(self, commands, nodes)
execute method execute incoming commands on nodes, keepts reult in responses and responsesDicts field...
Definition: NodeManager.py:63
Here is the call graph for this function:

Member Data Documentation

◆ cmd_executor

tests.test_drce_CommandExecutor.TestCommandExecutor.cmd_executor

Definition at line 30 of file test_drce_CommandExecutor.py.

◆ connect_mock

tests.test_drce_CommandExecutor.TestCommandExecutor.connect_mock

Definition at line 29 of file test_drce_CommandExecutor.py.


The documentation for this class was generated from the following file: