Tooling for converting coverage data into a SQL DB
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.5 KiB

# Copyright 2016 Hewlett Packard Enterprise Development LP
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import testscenarios
from coverage2sql.db import api
from coverage2sql.tests import base
from coverage2sql.tests import coverage2sql_fixtures as fixtures
from coverage2sql.tests import db_test_utils
load_tests = testscenarios.load_tests_apply_scenarios
class TestDatabaseAPI(base.TestCase):
scenarios = [
('mysql', {'dialect': 'mysql'}),
('postgresql', {'dialect': 'postgres'}),
('sqlite', {'dialect': 'sqlite'})
def setUp(self):
super(TestDatabaseAPI, self).setUp()
if not db_test_utils.is_backend_avail(self.dialect):
raise self.skipTest('%s is not available' % self.dialect)
if self.dialect == 'mysql':
elif self.dialect == 'postgres':
elif self.dialect == 'sqlite':
def test_create_coverage(self):
cov = api.create_coverage('foo_project')
self.assertTrue(cov is not None)
self.assertEqual(cov.project_name, 'foo_project')
def test_get_coverage_all(self):
covs = api.get_coverage()
self.assertTrue(covs is not None)
self.assertEqual(len(covs), 2)
names = [n.project_name for n in covs]
self.assertIn(needle='foo1_project', haystack=names)
self.assertIn(needle='foo2_project', haystack=names)
def test_get_coverage_with_projenct_name(self):
covs = api.get_coverage(project_name='foo1_project')
self.assertTrue(covs is not None)
self.assertEqual(len(covs), 1)
self.assertEqual(covs[0].project_name, 'foo1_project')