1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
# vim: set fileencoding=utf-8 :
#
# (C) 2012 Intel Corporation <markus.lehtonen@linux.intel.com>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, please see
# <http://www.gnu.org/licenses/>
"""Test module for RPM command line tools of the git-buildpackage suite"""
import os
import shutil
from glob import glob
from gbp.command_wrappers import Command
from tests.component import ComponentTestBase, ComponentTestGitRepository
RPM_TEST_DATA_SUBMODULE = os.path.join('tests', 'component', 'rpm', 'data')
RPM_TEST_DATA_DIR = os.path.abspath(RPM_TEST_DATA_SUBMODULE)
def setup_module():
"""Test Module setup"""
ComponentTestGitRepository.check_testdata(RPM_TEST_DATA_SUBMODULE)
class RpmRepoTestBase(ComponentTestBase):
"""Baseclass for tests run in a Git repository with packaging data"""
@classmethod
def setUpClass(cls):
"""Initializations only made once per test run"""
super(RpmRepoTestBase, cls).setUpClass()
# Initialize test data repositories
cmd = Command('./manage.py', cwd=RPM_TEST_DATA_DIR, capture_stderr=True)
cmd(['import-repo', '-o', cls._tmproot])
cls.orig_repos = {}
for path in glob(cls._tmproot + '/*.repo'):
prj = os.path.basename(path).rsplit('.', 1)[0]
cls.orig_repos[prj] = ComponentTestGitRepository(path)
@classmethod
def init_test_repo(cls, pkg_name):
"""Initialize git repository for testing"""
dirname = os.path.basename(cls.orig_repos[pkg_name].path)
shutil.copytree(cls.orig_repos[pkg_name].path, dirname)
os.chdir(dirname)
return ComponentTestGitRepository('.')
init_test_repo.__test__ = False
# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·:
|