Exemple #1
0
 def test_check_status(self, print_mock, get_mock):
     # pylint: disable=unused-argument
     # NOTE(ralonsoh): the pylint exception must be removed. The mocked
     # command call must be tested.
     task_id = str(uuid.uuid4())
     get_mock.return_value = {'status': 2, 'result': 'error'}
     status = EnvCommand()._check_status(task_id, 'hello world')
     self.assertEqual(status, 2)
Exemple #2
0
 def test_print_status(self):
     try:
         EnvCommand()._print_status('hello', 'word')
     except Exception as e:  # pylint: disable=broad-except
         # NOTE(ralonsoh): try to reduce the scope of this exception.
         self.assertIsInstance(e, IndexError)
Exemple #3
0
 def test_start_async_task(self, post_mock):
     data = {'action': 'create_grafana'}
     EnvCommand()._start_async_task(data)
     post_mock.assert_called_once()
Exemple #4
0
 def test_do_prepare(self, check_status_mock, start_async_task_mock):
     env = EnvCommand()
     env.do_prepare({})
     start_async_task_mock.assert_called_once()
     check_status_mock.assert_called_once()
Exemple #5
0
 def test_print_status(self):
     try:
         EnvCommand()._print_status('hello', 'word')
     except Exception as e:
         self.assertIsInstance(e, IndexError)
Exemple #6
0
 def test_check_status(self, print_mock, get_mock):
     task_id = str(uuid.uuid4())
     get_mock.return_value = {'status': 2, 'result': 'error'}
     status = EnvCommand()._check_status(task_id, 'hello world')
     self.assertEqual(status, 2)
Exemple #7
0
 def test_start_async_task(self, post_mock):
     data = {'action': 'createGrafanaContainer'}
     EnvCommand()._start_async_task(data)
     self.assertTrue(post_mock.called)
Exemple #8
0
 def test_do_prepare(self, check_status_mock, start_async_task_mock):
     env = EnvCommand()
     env.do_prepare({})
     self.assertTrue(start_async_task_mock.called)
     self.assertTrue(check_status_mock.called)