Permalink
Browse files

Merge branch 'master' into bf-docker-fixture

allowing tests.utils.skip_ssh to be used as both a function and a decorator
  • Loading branch information...
chaselgrove committed Nov 21, 2017
2 parents 9a6ca6f + 7f0d367 commit 195fc464c72c66d3a74f11f26a1186c31ba6a423
View
@@ -15,8 +15,8 @@ matrix:
- python: 2.7
# no loop dev support on travis yet :-/ https://github.com/travis-ci/travis-ci/issues/2700
#- python: 2.7
# env:
# - NOSE_WRAPPER="tools/eval_under_testloopfs"
env:
- NICEMAN_TESTS_SSH=1
- python: 2.7
# By default no logs will be output. This one is to test with log output at INFO level
env:
@@ -34,6 +34,8 @@ matrix:
- https_proxy=
- python: 3.4
- python: 3.5
env:
- NICEMAN_TESTS_SSH=1
# Those aren't yet ready since lxml Ibelieve fails to install
#- python: pypy
#- python: pypy3
@@ -74,23 +74,23 @@ class APTSource(SpecObject):
_register_with_representer(APTSource)
@attr.s(slots=True)
@attr.s(slots=True, frozen=True, cmp=False, hash=True)
class DEBPackage(Package):
"""Debian package information"""
name = attr.ib()
# Optional
upstream_name = attr.ib(default=None)
version = attr.ib(default=None)
architecture = attr.ib(default=None)
source_name = attr.ib(default=None)
source_version = attr.ib(default=None)
size = attr.ib(default=None)
md5 = attr.ib(default=None)
sha1 = attr.ib(default=None)
sha256 = attr.ib(default=None)
versions = attr.ib(default=None) # Hash ver_str -> [Array of source names]
install_date = attr.ib(default=None)
files = attr.ib(default=attr.Factory(list))
source_name = attr.ib(default=None, hash=False)
source_version = attr.ib(default=None, hash=False)
size = attr.ib(default=None, hash=False)
md5 = attr.ib(default=None, hash=False)
sha1 = attr.ib(default=None, hash=False)
sha256 = attr.ib(default=None, hash=False)
versions = attr.ib(default=None, hash=False) # Hash ver_str -> [Array of source names]
install_date = attr.ib(default=None, hash=False)
files = attr.ib(default=attr.Factory(list), hash=False)
def satisfies(self, other):
"""return True if this package (self) satisfies the requirements of
@@ -464,14 +464,13 @@ def _get_date_from_release_file(self, archive_uri, uri_suite):
try:
out = self._session.read(filename)
spec = get_spec_from_release_file(out)
try:
date = str(pytz.utc.localize(
datetime.utcfromtimestamp(
mktime_tz(parsedate_tz(spec.date)))))
except TypeError as _:
lgr.warning("Unexpected date format %s " % spec.date)
break
date = str(pytz.utc.localize(
datetime.utcfromtimestamp(
mktime_tz(parsedate_tz(spec.date)))))
except CommandError as _:
# NOTE: We will be trying release files that end in
# "Release" and "InRelease", so we expect to fail in opening
# specific attempts.
pass
return date
@@ -19,7 +19,10 @@
import mock
from niceman.tests.utils import skip_if_no_apt_cache
@skip_if_no_apt_cache
def test_dpkg_manager_identify_packages():
files = ["/sbin/iptables"]
tracer = DebTracer()
@@ -140,7 +140,7 @@ def identify_distributions(files, session=None):
files_to_consider = files[:]
# Identify directories from the files_to_consider
dirs = set([x for x in files_to_consider if session.isdir(x)])
dirs = set(filter(session.isdir, files_to_consider))
distibutions = []
for Tracer in Tracers:
@@ -72,10 +72,9 @@ def test_source_file_crash(script=None):
with raises(Exception): # TODO: unify?
ses.source_script(script)
@with_tempfile(content="content")
def test_isdir(script=None):
def test_isdir():
ses = ShellSession()
assert not ses.isdir(script)
assert not ses.isdir(__file__)
assert ses.isdir("/bin")
@@ -15,7 +15,7 @@
import uuid
from ...utils import swallow_logs
from ...tests.utils import assert_in, skip_if_no_network
from ...tests.utils import assert_in, skip_if_no_network, skip_ssh
from ..base import ResourceManager
from ...cmd import Runner
@@ -54,6 +54,8 @@ def setup_docker():
def test_ssh_class(setup_docker):
skip_ssh()
with swallow_logs(new_level=logging.DEBUG) as log:
# Test connecting to test SSH server.
@@ -215,11 +215,13 @@ def parse_apt_cache_policy_source_info(policy_output):
else:
lgr.warning("Unexpected source line %s" %
info.get("source"))
attribs = re_rel_attrib.finditer(info.get("release_info"))
for attrib in attribs:
if attrib.group("tag") in tag_map:
src_detail[tag_map[attrib.group("tag")]] = \
attrib.group("value")
release_info = info.get("release_info")
if release_info:
attribs = re_rel_attrib.finditer(release_info)
for attrib in attribs:
if attrib.group("tag") in tag_map:
src_detail[tag_map[attrib.group("tag")]] = \
attrib.group("value")
source_info[info.get("source")] = src_detail
return source_info
@@ -285,6 +285,10 @@ def test_parse_apt_cache_policy_source_info():
500 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages
release v=16.04,o=Ubuntu,a=xenial-security,n=xenial,l=Ubuntu,c=restricted,b=amd64
origin security.ubuntu.com
500 http://debproxy:9999/debian/ jessie-backports/contrib Translation-en
100 http://debproxy:9999/debian/ jessie-backports/non-free amd64 Packages
release o=Debian Backports,a=jessie-backports,n=jessie-backports,l=Debian Backports,c=non-free
origin debproxy
500 http://us.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages
release v=16.04,o=Ubuntu,a=xenial-updates,n=xenial,l=Ubuntu,c=universe,b=amd64
origin us.archive.ubuntu.com
@@ -313,7 +317,23 @@ def test_parse_apt_cache_policy_source_info():
'component': 'restricted',
'label': 'Ubuntu',
'origin': 'Ubuntu',
'site': 'security.ubuntu.com'}}
'site': 'security.ubuntu.com'
},
'http://debproxy:9999/debian/ jessie-backports/contrib Translation-en':
{'archive_uri': 'http://debproxy:9999/debian/',
'uri_suite': 'jessie-backports'
},
'http://debproxy:9999/debian/ jessie-backports/non-free amd64 Packages':
{'archive': 'jessie-backports',
'archive_uri': 'http://debproxy:9999/debian/',
'codename': 'jessie-backports',
'component': 'non-free',
'label': 'Debian Backports',
'origin': 'Debian Backports',
'site': 'debproxy',
'uri_suite': 'jessie-backports'
},
}
out = parse_apt_cache_policy_source_info(txt)
assert_is_subset_recur(out1, out, [dict])
@@ -50,6 +50,9 @@ def _get_git_version():
"""Return version of available git"""
return _runner.run('git version'.split())[0].split()[-1]
def _get_apt_cache_version():
"""Return version of available git"""
return _runner.run('apt-cache -v'.split())[0].split()[1]
class ExternalVersions(object):
"""Helper to figure out/use versions of the externals (modules, cmdline tools, etc).
@@ -69,7 +72,8 @@ class ExternalVersions(object):
CUSTOM = {
'cmd:annex': _get_annex_version,
'cmd:git': _get_git_version
'cmd:git': _get_git_version,
'cmd:apt-cache': _get_apt_cache_version
}
def __init__(self):
Oops, something went wrong.

0 comments on commit 195fc46

Please sign in to comment.