mirror of
https://github.com/openSUSE/osc.git
synced 2025-08-12 02:04:04 +02:00
Run autopep8 to fix whitespace issues
This commit is contained in:
@@ -26,6 +26,7 @@ class ConfigLineOrder:
|
||||
It keeps track of all lines (including comments) in the _lines list. This list
|
||||
either contains SectionLine() instances or CommentLine() instances.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self._lines = []
|
||||
|
||||
@@ -80,18 +81,22 @@ class ConfigLineOrder:
|
||||
if line.type == 'section':
|
||||
yield line.name
|
||||
|
||||
|
||||
class Line:
|
||||
"""Base class for all line objects"""
|
||||
|
||||
def __init__(self, name, type):
|
||||
self.name = name
|
||||
self.type = type
|
||||
|
||||
|
||||
class SectionLine(Line):
|
||||
"""
|
||||
This class represents a [section]. It stores all lines which belongs to
|
||||
this certain section in the _lines list. The _lines list either contains
|
||||
CommentLine() or OptionLine() instances.
|
||||
"""
|
||||
|
||||
def __init__(self, sectname):
|
||||
super().__init__(sectname, 'section')
|
||||
self._lines = []
|
||||
@@ -154,12 +159,14 @@ class SectionLine(Line):
|
||||
|
||||
class CommentLine(Line):
|
||||
"""Store a commentline"""
|
||||
|
||||
def __init__(self, line):
|
||||
super().__init__(line.strip('\n'), 'comment')
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class OptionLine(Line):
|
||||
"""
|
||||
This class represents an option. The class' ``name`` attribute is used
|
||||
@@ -202,6 +209,7 @@ class OscConfigParser(configparser.ConfigParser):
|
||||
In order to keep the order and the format it makes use of the ConfigLineOrder()
|
||||
class.
|
||||
"""
|
||||
|
||||
def __init__(self, defaults=None):
|
||||
super().__init__(defaults or {})
|
||||
self._sections = ConfigLineOrder()
|
||||
|
@@ -164,8 +164,8 @@ def run(prg, argv=None):
|
||||
except (oscerr.PackageExists, oscerr.PackageMissing, oscerr.WorkingCopyInconsistent) as e:
|
||||
print(e.msg, file=sys.stderr)
|
||||
except oscerr.PackageInternalError as e:
|
||||
print('a package internal error occured\n' \
|
||||
'please file a bug and attach your current package working copy ' \
|
||||
print('a package internal error occured\n'
|
||||
'please file a bug and attach your current package working copy '
|
||||
'and the following traceback to it:', file=sys.stderr)
|
||||
print(e.msg, file=sys.stderr)
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
|
32
osc/build.py
32
osc/build.py
@@ -69,6 +69,7 @@ if hostarch == 'i686': # FIXME
|
||||
if hostarch == 'parisc':
|
||||
hostarch = 'hppa'
|
||||
|
||||
|
||||
class Buildinfo:
|
||||
"""represent the contents of a buildinfo file"""
|
||||
|
||||
@@ -196,7 +197,6 @@ class Buildinfo:
|
||||
else:
|
||||
self.preinstallimage = None
|
||||
|
||||
|
||||
def has_dep(self, name):
|
||||
for i in self.deps:
|
||||
if i.name == name:
|
||||
@@ -215,6 +215,7 @@ class Pac:
|
||||
|
||||
We build a map that's later used to fill our URL templates
|
||||
"""
|
||||
|
||||
def __init__(self, node, buildarch, pacsuffix, apiurl, localpkgs=None):
|
||||
localpkgs = localpkgs or []
|
||||
self.mp = {}
|
||||
@@ -282,7 +283,6 @@ class Pac:
|
||||
# make the content of the dictionary accessible as class attributes
|
||||
self.__dict__.update(self.mp)
|
||||
|
||||
|
||||
def makeurls(self, cachedir, urllist):
|
||||
self.localdir = '%s/%s/%s/%s' % (cachedir, self.project, self.repository, self.repoarch)
|
||||
self.fullfilename = os.path.join(self.localdir, self.canonname)
|
||||
@@ -351,6 +351,7 @@ def get_preinstall_image(apiurl, arch, cache_dir, img_info, offline=False):
|
||||
os.rename(ifile_path_part, ifile_path)
|
||||
return (imagefile, imagesource, img_bins)
|
||||
|
||||
|
||||
def get_built_files(pacdir, buildtype):
|
||||
if buildtype == 'spec':
|
||||
debs_dir = os.path.join(pacdir, 'DEBS')
|
||||
@@ -442,6 +443,7 @@ def get_built_files(pacdir, buildtype):
|
||||
s_built = ''
|
||||
return s_built, b_built
|
||||
|
||||
|
||||
def get_repo(path):
|
||||
"""Walks up path looking for any repodata directories.
|
||||
|
||||
@@ -468,6 +470,7 @@ def get_repo(path):
|
||||
|
||||
return repositoryDirectory
|
||||
|
||||
|
||||
def get_prefer_pkgs(dirs, wanted_arch, type, cpio):
|
||||
paths = []
|
||||
repositories = []
|
||||
@@ -541,6 +544,8 @@ trustprompt = """Would you like to ...
|
||||
1 - always trust packages from '%(project)s'
|
||||
2 - trust packages just this time
|
||||
? """
|
||||
|
||||
|
||||
def check_trusted_projects(apiurl, projects):
|
||||
trusted = config['api_host_options'][apiurl]['trusted_prj']
|
||||
tlen = len(trusted)
|
||||
@@ -560,6 +565,7 @@ def check_trusted_projects(apiurl, projects):
|
||||
config['api_host_options'][apiurl]['trusted_prj'] = trusted
|
||||
conf.config_set_option(apiurl, 'trusted_prj', ' '.join(trusted))
|
||||
|
||||
|
||||
def get_kiwipath_from_buildinfo(bi, prj, repo):
|
||||
# If the project does not have a path defined we need to get the config
|
||||
# via the repositories in the kiwi file. Unfortunately the buildinfo
|
||||
@@ -575,6 +581,7 @@ def get_kiwipath_from_buildinfo(bi, prj, repo):
|
||||
kiwipath.insert(0, myprp)
|
||||
return kiwipath
|
||||
|
||||
|
||||
def calculate_prj_pac(opts, descr):
|
||||
project = opts.alternative_project or store_read_project('.')
|
||||
if opts.local_package:
|
||||
@@ -583,16 +590,19 @@ def calculate_prj_pac(opts, descr):
|
||||
package = store_read_package('.')
|
||||
return project, package
|
||||
|
||||
|
||||
def calculate_build_root(apihost, prj, pac, repo, arch):
|
||||
buildroot = os.environ.get('OSC_BUILD_ROOT', config['build-root']) \
|
||||
% {'repo': repo, 'arch': arch, 'project': prj, 'package': pac, 'apihost': apihost}
|
||||
return buildroot
|
||||
|
||||
|
||||
def build_as_user():
|
||||
if os.environ.get('OSC_SU_WRAPPER', config['su-wrapper']).split():
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def su_wrapper(cmd):
|
||||
sucmd = os.environ.get('OSC_SU_WRAPPER', config['su-wrapper']).split()
|
||||
if sucmd:
|
||||
@@ -604,6 +614,7 @@ def su_wrapper(cmd):
|
||||
cmd = sucmd + cmd
|
||||
return cmd
|
||||
|
||||
|
||||
def run_build(opts, *args):
|
||||
cmd = [config['build-cmd']]
|
||||
cmd += args
|
||||
@@ -614,6 +625,7 @@ def run_build(opts, *args):
|
||||
cmd.append('--norootforbuild')
|
||||
return run_external(cmd[0], *cmd[1:])
|
||||
|
||||
|
||||
def main(apiurl, opts, argv):
|
||||
|
||||
repo = argv[0]
|
||||
@@ -760,7 +772,8 @@ def main(apiurl, opts, argv):
|
||||
for var in ['OSC_PACKAGECACHEDIR', 'OSC_SU_WRAPPER', 'OSC_BUILD_ROOT']:
|
||||
val = os.getenv(var)
|
||||
if val:
|
||||
if var.startswith('OSC_'): var = var[4:]
|
||||
if var.startswith('OSC_'):
|
||||
var = var[4:]
|
||||
var = var.lower().replace('_', '-')
|
||||
if var in config:
|
||||
print('Overriding config value for %s=\'%s\' with \'%s\'' % (var, config[var], val))
|
||||
@@ -990,10 +1003,10 @@ def main(apiurl, opts, argv):
|
||||
if pkg_meta_e:
|
||||
print('ERROR: Either wrong repo/arch as parameter or a parse error of .spec/.dsc/.kiwi file due to syntax error', file=sys.stderr)
|
||||
else:
|
||||
print('The package \'%s\' does not exist - please ' \
|
||||
print('The package \'%s\' does not exist - please '
|
||||
'rerun with \'--local-package\'' % pac, file=sys.stderr)
|
||||
else:
|
||||
print('The project \'%s\' does not exist - please ' \
|
||||
print('The project \'%s\' does not exist - please '
|
||||
'rerun with \'--alternative-project <alternative_project>\'' % prj, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
else:
|
||||
@@ -1143,15 +1156,20 @@ def main(apiurl, opts, argv):
|
||||
if binaries:
|
||||
class mytmpdir:
|
||||
""" temporary directory that removes itself"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.name = mkdtemp(*args, **kwargs)
|
||||
_rmtree = staticmethod(shutil.rmtree)
|
||||
|
||||
def cleanup(self):
|
||||
self._rmtree(self.name)
|
||||
|
||||
def __del__(self):
|
||||
self.cleanup()
|
||||
|
||||
def __exit__(self):
|
||||
self.cleanup()
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
@@ -1418,7 +1436,6 @@ def main(apiurl, opts, argv):
|
||||
if config['build-vm-user']:
|
||||
vm_options += ['--vm-user=' + config['build-vm-user']]
|
||||
|
||||
|
||||
if opts.preload:
|
||||
print("Preload done for selected repo/arch.")
|
||||
sys.exit(0)
|
||||
@@ -1462,7 +1479,8 @@ def main(apiurl, opts, argv):
|
||||
(s_built, b_built) = get_built_files(pacdir, bi.buildtype)
|
||||
|
||||
print()
|
||||
if s_built: print(decode_it(s_built))
|
||||
if s_built:
|
||||
print(decode_it(s_built))
|
||||
print()
|
||||
print(decode_it(b_built))
|
||||
|
||||
|
@@ -11,9 +11,11 @@ class KeyError(Exception):
|
||||
super().__init__()
|
||||
self.args = args
|
||||
self.key = key
|
||||
|
||||
def __str__(self):
|
||||
return '' + self.key + ' :' + ' '.join(self.args)
|
||||
|
||||
|
||||
class Checker:
|
||||
def __init__(self):
|
||||
self.dbdir = mkdtemp(prefix='oscrpmdb')
|
||||
@@ -101,6 +103,7 @@ class Checker:
|
||||
if fd is not None:
|
||||
os.close(fd)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
keyfiles = []
|
||||
|
File diff suppressed because it is too large
Load Diff
11
osc/conf.py
11
osc/conf.py
@@ -82,6 +82,7 @@ def _identify_osccookiejar():
|
||||
|
||||
return os.path.join(osc_state_dir, 'cookiejar')
|
||||
|
||||
|
||||
DEFAULTS = {'apiurl': 'https://api.opensuse.org',
|
||||
'user': None,
|
||||
'pass': None,
|
||||
@@ -492,7 +493,7 @@ def get_apiurl_usr(apiurl):
|
||||
try:
|
||||
return get_apiurl_api_host_options(apiurl)['user']
|
||||
except KeyError:
|
||||
print('no specific section found in config file for host of [\'%s\'] - using default user: \'%s\'' \
|
||||
print('no specific section found in config file for host of [\'%s\'] - using default user: \'%s\''
|
||||
% (apiurl, config['user']), file=sys.stderr)
|
||||
return config['user']
|
||||
|
||||
@@ -634,6 +635,7 @@ def config_set_option(section, opt, val=None, delete=False, update=True, creds_m
|
||||
return (opt, cp.get(section, opt, raw=True))
|
||||
return (opt, None)
|
||||
|
||||
|
||||
def _extract_user_compat(cp, section, creds_mgr):
|
||||
"""
|
||||
This extracts the user either from the ConfigParser or
|
||||
@@ -644,6 +646,7 @@ def _extract_user_compat(cp, section, creds_mgr):
|
||||
user = creds_mgr.get_user(section)
|
||||
return user
|
||||
|
||||
|
||||
def write_initial_config(conffile, entries, custom_template='', creds_mgr_descriptor=None):
|
||||
"""
|
||||
write osc's intial configuration file. entries is a dict which contains values
|
||||
@@ -731,7 +734,7 @@ def get_config(override_conffile=None,
|
||||
|
||||
conffile = os.path.expanduser(conffile)
|
||||
if not os.path.exists(conffile):
|
||||
raise oscerr.NoConfigfile(conffile, \
|
||||
raise oscerr.NoConfigfile(conffile,
|
||||
account_not_configured_text % conffile)
|
||||
|
||||
# okay, we made sure that oscrc exists
|
||||
@@ -867,7 +870,7 @@ def get_config(override_conffile=None,
|
||||
scheme = config.get('scheme', 'https')
|
||||
config['apiurl'] = urljoin(scheme, apisrv)
|
||||
if 'apisrc' in config or 'scheme' in config:
|
||||
print('Warning: Use of the \'scheme\' or \'apisrv\' in oscrc is deprecated!\n' \
|
||||
print('Warning: Use of the \'scheme\' or \'apisrv\' in oscrc is deprecated!\n'
|
||||
'Warning: See README for migration details.', file=sys.stderr)
|
||||
if 'build_platform' in config:
|
||||
print('Warning: Use of \'build_platform\' config option is deprecated! (use \'build_repository\' instead)', file=sys.stderr)
|
||||
@@ -932,6 +935,7 @@ def identify_conf():
|
||||
|
||||
return conffile
|
||||
|
||||
|
||||
def interactive_config_setup(conffile, apiurl, initial=True):
|
||||
scheme = urlsplit(apiurl)[0]
|
||||
http = scheme == "http"
|
||||
@@ -958,6 +962,7 @@ def interactive_config_setup(conffile, apiurl, initial=True):
|
||||
else:
|
||||
add_section(conffile, apiurl, user, passwd, creds_mgr_descriptor=creds_mgr_descr, allow_http=http)
|
||||
|
||||
|
||||
def select_credentials_manager_descr():
|
||||
if not credentials.has_keyring_support():
|
||||
print('To use keyrings please install python%d-keyring.' % sys.version_info.major)
|
||||
|
226
osc/core.py
226
osc/core.py
File diff suppressed because it is too large
Load Diff
@@ -62,6 +62,7 @@ def create_text_meter(*args, **kwargs):
|
||||
return TextMeter(*args, **kwargs)
|
||||
return None
|
||||
|
||||
|
||||
if have_pb_module:
|
||||
TextMeter = PBTextMeter
|
||||
else:
|
||||
|
@@ -4,19 +4,22 @@
|
||||
# either version 2, or (at your option) any later version.
|
||||
|
||||
|
||||
|
||||
class OscBaseError(Exception):
|
||||
def __init__(self, args=()):
|
||||
super().__init__()
|
||||
self.args = args
|
||||
|
||||
def __str__(self):
|
||||
return ''.join(self.args)
|
||||
|
||||
|
||||
class UserAbort(OscBaseError):
|
||||
"""Exception raised when the user requested abortion"""
|
||||
|
||||
|
||||
class ConfigError(OscBaseError):
|
||||
"""Exception raised when there is an error in the config file"""
|
||||
|
||||
def __init__(self, msg, fname):
|
||||
super().__init__()
|
||||
self.msg = msg
|
||||
@@ -25,25 +28,32 @@ class ConfigError(OscBaseError):
|
||||
def __str__(self):
|
||||
return f"Error in config file {self.file}\n {self.msg}"
|
||||
|
||||
|
||||
class ConfigMissingApiurl(ConfigError):
|
||||
"""Exception raised when a apiurl does not exist in the config file"""
|
||||
|
||||
def __init__(self, msg, fname, url):
|
||||
super().__init__(msg, fname)
|
||||
self.url = url
|
||||
|
||||
|
||||
class ConfigMissingCredentialsError(ConfigError):
|
||||
def __init__(self, msg, fname, url):
|
||||
super().__init__(msg, fname)
|
||||
self.url = url
|
||||
|
||||
|
||||
class APIError(OscBaseError):
|
||||
"""Exception raised when there is an error in the output from the API"""
|
||||
|
||||
def __init__(self, msg):
|
||||
super().__init__()
|
||||
self.msg = msg
|
||||
|
||||
|
||||
class NoConfigfile(OscBaseError):
|
||||
"""Exception raised when osc's configfile cannot be found"""
|
||||
|
||||
def __init__(self, fname, msg):
|
||||
super().__init__()
|
||||
self.file = fname
|
||||
@@ -52,22 +62,28 @@ class NoConfigfile(OscBaseError):
|
||||
def __str__(self):
|
||||
return f"Config file cannot be found: {self.file}\n {self.msg}"
|
||||
|
||||
|
||||
class ExtRuntimeError(OscBaseError):
|
||||
"""Exception raised when there is a runtime error of an external tool"""
|
||||
|
||||
def __init__(self, msg, fname):
|
||||
super().__init__()
|
||||
self.msg = msg
|
||||
self.file = fname
|
||||
|
||||
|
||||
class ServiceRuntimeError(OscBaseError):
|
||||
"""Exception raised when the execution of a source service failed"""
|
||||
|
||||
def __init__(self, msg):
|
||||
super().__init__()
|
||||
self.msg = msg
|
||||
|
||||
|
||||
class WrongArgs(OscBaseError):
|
||||
"""Exception raised by the cli for wrong arguments usage"""
|
||||
|
||||
|
||||
class WrongOptions(OscBaseError):
|
||||
"""Exception raised by the cli for wrong option usage"""
|
||||
# def __str__(self):
|
||||
@@ -76,45 +92,57 @@ class WrongOptions(OscBaseError):
|
||||
# s += '\n' + self.args
|
||||
# return s
|
||||
|
||||
|
||||
class NoWorkingCopy(OscBaseError):
|
||||
"""Exception raised when directory is neither a project dir nor a package dir"""
|
||||
|
||||
|
||||
class NotMissing(OscBaseError):
|
||||
"""Exception raised when link target should not exist, but it does"""
|
||||
|
||||
|
||||
class WorkingCopyWrongVersion(OscBaseError):
|
||||
"""Exception raised when working copy's .osc/_osclib_version doesn't match"""
|
||||
|
||||
|
||||
class WorkingCopyOutdated(OscBaseError):
|
||||
"""Exception raised when the working copy is outdated.
|
||||
It takes a tuple with three arguments: path to wc,
|
||||
revision that it has, revision that it should have.
|
||||
"""
|
||||
|
||||
def __str__(self):
|
||||
return ('Working copy \'%s\' is out of date (rev %s vs rev %s).\n'
|
||||
'Looks as if you need to update it first.' \
|
||||
'Looks as if you need to update it first.'
|
||||
% (self.args[0], self.args[1], self.args[2]))
|
||||
|
||||
|
||||
class PackageError(OscBaseError):
|
||||
"""Base class for all Package related exceptions"""
|
||||
|
||||
def __init__(self, prj, pac):
|
||||
super().__init__()
|
||||
self.prj = prj
|
||||
self.pac = pac
|
||||
|
||||
|
||||
class WorkingCopyInconsistent(PackageError):
|
||||
"""Exception raised when the working copy is in an inconsistent state"""
|
||||
|
||||
def __init__(self, prj, pac, dirty_files, msg):
|
||||
super().__init__(prj, pac)
|
||||
self.dirty_files = dirty_files
|
||||
self.msg = msg
|
||||
|
||||
|
||||
class LinkExpandError(PackageError):
|
||||
"""Exception raised when source link expansion fails"""
|
||||
|
||||
def __init__(self, prj, pac, msg):
|
||||
super().__init__(prj, pac)
|
||||
self.msg = msg
|
||||
|
||||
|
||||
class OscIOError(OscBaseError):
|
||||
def __init__(self, e, msg):
|
||||
super().__init__()
|
||||
@@ -133,6 +161,7 @@ class OscInvalidRevision(OscValueError):
|
||||
"""
|
||||
Invalid revision value.
|
||||
"""
|
||||
|
||||
def __str__(self):
|
||||
return "Invalid revision value: {}".format("".join(self.args))
|
||||
|
||||
@@ -141,41 +170,50 @@ class PackageNotInstalled(OscBaseError):
|
||||
"""
|
||||
Exception raised when a package is not installed on local system
|
||||
"""
|
||||
|
||||
def __init__(self, pkg):
|
||||
super().__init__((pkg,))
|
||||
|
||||
def __str__(self):
|
||||
return 'Package %s is required for this operation' % self.args
|
||||
|
||||
|
||||
class SignalInterrupt(Exception):
|
||||
"""Exception raised on SIGTERM and SIGHUP."""
|
||||
|
||||
|
||||
class PackageExists(PackageError):
|
||||
"""
|
||||
Exception raised when a local object already exists
|
||||
"""
|
||||
|
||||
def __init__(self, prj, pac, msg):
|
||||
super().__init__(prj, pac)
|
||||
self.msg = msg
|
||||
|
||||
|
||||
class PackageMissing(PackageError):
|
||||
"""
|
||||
Exception raised when a local object doesn't exist
|
||||
"""
|
||||
|
||||
def __init__(self, prj, pac, msg):
|
||||
super().__init__(prj, pac)
|
||||
self.msg = msg
|
||||
|
||||
|
||||
class PackageFileConflict(PackageError):
|
||||
"""
|
||||
Exception raised when there's a file conflict.
|
||||
Conflict doesn't mean an unsuccessfull merge in this context.
|
||||
"""
|
||||
|
||||
def __init__(self, prj, pac, file, msg):
|
||||
super().__init__(prj, pac)
|
||||
self.file = file
|
||||
self.msg = msg
|
||||
|
||||
|
||||
class PackageInternalError(PackageError):
|
||||
def __init__(self, prj, pac, msg):
|
||||
super().__init__(prj, pac)
|
||||
|
@@ -64,6 +64,7 @@ def xml_equal(actual, exp):
|
||||
|
||||
class RequestWrongOrder(Exception):
|
||||
"""raised if an unexpected request is issued to urllib2"""
|
||||
|
||||
def __init__(self, url, exp_url, method, exp_method):
|
||||
super().__init__()
|
||||
self.url = url
|
||||
@@ -74,8 +75,10 @@ class RequestWrongOrder(Exception):
|
||||
def __str__(self):
|
||||
return '%s, %s, %s, %s' % (self.url, self.exp_url, self.method, self.exp_method)
|
||||
|
||||
|
||||
class RequestDataMismatch(Exception):
|
||||
"""raised if POSTed or PUTed data doesn't match with the expected data"""
|
||||
|
||||
def __init__(self, url, got, exp):
|
||||
self.url = url
|
||||
self.got = got
|
||||
|
@@ -10,9 +10,11 @@ from .common import OscTestCase
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'addfile_fixtures')
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromTestCase(TestAddFiles)
|
||||
|
||||
|
||||
class TestAddFiles(OscTestCase):
|
||||
def _get_fixtures_dir(self):
|
||||
return FIXTURES_DIR
|
||||
@@ -83,5 +85,6 @@ class TestAddFiles(OscTestCase):
|
||||
self.assertRaises(osc.oscerr.OscIOError, p.addfile, 'doesnotexist')
|
||||
self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_added')))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@@ -12,11 +12,14 @@ from .common import GET, PUT, POST, DELETE, OscTestCase
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'commit_fixtures')
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromTestCase(TestCommit)
|
||||
|
||||
|
||||
rev_dummy = '<revision rev="repository">\n <srcmd5>empty</srcmd5>\n</revision>'
|
||||
|
||||
|
||||
class TestCommit(OscTestCase):
|
||||
def _get_fixtures_dir(self):
|
||||
return FIXTURES_DIR
|
||||
@@ -368,5 +371,6 @@ class TestCommit(OscTestCase):
|
||||
self._check_status(p, 'add', '!')
|
||||
self._check_status(p, 'bar', ' ')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@@ -9,9 +9,11 @@ from .common import OscTestCase
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'deletefile_fixtures')
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromTestCase(TestDeleteFiles)
|
||||
|
||||
|
||||
class TestDeleteFiles(OscTestCase):
|
||||
def _get_fixtures_dir(self):
|
||||
return FIXTURES_DIR
|
||||
@@ -205,5 +207,6 @@ class TestDeleteFiles(OscTestCase):
|
||||
self.assertTrue(ret[0] == exp1)
|
||||
self.assertTrue(ret[1] == exp2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@@ -11,11 +11,14 @@ from .common import GET, OscTestCase
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'difffile_fixtures')
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromTestCase(TestDiffFiles)
|
||||
|
||||
|
||||
class TestDiffFiles(OscTestCase):
|
||||
diff_hdr = 'Index: %s\n==================================================================='
|
||||
|
||||
def _get_fixtures_dir(self):
|
||||
return FIXTURES_DIR
|
||||
|
||||
@@ -335,5 +338,6 @@ Binary file 'binary' has changed.
|
||||
exp = __canonise_diff(exp)
|
||||
self.assertEqualMultiline(got, exp)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@@ -6,6 +6,7 @@ from osc.util.helper import decode_it, decode_list
|
||||
def suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromTestCase(TestResults)
|
||||
|
||||
|
||||
class TestResults(unittest.TestCase):
|
||||
def testDecodeList(self):
|
||||
strlist = ['Test1', 'Test2', 'Test3']
|
||||
@@ -21,7 +22,6 @@ class TestResults(unittest.TestCase):
|
||||
out = decode_list(byteslist)
|
||||
self.assertListEqual(out, strlist)
|
||||
|
||||
|
||||
def testDecodeIt(self):
|
||||
bytes_obj = b'Test the decoding'
|
||||
string_obj = 'Test the decoding'
|
||||
@@ -32,6 +32,6 @@ class TestResults(unittest.TestCase):
|
||||
out = decode_it(string_obj)
|
||||
self.assertEqual(out, string_obj)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
|
@@ -9,9 +9,11 @@ from .common import OscTestCase
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'init_package_fixtures')
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromTestCase(TestInitPackage)
|
||||
|
||||
|
||||
class TestInitPackage(OscTestCase):
|
||||
def _get_fixtures_dir(self):
|
||||
# workaround for git because it doesn't allow empty dirs
|
||||
@@ -88,5 +90,6 @@ class TestInitPackage(OscTestCase):
|
||||
f.write('foo\n')
|
||||
self.assertRaises(osc.oscerr.OscIOError, osc.core.Package.init_package, 'http://localhost', 'osctest', 'testpkg', pac_dir)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@@ -10,9 +10,11 @@ from .common import GET, OscTestCase
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'init_project_fixtures')
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromTestCase(TestInitProject)
|
||||
|
||||
|
||||
class TestInitProject(OscTestCase):
|
||||
def _get_fixtures_dir(self):
|
||||
# workaround for git because it doesn't allow empty dirs
|
||||
@@ -70,5 +72,6 @@ class TestInitProject(OscTestCase):
|
||||
self._check_list(os.path.join(storedir, '_apiurl'), 'http://localhost\n')
|
||||
self.assertFalse(os.path.exists(os.path.join(storedir, '_packages')))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@@ -9,9 +9,11 @@ from .common import OscTestCase
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'project_package_status_fixtures')
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromTestCase(TestPackageStatus)
|
||||
|
||||
|
||||
class TestPackageStatus(OscTestCase):
|
||||
def _get_fixtures_dir(self):
|
||||
return FIXTURES_DIR
|
||||
@@ -84,5 +86,6 @@ class TestPackageStatus(OscTestCase):
|
||||
st = p.get_status(True)
|
||||
self.assertEqual(exp_st, st)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@@ -14,10 +14,12 @@ FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'prdiff_fixtures')
|
||||
UPSTREAM = 'some:project'
|
||||
BRANCH = 'home:user:branches:' + UPSTREAM
|
||||
|
||||
|
||||
def rdiff_url(pkg, oldprj, newprj):
|
||||
return 'http://localhost/source/%s/%s?unified=1&opackage=%s&oproject=%s&cmd=diff&expand=1&tarlimit=0&filelimit=0' % \
|
||||
(newprj, pkg, pkg, oldprj.replace(':', '%3A'))
|
||||
|
||||
|
||||
def request_url(prj):
|
||||
return 'http://localhost/search/request?match=%%28state%%2F%%40name%%3D%%27new%%27+or+state%%2F%%40name%%3D%%27review%%27%%29+and+%%28action%%2Ftarget%%2F%%40project%%3D%%27%s%%27+or+action%%2Fsource%%2F%%40project%%3D%%27%s%%27%%29' % \
|
||||
tuple([prj.replace(':', '%3A')] * 2)
|
||||
@@ -45,8 +47,10 @@ def POST_RDIFF(oldprj, newprj):
|
||||
def suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromTestCase(TestProjectDiff)
|
||||
|
||||
|
||||
class TestProjectDiff(OscTestCase):
|
||||
diff_hdr = 'Index: %s\n==================================================================='
|
||||
|
||||
def _get_fixtures_dir(self):
|
||||
return FIXTURES_DIR
|
||||
|
||||
@@ -61,13 +65,11 @@ class TestProjectDiff(OscTestCase):
|
||||
cli.main(argv=argv)
|
||||
return sys.stdout.getvalue()
|
||||
|
||||
|
||||
def testPrdiffTooManyArgs(self):
|
||||
def runner():
|
||||
self._run_prdiff('one', 'two', 'superfluous-arg')
|
||||
self.assertRaises(osc.oscerr.WrongArgs, runner)
|
||||
|
||||
|
||||
@GET_PROJECT_PACKAGES(UPSTREAM, BRANCH)
|
||||
@POST_RDIFF(UPSTREAM, BRANCH)
|
||||
@POST(rdiff_url('only-in-new', UPSTREAM, BRANCH), exp='', text='')
|
||||
@@ -77,6 +79,7 @@ differs: common-two
|
||||
identical: common-three
|
||||
identical: only-in-new
|
||||
"""
|
||||
|
||||
def runner():
|
||||
self._run_prdiff()
|
||||
|
||||
@@ -90,7 +93,6 @@ identical: only-in-new
|
||||
out = self._run_prdiff()
|
||||
self.assertEqualMultiline(out, exp)
|
||||
|
||||
|
||||
@GET_PROJECT_PACKAGES(UPSTREAM, BRANCH)
|
||||
@POST_RDIFF(UPSTREAM, BRANCH)
|
||||
@POST(rdiff_url('only-in-new', UPSTREAM, BRANCH), exp='', text='')
|
||||
@@ -104,7 +106,6 @@ identical: only-in-new
|
||||
out = self._run_prdiff('home:user:branches:some:project')
|
||||
self.assertEqualMultiline(out, exp)
|
||||
|
||||
|
||||
@GET_PROJECT_PACKAGES('old:prj', 'new:prj')
|
||||
@POST_RDIFF('old:prj', 'new:prj')
|
||||
def testPrdiffTwoArgs(self):
|
||||
@@ -116,7 +117,6 @@ identical: common-three
|
||||
out = self._run_prdiff('old:prj', 'new:prj')
|
||||
self.assertEqualMultiline(out, exp)
|
||||
|
||||
|
||||
@GET_PROJECT_PACKAGES('old:prj', 'new:prj')
|
||||
@POST_RDIFF('old:prj', 'new:prj')
|
||||
def testPrdiffOldOnly(self):
|
||||
@@ -129,7 +129,6 @@ old only: only-in-old
|
||||
out = self._run_prdiff('--show-not-in-new', 'old:prj', 'new:prj')
|
||||
self.assertEqualMultiline(out, exp)
|
||||
|
||||
|
||||
@GET_PROJECT_PACKAGES('old:prj', 'new:prj')
|
||||
@POST_RDIFF('old:prj', 'new:prj')
|
||||
def testPrdiffNewOnly(self):
|
||||
@@ -142,7 +141,6 @@ new only: only-in-new
|
||||
out = self._run_prdiff('--show-not-in-old', 'old:prj', 'new:prj')
|
||||
self.assertEqualMultiline(out, exp)
|
||||
|
||||
|
||||
@GET_PROJECT_PACKAGES('old:prj', 'new:prj')
|
||||
@POST_RDIFF('old:prj', 'new:prj')
|
||||
def testPrdiffDiffstat(self):
|
||||
@@ -158,7 +156,6 @@ identical: common-three
|
||||
out = self._run_prdiff('--diffstat', 'old:prj', 'new:prj')
|
||||
self.assertEqualMultiline(out, exp)
|
||||
|
||||
|
||||
@GET_PROJECT_PACKAGES('old:prj', 'new:prj')
|
||||
@POST_RDIFF('old:prj', 'new:prj')
|
||||
def testPrdiffUnified(self):
|
||||
@@ -182,7 +179,6 @@ identical: common-three
|
||||
out = self._run_prdiff('--unified', 'old:prj', 'new:prj')
|
||||
self.assertEqualMultiline(out, exp)
|
||||
|
||||
|
||||
@GET_PROJECT_PACKAGES('old:prj', 'new:prj')
|
||||
@POST(rdiff_url('common-two', 'old:prj', 'new:prj'), exp='', file='common-two-diff')
|
||||
@POST(rdiff_url('common-three', 'old:prj', 'new:prj'), exp='', text='')
|
||||
@@ -195,7 +191,6 @@ identical: common-three
|
||||
'old:prj', 'new:prj')
|
||||
self.assertEqualMultiline(out, exp)
|
||||
|
||||
|
||||
@GET_PROJECT_PACKAGES('old:prj', 'new:prj')
|
||||
@POST(rdiff_url('common-two', 'old:prj', 'new:prj'), exp='', file='common-two-diff')
|
||||
@POST(rdiff_url('common-three', 'old:prj', 'new:prj'), exp='', text='')
|
||||
@@ -207,7 +202,6 @@ identical: common-three
|
||||
out = self._run_prdiff('--exclude', 'one', 'old:prj', 'new:prj')
|
||||
self.assertEqualMultiline(out, exp)
|
||||
|
||||
|
||||
@GET_PROJECT_PACKAGES('old:prj', 'new:prj')
|
||||
@POST(rdiff_url('common-two', 'old:prj', 'new:prj'), exp='', file='common-two-diff')
|
||||
def testPrdiffIncludeExclude(self):
|
||||
@@ -219,7 +213,6 @@ identical: common-three
|
||||
'old:prj', 'new:prj')
|
||||
self.assertEqualMultiline(out, exp)
|
||||
|
||||
|
||||
@GET_PROJECT_PACKAGES(UPSTREAM, BRANCH)
|
||||
@GET(request_url(UPSTREAM), exp='', file='request')
|
||||
@POST(rdiff_url('common-one', UPSTREAM, BRANCH), exp='', text='')
|
||||
@@ -241,8 +234,8 @@ identical: only-in-new
|
||||
out = self._run_prdiff('--requests', UPSTREAM, BRANCH)
|
||||
self.assertEqualMultiline(out, exp)
|
||||
|
||||
|
||||
# Reverse the direction of the diff.
|
||||
|
||||
@GET_PROJECT_PACKAGES(BRANCH, UPSTREAM)
|
||||
@GET(request_url(BRANCH), exp='', file='no-requests')
|
||||
@POST(rdiff_url('common-one', BRANCH, UPSTREAM), exp='', text='')
|
||||
@@ -260,6 +253,5 @@ identical: only-in-new
|
||||
self.assertEqualMultiline(out, exp)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@@ -9,9 +9,11 @@ from .common import OscTestCase
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'project_package_status_fixtures')
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromTestCase(TestProjectStatus)
|
||||
|
||||
|
||||
class TestProjectStatus(OscTestCase):
|
||||
def _get_fixtures_dir(self):
|
||||
return FIXTURES_DIR
|
||||
@@ -159,5 +161,6 @@ class TestProjectStatus(OscTestCase):
|
||||
p = prj.get_pacobj('doesnotexist')
|
||||
self.assertTrue(isinstance(p, type(None)))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@@ -12,9 +12,11 @@ from .common import GET, PUT, POST, DELETE, OscTestCase
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'repairwc_fixtures')
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromTestCase(TestRepairWC)
|
||||
|
||||
|
||||
class TestRepairWC(OscTestCase):
|
||||
def _get_fixtures_dir(self):
|
||||
return FIXTURES_DIR
|
||||
|
@@ -10,9 +10,11 @@ from .common import OscTestCase
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'request_fixtures')
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromTestCase(TestRequest)
|
||||
|
||||
|
||||
class TestRequest(OscTestCase):
|
||||
def _get_fixtures_dir(self):
|
||||
return FIXTURES_DIR
|
||||
@@ -565,5 +567,6 @@ Comment: <no comment>"""
|
||||
self.assertTrue(len(r.get_actions('submit', 'delete', 'change_devel')) == 5)
|
||||
self.assertTrue(len(r.get_actions()) == 8)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@@ -10,6 +10,7 @@ from .common import GET, OscTestCase
|
||||
def suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromTestCase(TestResults)
|
||||
|
||||
|
||||
class TestResults(OscTestCase):
|
||||
def setUp(self):
|
||||
super().setUp(copytree=False)
|
||||
@@ -50,6 +51,6 @@ class TestResults(OscTestCase):
|
||||
out = self._run_osc('results', '--watch', '--xml', 'testproject', 'python-MarkupSafe')
|
||||
self.assertEqualMultiline(out, self._get_fixture('result-dirty.xml') + self._get_fixture('result.xml'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
|
@@ -9,9 +9,11 @@ from .common import OscTestCase
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'revertfile_fixtures')
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromTestCase(TestRevertFiles)
|
||||
|
||||
|
||||
class TestRevertFiles(OscTestCase):
|
||||
def _get_fixtures_dir(self):
|
||||
return FIXTURES_DIR
|
||||
@@ -95,5 +97,6 @@ class TestRevertFiles(OscTestCase):
|
||||
self.assertTrue(os.path.exists(storefile))
|
||||
self.assertFilesEqual(fname, storefile)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@@ -9,9 +9,11 @@ from .common import GET, PUT, OscTestCase
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'setlinkrev_fixtures')
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromTestCase(TestSetLinkRev)
|
||||
|
||||
|
||||
class TestSetLinkRev(OscTestCase):
|
||||
def setUp(self):
|
||||
super().setUp(copytree=False)
|
||||
@@ -89,5 +91,6 @@ class TestSetLinkRev(OscTestCase):
|
||||
"""delete non existent rev attribute from link xml"""
|
||||
osc.core.set_link_rev('http://localhost', 'osctest', 'simple', revision=None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@@ -10,9 +10,11 @@ from .common import GET, OscTestCase
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'update_fixtures')
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromTestCase(TestUpdate)
|
||||
|
||||
|
||||
class TestUpdate(OscTestCase):
|
||||
def _get_fixtures_dir(self):
|
||||
return FIXTURES_DIR
|
||||
@@ -285,5 +287,6 @@ class TestUpdate(OscTestCase):
|
||||
self.assertFalse(os.path.exists(os.path.join('.osc', 'added')))
|
||||
self._check_digests('testUpdateResumeDeletedFile_files')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Reference in New Issue
Block a user