def test_setup_config(self): tmc = TempestMailCmd() tmc.parse_arguments([ '-c', 'tests/fixtures/config.yaml', '--job', 'periodic-tripleo-ci-centos-7-ovb-nonha-tempest-' 'oooq-master', '--file', 'tests/fixtures/not_found.log', '--skip-file', self.tmp_file ]) tmc.setup_logging() tmc.setupConfig() config = tmc.config self.assertEqual(config.require_auth, True) self.assertEqual(config.mail_from, '*****@*****.**') self.assertEqual(config.templates_path, 'template/') self.assertEqual(config.log_url, 'http://logs.openstack.org/periodic/') self.assertEqual( config.api_server, 'http://tempest-tripleoci.rhcloud.com/api/v1.0/sendmail') self.assertEqual(config.use_api_server, True) self.assertEqual(config.default_log_url, 'http://logs.openstack.org')
def test_load_skip_file(self): tmc = TempestMailCmd() tmc.parse_arguments([ '-c', 'tests/fixtures/config.yaml', '--job', 'periodic-tripleo-ci-centos-7-ovb-nonha-tempest-' 'oooq-master', '--file', 'tests/fixtures/not_found.log', '--skip-file', self.tmp_file ]) tmc.setup_logging() tmc.setupConfig() result = tmc.load_skip_file(self.tmp_file) expected = [{ 'test': '.*test_external_network_visibility', 'reason': 'Tempest test "external network visibility" fails' }, { 'test': 'tempest.api.data_processing', 'reason': 'tempest.api.data_processing tests failing on newton' }, { 'test': 'neutron.tests.tempest.api.test_revisions.TestRevisions', 'reason': 'New test, need investigation' }] self.assertEquals(result, expected) tmc.parse_arguments([ '-c', 'tests/fixtures/config.yaml', '--job', 'periodic-tripleo-ci-centos-7-ovb-nonha-tempest-' 'oooq-master', '--file', 'tests/fixtures/not_found.log', '--skip-file', 'non_exist_file.txt' ]) result = tmc.load_skip_file(self.tmp_file) self.assertEquals(result, [])
def test_get_data(self): tmc = TempestMailCmd() tmc.parse_arguments([ '-c', 'tests/fixtures/config.yaml', '--job', 'periodic-tripleo-ci-centos-7-ovb-nonha-tempest-' 'oooq-master', '--file', 'tests/fixtures/not_found.log' ]) tmc.setup_logging() tmc.setupConfig() data = tmc.get_data(self.console_ok, None, 'http://logs.openstack.org') self.assertEquals( data['job'], 'periodic-tripleo-ci-centos-7-ovb-nonha-tempest-oooq-master') self.assertEquals(data['date'], None) self.assertEquals(data['run'], True) self.assertEquals(data['link'], 'http://logs.openstack.org') self.assertEquals(len(data['ok']), 99) self.assertEquals(data.get('failed'), None) self.assertEquals(data.get('covered'), None) self.assertEquals(data.get('new'), None) self.assertEquals(data.get('errors'), None) data = tmc.get_data('some content', None, 'http://logs.openstack.org') self.assertEquals(data['run'], False) data = tmc.get_data(self.console_fail, None, 'http://logs.openstack.org') self.assertNotEquals(data['failed'], None)
def test_get_console(self, html_mock): tmc = TempestMailCmd() tmc.parse_arguments([ '-c', 'tests/fixtures/config.yaml', '--job', 'periodic-tripleo-ci-centos-7-ovb-nonha-tempest-' 'oooq-master', '--file', 'tests/fixtures/console_ok.log' ]) tmc.setup_logging() tmc.setupConfig() console, date, log_path = tmc.get_console() self.assertEquals(console, self.console_ok) self.assertEquals( log_path, 'Not available yet. ' 'Check https://logs.openstack.org') tmc.parse_arguments([ '-c', 'tests/fixtures/config.yaml', '--job', 'periodic-tripleo-ci-centos-7-ovb-nonha-tempest-' 'oooq-master', '--file', 'tests/fixtures/not_found.log' ]) self.assertEquals(tmc.get_console(), (None, None, None)) html_mock.return_value.status_code = '300' result = tmc.get_console(job_url='http://logs.openstack.org') self.assertEquals(result, (None, None, None)) html_mock.return_value.status_code = '200' html_mock.return_value.content = self.console_ok console, date, url = tmc.get_console( job_url='http://logs.openstack.org') self.assertEquals(console, self.console_ok.decode('utf-8')) self.assertEquals(url, 'http://logs.openstack.org/console.html.gz') html_mock.return_value = None result = tmc.get_console(job_url='http://logs.openstack.org') self.assertEquals(result, (None, None, None))
def test_get_index(self, html_mock): tmc = TempestMailCmd() tmc.parse_arguments([ '-c', 'tests/fixtures/config.yaml', '--job', 'periodic-tripleo-ci-centos-7-ovb-nonha-tempest-' 'oooq-master' ]) tmc.setup_logging() tmc.setupConfig() html_mock.return_value.content.decode.return_value = self.content_job.decode( ) index = tmc.get_index() self.assertEquals(index, [(u'http://logs.openstack.org/periodic/perio' 'dic-tripleo-ci-centos-7-ovb-nonha-tempest-' 'oooq-master/613de4e/')]) html_mock.return_value.content.decode.return_value = 'No links' index = tmc.get_index() self.assertEquals(index, []) html_mock.return_value = None index = tmc.get_index() self.assertEquals(index, []) html_mock.ok.return_value = None index = tmc.get_index() self.assertEquals(index, []) html_mock.ok.return_value = True html_mock.content.return_value = None index = tmc.get_index() self.assertEquals(index, [])