Exemplo n.º 1
0
 def test_timerfunc_list(self, mock_test_list, mock_TestManager_run):
     cpulse = utils.get_cpulse_test()
     cpulse_obj = [objects.Cpulse(self.context, **cpulse)]
     mock_test_list.return_value = cpulse_obj
     timerthread.timerfunc()
     time.sleep(1)
     self.assertTrue(mock_TestManager_run.not_called)
Exemplo n.º 2
0
 def test_cpulse_getone_by_uuid(self, mock_get_by_uuid, mock_test_show):
     cpulse = utils.get_cpulse_test()
     cpulse_obj = objects.Cpulse(self.context, **cpulse)
     mock_get_by_uuid.return_value = cpulse_obj
     uuid = cpulse.get('uuid')
     response = self.app.get('/cpulse/%s' % uuid)
     self.assertEqual(response.status_int, 200)
Exemplo n.º 3
0
 def test_cpulse_delete_by_uuid(self, mock_get_by_uuid, mock_test_delete):
     cpulse = utils.get_cpulse_test()
     cpulse_obj = objects.Cpulse(self.context, **cpulse)
     mock_get_by_uuid.return_value = cpulse_obj
     uuid = cpulse.get('uuid')
     response = self.app.delete('/cpulse/%s' % uuid)
     mock_test_delete.assert_called_once_with(mock.ANY, uuid)
     self.assertEqual(response.status_int, 204)
Exemplo n.º 4
0
 def test_cpulse_create(self):
     with mock.patch.object(self.dbapi, 'create_test',
                            autospec=True) as mock_create_test:
         mock_create_test.return_value = self.cpulsetest
         cpulse = objects.Cpulse(self.context, **self.cpulsetest)
         cpulse.create()
         mock_create_test.assert_called_once_with(self.cpulsetest)
         self.assertEqual(self.context, cpulse._context)
Exemplo n.º 5
0
 def test_timerfunc_list_manual_test(self, mock_test_list,
                                     mock_TestManager_run):
     cpulse = utils.get_cpulse_test()
     cpulse['testtype'] = 'manual'
     cpulse_obj = [objects.Cpulse(self.context, **cpulse)]
     mock_test_list.return_value = cpulse_obj
     timerthread.timerfunc()
     time.sleep(1)
     mock_TestManager_run.assert_called_once_with(test=cpulse_obj[0])
Exemplo n.º 6
0
 def test_cpulse_getall_tests(self, mock_test_list, mock_test_show):
     cpulse = utils.get_cpulse_test()
     cpulse_obj = [objects.Cpulse(self.context, **cpulse)]
     mock_test_list.return_value = cpulse_obj
     mock_test_show.return_value = cpulse_obj[0]
     response = self.app.get('/cpulse')
     self.assertEqual(response.status_int, 200)
     unittest_cpulses = response.json['cpulses']
     self.assertEqual(len(unittest_cpulses), 1)
     self.assertEqual(unittest_cpulses[0].get('uuid'), cpulse['uuid'])
Exemplo n.º 7
0
 def create_task_entry(self, context):
     test = {}
     test['state'] = 'scheduled'
     test['testtype'] = 'periodic'
     test['name'] = self.task
     test['uuid'] = utils.generate_uuid()
     new_test = objects.Cpulse(context, **test)
     with cpulse_lock.thread_lock(new_test, self.conductor_id):
         LOG.info(('Creating db entry for the test %s') % test['name'])
         new_test.create()
     return new_test
Exemplo n.º 8
0
    def post(self, test):
        """Create a new test.

        :param test: a test within the request body.
        """

        test_dict = test.as_dict()
        context = pecan.request.context
        auth_token = context.auth_token_info['token']
        test_dict['project_id'] = auth_token['project']['id']
        test_dict['user_id'] = auth_token['user']['id']
        ncp = objects.Cpulse(context, **test_dict)
        ncp.cpulse_create_timeout = 0
        ncp.result = "NotYetRun"
        ncp.testtype = "manual"
        ncp.state = 'scheduled'
        res_test = pecan.request.rpcapi.test_create(ncp,
                                                    ncp.cpulse_create_timeout)

        return Cpulse.convert_with_links(res_test)