15 tests fail
Opened this issue · 0 comments
yurivict commented
=========================================================================================================== FAILURES ===========================================================================================================
_____________________________________________________________________________________________________ test_archive_session _____________________________________________________________________________________________________
tmpdir = local('/tmp/pytest-of-yuri/pytest-4/test_archive_session0')
def test_archive_session(tmpdir):
tmpdir.chdir()
s = internetarchive.session.ArchiveSession(CONFIG)
assert os.path.isfile('test.log')
> assert CONFIG == s.config
E AssertionError: assert {'cookies': {...test_secret'}} == {'cookies': {...test_secret'}}
E Omitting 3 identical items, use -vv to show
E Right contains 1 more item:
E {'general': {'screenname': 'None'}}
E Full diff:
E {
E 'cookies': {'logged-in-sig': 'testsig; path=/; domain=.archive.org',
E 'logged-in-user': 'test%40example.com; path=/; '...
E
E ...Full output truncated (7 lines hidden), use '-vv' to show
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_session.py:31: AssertionError
____________________________________________________________________________________________ test_write_config_file_config_existing ____________________________________________________________________________________________
def test_write_config_file_config_existing():
"""Test that .config's permissions remain but ia gets created correctly."""
> _test_write_config_file(
dirs=['.config'],
expected_config_file='.config/internetarchive/ia.ini',
expected_modes=[
('.config/internetarchive/ia.ini', 0o600),
('.config/internetarchive', 0o700),
('.config', 0o777),
],
)
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_config.py:367:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
expected_config_file = '/tmp/tmpszciqv8h/.config/internetarchive/ia.ini'
expected_modes = [('/tmp/tmpszciqv8h/.config/internetarchive/ia.ini', 384), ('/tmp/tmpszciqv8h/.config/internetarchive', 448), ('/tmp/tmpszciqv8h/.config', 511)], dirs = ['/tmp/tmpszciqv8h/.config']
create_expected_file = False, config_file_param = None
def _test_write_config_file(
expected_config_file,
expected_modes,
dirs=None,
create_expected_file=False,
config_file_param=None):
# expected_config_file: str
# expected_modes: list of (path, mode) tuples
# dirs: list of str, directories to create before running write_config_file
# create_expected_file: bool, create the expected_config_file if True
# config_file_param: str, filename to pass to write_config_file
# Both dirs and the config file are created with mode 777 (minus umask).
# All paths are evaluated relative to a temporary HOME.
# Mode comparison accounts for the umask; expected_modes does not need to care about it.
with tempfile.TemporaryDirectory() as temp_home_dir:
expected_config_file = os.path.join(temp_home_dir, expected_config_file)
if dirs:
dirs = [os.path.join(temp_home_dir, d) for d in dirs]
expected_modes = [(os.path.join(temp_home_dir, p), m) for p, m in expected_modes]
if config_file_param:
config_file_param = os.path.join(temp_home_dir, config_file_param)
with _environ(HOME=temp_home_dir):
# Need to account for the umask in the expected_modes comparisons.
# The umask can't just be retrieved, so set and then restore previous value.
umask = os.umask(0)
os.umask(umask)
if dirs:
for d in dirs:
os.mkdir(d)
if create_expected_file:
with open(expected_config_file, 'w') as fp:
os.chmod(expected_config_file, 0o777)
config_file = internetarchive.config.write_config_file({}, config_file_param)
> assert config_file == expected_config_file
E AssertionError: assert '/usr/ports/w...rchive/ia.ini' == '/tmp/tmpszci...rchive/ia.ini'
E - /tmp/tmpszciqv8h/.config/internetarchive/ia.ini
E + /usr/ports/www/py-internetarchive/work-py39/internetarchive/ia.ini
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_config.py:346: AssertionError
_____________________________________________________________________________________________ test_parse_config_file_existing_all ______________________________________________________________________________________________
def test_parse_config_file_existing_all():
> _test_parse_config_file(
expected_result=('$TMPTESTDIR/.config/internetarchive/ia.ini', True),
config_file_paths=[
'$TMPTESTDIR/.config/internetarchive/ia.ini',
'$TMPTESTDIR/.config/ia.ini',
'$TMPTESTDIR/.ia'
],
)
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_config.py:252:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
expected_result = ('/tmp/tmp70g3p74q/.config/internetarchive/ia.ini', True), config_file_contents = ''
config_file_paths = ['/tmp/tmp70g3p74q/.config/internetarchive/ia.ini', '/tmp/tmp70g3p74q/.config/ia.ini', '/tmp/tmp70g3p74q/.ia'], home = '/tmp/tmp70g3p74q', xdg_config_home = None, config_file_param = None
def _test_parse_config_file(
expected_result,
config_file_contents='',
config_file_paths=None,
home=None,
xdg_config_home=None,
config_file_param=None):
# expected_result: (config_file_path, is_xdg); config isn't compared.
# config_file_contents: str
# config_file_paths: list of filenames to write config_file_contents to
# home: str, override HOME env var; default: path of the temporary dir
# xdg_config_home: str, set XDG_CONFIG_HOME
# config_file_param: str, filename to pass to parse_config_file
# All paths starting with '$TMPTESTDIR/' get evaluated relative to the temp dir.
if not config_file_paths:
config_file_paths = []
with tempfile.TemporaryDirectory() as tmp_test_dir:
def _replace_path(s):
if s and s.startswith('$TMPTESTDIR/'):
return os.path.join(tmp_test_dir, s.split('/', 1)[1])
return s
expected_result = (_replace_path(expected_result[0]), expected_result[1])
config_file_paths = [_replace_path(x) for x in config_file_paths]
home = _replace_path(home)
xdg_config_home = _replace_path(xdg_config_home)
config_file_param = _replace_path(config_file_param)
for p in config_file_paths:
os.makedirs(os.path.dirname(p), exist_ok=True)
with open(p, 'w') as fp:
fp.write(config_file_contents)
if home is None:
home = tmp_test_dir
env = {'HOME': home}
if xdg_config_home is not None:
env['XDG_CONFIG_HOME'] = xdg_config_home
with _environ(**env):
config_file_path, is_xdg, config = internetarchive.config.parse_config_file(
config_file=config_file_param)
> assert (config_file_path, is_xdg) == expected_result[0:2]
E AssertionError: assert ('/usr/ports/...ia.ini', True) == ('/tmp/tmp70g...ia.ini', True)
E At index 0 diff: '/usr/ports/www/py-internetarchive/work-py39/internetarchive/ia.ini' != '/tmp/tmp70g3p74q/.config/internetarchive/ia.ini'
E Full diff:
E - ('/tmp/tmp70g3p74q/.config/internetarchive/ia.ini', True)
E + ('/usr/ports/www/py-internetarchive/work-py39/internetarchive/ia.ini', True)
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_config.py:221: AssertionError
____________________________________________________________________________________ test_write_config_file_config_internetarchive_existing ____________________________________________________________________________________
def test_write_config_file_config_internetarchive_existing():
"""Test that directory permissions are left as is"""
> _test_write_config_file(
dirs=['.config', '.config/internetarchive'],
expected_config_file='.config/internetarchive/ia.ini',
expected_modes=[
('.config/internetarchive/ia.ini', 0o600),
('.config/internetarchive', 0o777),
('.config', 0o777),
],
)
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_config.py:380:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
expected_config_file = '/tmp/tmpy6oy6hmq/.config/internetarchive/ia.ini'
expected_modes = [('/tmp/tmpy6oy6hmq/.config/internetarchive/ia.ini', 384), ('/tmp/tmpy6oy6hmq/.config/internetarchive', 511), ('/tmp/tmpy6oy6hmq/.config', 511)]
dirs = ['/tmp/tmpy6oy6hmq/.config', '/tmp/tmpy6oy6hmq/.config/internetarchive'], create_expected_file = False, config_file_param = None
def _test_write_config_file(
expected_config_file,
expected_modes,
dirs=None,
create_expected_file=False,
config_file_param=None):
# expected_config_file: str
# expected_modes: list of (path, mode) tuples
# dirs: list of str, directories to create before running write_config_file
# create_expected_file: bool, create the expected_config_file if True
# config_file_param: str, filename to pass to write_config_file
# Both dirs and the config file are created with mode 777 (minus umask).
# All paths are evaluated relative to a temporary HOME.
# Mode comparison accounts for the umask; expected_modes does not need to care about it.
with tempfile.TemporaryDirectory() as temp_home_dir:
expected_config_file = os.path.join(temp_home_dir, expected_config_file)
if dirs:
dirs = [os.path.join(temp_home_dir, d) for d in dirs]
expected_modes = [(os.path.join(temp_home_dir, p), m) for p, m in expected_modes]
if config_file_param:
config_file_param = os.path.join(temp_home_dir, config_file_param)
with _environ(HOME=temp_home_dir):
# Need to account for the umask in the expected_modes comparisons.
# The umask can't just be retrieved, so set and then restore previous value.
umask = os.umask(0)
os.umask(umask)
if dirs:
for d in dirs:
os.mkdir(d)
if create_expected_file:
with open(expected_config_file, 'w') as fp:
os.chmod(expected_config_file, 0o777)
config_file = internetarchive.config.write_config_file({}, config_file_param)
> assert config_file == expected_config_file
E AssertionError: assert '/usr/ports/w...rchive/ia.ini' == '/tmp/tmpy6oy...rchive/ia.ini'
E - /tmp/tmpy6oy6hmq/.config/internetarchive/ia.ini
E + /usr/ports/www/py-internetarchive/work-py39/internetarchive/ia.ini
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_config.py:346: AssertionError
_________________________________________________________________________________________________ test_write_config_file_blank _________________________________________________________________________________________________
def test_write_config_file_blank():
"""Test that a blank HOME is populated with expected dirs and modes."""
> _test_write_config_file(
expected_config_file='.config/internetarchive/ia.ini',
expected_modes=[
('.config/internetarchive/ia.ini', 0o600),
('.config/internetarchive', 0o700),
('.config', 0o700),
],
)
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_config.py:355:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
expected_config_file = '/tmp/tmp3r289ul8/.config/internetarchive/ia.ini'
expected_modes = [('/tmp/tmp3r289ul8/.config/internetarchive/ia.ini', 384), ('/tmp/tmp3r289ul8/.config/internetarchive', 448), ('/tmp/tmp3r289ul8/.config', 448)], dirs = None, create_expected_file = False
config_file_param = None
def _test_write_config_file(
expected_config_file,
expected_modes,
dirs=None,
create_expected_file=False,
config_file_param=None):
# expected_config_file: str
# expected_modes: list of (path, mode) tuples
# dirs: list of str, directories to create before running write_config_file
# create_expected_file: bool, create the expected_config_file if True
# config_file_param: str, filename to pass to write_config_file
# Both dirs and the config file are created with mode 777 (minus umask).
# All paths are evaluated relative to a temporary HOME.
# Mode comparison accounts for the umask; expected_modes does not need to care about it.
with tempfile.TemporaryDirectory() as temp_home_dir:
expected_config_file = os.path.join(temp_home_dir, expected_config_file)
if dirs:
dirs = [os.path.join(temp_home_dir, d) for d in dirs]
expected_modes = [(os.path.join(temp_home_dir, p), m) for p, m in expected_modes]
if config_file_param:
config_file_param = os.path.join(temp_home_dir, config_file_param)
with _environ(HOME=temp_home_dir):
# Need to account for the umask in the expected_modes comparisons.
# The umask can't just be retrieved, so set and then restore previous value.
umask = os.umask(0)
os.umask(umask)
if dirs:
for d in dirs:
os.mkdir(d)
if create_expected_file:
with open(expected_config_file, 'w') as fp:
os.chmod(expected_config_file, 0o777)
config_file = internetarchive.config.write_config_file({}, config_file_param)
> assert config_file == expected_config_file
E AssertionError: assert '/usr/ports/w...rchive/ia.ini' == '/tmp/tmp3r28...rchive/ia.ini'
E - /tmp/tmp3r289ul8/.config/internetarchive/ia.ini
E + /usr/ports/www/py-internetarchive/work-py39/internetarchive/ia.ini
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_config.py:346: AssertionError
_______________________________________________________________________________________ test_parse_config_file_with_environment_variable _______________________________________________________________________________________
def test_parse_config_file_with_environment_variable():
with _environ(IA_CONFIG_FILE='/inexistent.ia.ini'):
> _test_parse_config_file(
expected_result=('/inexistent.ia.ini', False),
)
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_config.py:299:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
expected_result = ('/inexistent.ia.ini', False), config_file_contents = '', config_file_paths = [], home = '/tmp/tmpxicijms5', xdg_config_home = None, config_file_param = None
def _test_parse_config_file(
expected_result,
config_file_contents='',
config_file_paths=None,
home=None,
xdg_config_home=None,
config_file_param=None):
# expected_result: (config_file_path, is_xdg); config isn't compared.
# config_file_contents: str
# config_file_paths: list of filenames to write config_file_contents to
# home: str, override HOME env var; default: path of the temporary dir
# xdg_config_home: str, set XDG_CONFIG_HOME
# config_file_param: str, filename to pass to parse_config_file
# All paths starting with '$TMPTESTDIR/' get evaluated relative to the temp dir.
if not config_file_paths:
config_file_paths = []
with tempfile.TemporaryDirectory() as tmp_test_dir:
def _replace_path(s):
if s and s.startswith('$TMPTESTDIR/'):
return os.path.join(tmp_test_dir, s.split('/', 1)[1])
return s
expected_result = (_replace_path(expected_result[0]), expected_result[1])
config_file_paths = [_replace_path(x) for x in config_file_paths]
home = _replace_path(home)
xdg_config_home = _replace_path(xdg_config_home)
config_file_param = _replace_path(config_file_param)
for p in config_file_paths:
os.makedirs(os.path.dirname(p), exist_ok=True)
with open(p, 'w') as fp:
fp.write(config_file_contents)
if home is None:
home = tmp_test_dir
env = {'HOME': home}
if xdg_config_home is not None:
env['XDG_CONFIG_HOME'] = xdg_config_home
with _environ(**env):
config_file_path, is_xdg, config = internetarchive.config.parse_config_file(
config_file=config_file_param)
> assert (config_file_path, is_xdg) == expected_result[0:2]
E AssertionError: assert ('/usr/ports/...ia.ini', True) == ('/inexistent.ia.ini', False)
E At index 0 diff: '/usr/ports/www/py-internetarchive/work-py39/internetarchive/ia.ini' != '/inexistent.ia.ini'
E Full diff:
E - ('/inexistent.ia.ini', False)
E + ('/usr/ports/www/py-internetarchive/work-py39/internetarchive/ia.ini', True)
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_config.py:221: AssertionError
__________________________________________________________________________________________ test_parse_config_file_existing_config_ia ___________________________________________________________________________________________
def test_parse_config_file_existing_config_ia():
> _test_parse_config_file(
expected_result=('$TMPTESTDIR/.config/ia.ini', False),
config_file_paths=['$TMPTESTDIR/.config/ia.ini'],
)
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_config.py:231:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
expected_result = ('/tmp/tmpoi2t7t7u/.config/ia.ini', False), config_file_contents = '', config_file_paths = ['/tmp/tmpoi2t7t7u/.config/ia.ini'], home = '/tmp/tmpoi2t7t7u', xdg_config_home = None, config_file_param = None
def _test_parse_config_file(
expected_result,
config_file_contents='',
config_file_paths=None,
home=None,
xdg_config_home=None,
config_file_param=None):
# expected_result: (config_file_path, is_xdg); config isn't compared.
# config_file_contents: str
# config_file_paths: list of filenames to write config_file_contents to
# home: str, override HOME env var; default: path of the temporary dir
# xdg_config_home: str, set XDG_CONFIG_HOME
# config_file_param: str, filename to pass to parse_config_file
# All paths starting with '$TMPTESTDIR/' get evaluated relative to the temp dir.
if not config_file_paths:
config_file_paths = []
with tempfile.TemporaryDirectory() as tmp_test_dir:
def _replace_path(s):
if s and s.startswith('$TMPTESTDIR/'):
return os.path.join(tmp_test_dir, s.split('/', 1)[1])
return s
expected_result = (_replace_path(expected_result[0]), expected_result[1])
config_file_paths = [_replace_path(x) for x in config_file_paths]
home = _replace_path(home)
xdg_config_home = _replace_path(xdg_config_home)
config_file_param = _replace_path(config_file_param)
for p in config_file_paths:
os.makedirs(os.path.dirname(p), exist_ok=True)
with open(p, 'w') as fp:
fp.write(config_file_contents)
if home is None:
home = tmp_test_dir
env = {'HOME': home}
if xdg_config_home is not None:
env['XDG_CONFIG_HOME'] = xdg_config_home
with _environ(**env):
config_file_path, is_xdg, config = internetarchive.config.parse_config_file(
config_file=config_file_param)
> assert (config_file_path, is_xdg) == expected_result[0:2]
E AssertionError: assert ('/usr/ports/...ia.ini', True) == ('/tmp/tmpoi2...a.ini', False)
E At index 0 diff: '/usr/ports/www/py-internetarchive/work-py39/internetarchive/ia.ini' != '/tmp/tmpoi2t7t7u/.config/ia.ini'
E Full diff:
E - ('/tmp/tmpoi2t7t7u/.config/ia.ini', False)
E + ('/usr/ports/www/py-internetarchive/work-py39/internetarchive/ia.ini', True)
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_config.py:221: AssertionError
____________________________________________________________________________________________ test_parse_config_file_existing_dotia _____________________________________________________________________________________________
def test_parse_config_file_existing_dotia():
> _test_parse_config_file(
expected_result=('$TMPTESTDIR/.ia', False),
config_file_paths=['$TMPTESTDIR/.ia'],
)
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_config.py:238:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
expected_result = ('/tmp/tmpp0brtuug/.ia', False), config_file_contents = '', config_file_paths = ['/tmp/tmpp0brtuug/.ia'], home = '/tmp/tmpp0brtuug', xdg_config_home = None, config_file_param = None
def _test_parse_config_file(
expected_result,
config_file_contents='',
config_file_paths=None,
home=None,
xdg_config_home=None,
config_file_param=None):
# expected_result: (config_file_path, is_xdg); config isn't compared.
# config_file_contents: str
# config_file_paths: list of filenames to write config_file_contents to
# home: str, override HOME env var; default: path of the temporary dir
# xdg_config_home: str, set XDG_CONFIG_HOME
# config_file_param: str, filename to pass to parse_config_file
# All paths starting with '$TMPTESTDIR/' get evaluated relative to the temp dir.
if not config_file_paths:
config_file_paths = []
with tempfile.TemporaryDirectory() as tmp_test_dir:
def _replace_path(s):
if s and s.startswith('$TMPTESTDIR/'):
return os.path.join(tmp_test_dir, s.split('/', 1)[1])
return s
expected_result = (_replace_path(expected_result[0]), expected_result[1])
config_file_paths = [_replace_path(x) for x in config_file_paths]
home = _replace_path(home)
xdg_config_home = _replace_path(xdg_config_home)
config_file_param = _replace_path(config_file_param)
for p in config_file_paths:
os.makedirs(os.path.dirname(p), exist_ok=True)
with open(p, 'w') as fp:
fp.write(config_file_contents)
if home is None:
home = tmp_test_dir
env = {'HOME': home}
if xdg_config_home is not None:
env['XDG_CONFIG_HOME'] = xdg_config_home
with _environ(**env):
config_file_path, is_xdg, config = internetarchive.config.parse_config_file(
config_file=config_file_param)
> assert (config_file_path, is_xdg) == expected_result[0:2]
E AssertionError: assert ('/usr/ports/...ia.ini', True) == ('/tmp/tmpp0b...g/.ia', False)
E At index 0 diff: '/usr/ports/www/py-internetarchive/work-py39/internetarchive/ia.ini' != '/tmp/tmpp0brtuug/.ia'
E Full diff:
E - ('/tmp/tmpp0brtuug/.ia', False)
E + ('/usr/ports/www/py-internetarchive/work-py39/internetarchive/ia.ini', True)
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_config.py:221: AssertionError
_____________________________________________________________________________________ test_parse_config_file_existing_config_ia_and_dotia ______________________________________________________________________________________
def test_parse_config_file_existing_config_ia_and_dotia():
> _test_parse_config_file(
expected_result=('$TMPTESTDIR/.config/ia.ini', False),
config_file_paths=['$TMPTESTDIR/.config/ia.ini', '$TMPTESTDIR/.ia'],
)
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_config.py:245:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
expected_result = ('/tmp/tmpxgojawjh/.config/ia.ini', False), config_file_contents = '', config_file_paths = ['/tmp/tmpxgojawjh/.config/ia.ini', '/tmp/tmpxgojawjh/.ia'], home = '/tmp/tmpxgojawjh', xdg_config_home = None
config_file_param = None
def _test_parse_config_file(
expected_result,
config_file_contents='',
config_file_paths=None,
home=None,
xdg_config_home=None,
config_file_param=None):
# expected_result: (config_file_path, is_xdg); config isn't compared.
# config_file_contents: str
# config_file_paths: list of filenames to write config_file_contents to
# home: str, override HOME env var; default: path of the temporary dir
# xdg_config_home: str, set XDG_CONFIG_HOME
# config_file_param: str, filename to pass to parse_config_file
# All paths starting with '$TMPTESTDIR/' get evaluated relative to the temp dir.
if not config_file_paths:
config_file_paths = []
with tempfile.TemporaryDirectory() as tmp_test_dir:
def _replace_path(s):
if s and s.startswith('$TMPTESTDIR/'):
return os.path.join(tmp_test_dir, s.split('/', 1)[1])
return s
expected_result = (_replace_path(expected_result[0]), expected_result[1])
config_file_paths = [_replace_path(x) for x in config_file_paths]
home = _replace_path(home)
xdg_config_home = _replace_path(xdg_config_home)
config_file_param = _replace_path(config_file_param)
for p in config_file_paths:
os.makedirs(os.path.dirname(p), exist_ok=True)
with open(p, 'w') as fp:
fp.write(config_file_contents)
if home is None:
home = tmp_test_dir
env = {'HOME': home}
if xdg_config_home is not None:
env['XDG_CONFIG_HOME'] = xdg_config_home
with _environ(**env):
config_file_path, is_xdg, config = internetarchive.config.parse_config_file(
config_file=config_file_param)
> assert (config_file_path, is_xdg) == expected_result[0:2]
E AssertionError: assert ('/usr/ports/...ia.ini', True) == ('/tmp/tmpxgo...a.ini', False)
E At index 0 diff: '/usr/ports/www/py-internetarchive/work-py39/internetarchive/ia.ini' != '/tmp/tmpxgojawjh/.config/ia.ini'
E Full diff:
E - ('/tmp/tmpxgojawjh/.config/ia.ini', False)
E + ('/usr/ports/www/py-internetarchive/work-py39/internetarchive/ia.ini', True)
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_config.py:221: AssertionError
_____________________________________________________________________________________________ test_write_config_file_existing_file _____________________________________________________________________________________________
def test_write_config_file_existing_file():
"""Test that the permissions of the file are forced to 600"""
> _test_write_config_file(
dirs=['.config', '.config/internetarchive'],
expected_config_file='.config/internetarchive/ia.ini',
create_expected_file=True,
expected_modes=[
('.config/internetarchive/ia.ini', 0o600),
('.config/internetarchive', 0o777),
('.config', 0o777),
],
)
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_config.py:393:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
expected_config_file = '/tmp/tmpoej9n_ir/.config/internetarchive/ia.ini'
expected_modes = [('/tmp/tmpoej9n_ir/.config/internetarchive/ia.ini', 384), ('/tmp/tmpoej9n_ir/.config/internetarchive', 511), ('/tmp/tmpoej9n_ir/.config', 511)]
dirs = ['/tmp/tmpoej9n_ir/.config', '/tmp/tmpoej9n_ir/.config/internetarchive'], create_expected_file = True, config_file_param = None
def _test_write_config_file(
expected_config_file,
expected_modes,
dirs=None,
create_expected_file=False,
config_file_param=None):
# expected_config_file: str
# expected_modes: list of (path, mode) tuples
# dirs: list of str, directories to create before running write_config_file
# create_expected_file: bool, create the expected_config_file if True
# config_file_param: str, filename to pass to write_config_file
# Both dirs and the config file are created with mode 777 (minus umask).
# All paths are evaluated relative to a temporary HOME.
# Mode comparison accounts for the umask; expected_modes does not need to care about it.
with tempfile.TemporaryDirectory() as temp_home_dir:
expected_config_file = os.path.join(temp_home_dir, expected_config_file)
if dirs:
dirs = [os.path.join(temp_home_dir, d) for d in dirs]
expected_modes = [(os.path.join(temp_home_dir, p), m) for p, m in expected_modes]
if config_file_param:
config_file_param = os.path.join(temp_home_dir, config_file_param)
with _environ(HOME=temp_home_dir):
# Need to account for the umask in the expected_modes comparisons.
# The umask can't just be retrieved, so set and then restore previous value.
umask = os.umask(0)
os.umask(umask)
if dirs:
for d in dirs:
os.mkdir(d)
if create_expected_file:
with open(expected_config_file, 'w') as fp:
os.chmod(expected_config_file, 0o777)
config_file = internetarchive.config.write_config_file({}, config_file_param)
> assert config_file == expected_config_file
E AssertionError: assert '/usr/ports/w...rchive/ia.ini' == '/tmp/tmpoej9...rchive/ia.ini'
E - /tmp/tmpoej9n_ir/.config/internetarchive/ia.ini
E + /usr/ports/www/py-internetarchive/work-py39/internetarchive/ia.ini
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_config.py:346: AssertionError
_________________________________________________________________________________________________ test_parse_config_file_blank _________________________________________________________________________________________________
def test_parse_config_file_blank():
> _test_parse_config_file(
expected_result=('$TMPTESTDIR/.config/internetarchive/ia.ini', True)
)
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_config.py:225:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
expected_result = ('/tmp/tmp236hie7u/.config/internetarchive/ia.ini', True), config_file_contents = '', config_file_paths = [], home = '/tmp/tmp236hie7u', xdg_config_home = None, config_file_param = None
def _test_parse_config_file(
expected_result,
config_file_contents='',
config_file_paths=None,
home=None,
xdg_config_home=None,
config_file_param=None):
# expected_result: (config_file_path, is_xdg); config isn't compared.
# config_file_contents: str
# config_file_paths: list of filenames to write config_file_contents to
# home: str, override HOME env var; default: path of the temporary dir
# xdg_config_home: str, set XDG_CONFIG_HOME
# config_file_param: str, filename to pass to parse_config_file
# All paths starting with '$TMPTESTDIR/' get evaluated relative to the temp dir.
if not config_file_paths:
config_file_paths = []
with tempfile.TemporaryDirectory() as tmp_test_dir:
def _replace_path(s):
if s and s.startswith('$TMPTESTDIR/'):
return os.path.join(tmp_test_dir, s.split('/', 1)[1])
return s
expected_result = (_replace_path(expected_result[0]), expected_result[1])
config_file_paths = [_replace_path(x) for x in config_file_paths]
home = _replace_path(home)
xdg_config_home = _replace_path(xdg_config_home)
config_file_param = _replace_path(config_file_param)
for p in config_file_paths:
os.makedirs(os.path.dirname(p), exist_ok=True)
with open(p, 'w') as fp:
fp.write(config_file_contents)
if home is None:
home = tmp_test_dir
env = {'HOME': home}
if xdg_config_home is not None:
env['XDG_CONFIG_HOME'] = xdg_config_home
with _environ(**env):
config_file_path, is_xdg, config = internetarchive.config.parse_config_file(
config_file=config_file_param)
> assert (config_file_path, is_xdg) == expected_result[0:2]
E AssertionError: assert ('/usr/ports/...ia.ini', True) == ('/tmp/tmp236...ia.ini', True)
E At index 0 diff: '/usr/ports/www/py-internetarchive/work-py39/internetarchive/ia.ini' != '/tmp/tmp236hie7u/.config/internetarchive/ia.ini'
E Full diff:
E - ('/tmp/tmp236hie7u/.config/internetarchive/ia.ini', True)
E + ('/usr/ports/www/py-internetarchive/work-py39/internetarchive/ia.ini', True)
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_config.py:221: AssertionError
________________________________________________________________________________________________ test_get_config_no_config_file ________________________________________________________________________________________________
def test_get_config_no_config_file():
os.environ['HOME'] = ''
config = internetarchive.config.get_config()
> assert config == {}
E AssertionError: assert {'cookies': {...ret': 'None'}} == {}
E Left contains 3 more items:
E {'cookies': {'logged-in-sig': 'None', 'logged-in-user': 'None'},
E 'general': {'screenname': 'None'},
E 's3': {'access': 'None', 'secret': 'None'}}
E Full diff:
E {
E - ,...
E
E ...Full output truncated (6 lines hidden), use '-vv' to show
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_config.py:84: AssertionError
___________________________________________________________________________________________________ test_upload_queue_derive ___________________________________________________________________________________________________
nasa_item = Collection(identifier='nasa')
def test_upload_queue_derive(nasa_item):
with IaRequestsMock(assert_all_requests_are_fired=False) as rsps:
_expected_headers = deepcopy(EXPECTED_S3_HEADERS)
_expected_headers['x-archive-queue-derive'] = '1'
del _expected_headers['x-archive-meta00-scanner']
rsps.add(responses.PUT, S3_URL_RE, adding_headers=_expected_headers)
_responses = nasa_item.upload(NASA_METADATA_PATH, access_key='a', secret_key='b')
for resp in _responses:
headers = {k.lower(): str(v) for k, v in resp.request.headers.items()}
del headers['x-archive-meta00-scanner']
assert 'user-agent' in headers
del headers['user-agent']
> assert headers == _expected_headers
E AssertionError: assert {'accept': '*... 'close', ...} == {'accept': '*... 'close', ...}
E Omitting 7 identical items, use -vv to show
E Differing items:
E {'accept-encoding': 'gzip, deflate, br'} != {'accept-encoding': 'gzip, deflate'}
E Full diff:
E {
E 'accept': '*/*',
E - 'accept-encoding': 'gzip, deflate',...
E
E ...Full output truncated (9 lines hidden), use '-vv' to show
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_item.py:491: AssertionError
------------------------------------------------------------------------------------------------------ Captured log setup ------------------------------------------------------------------------------------------------------
DEBUG internetarchive.session:session.py:252 no metadata provided for "nasa", retrieving now.
------------------------------------------------------------------------------------------------------ Captured log call -------------------------------------------------------------------------------------------------------
INFO internetarchive.item:item.py:1095 uploaded nasa.json to https://s3.us.archive.org/nasa/nasa.json
_________________________________________________________________________________________________________ test_upload __________________________________________________________________________________________________________
nasa_item = Collection(identifier='nasa')
def test_upload(nasa_item):
with IaRequestsMock(assert_all_requests_are_fired=False) as rsps:
rsps.add(responses.PUT, S3_URL_RE,
adding_headers=EXPECTED_S3_HEADERS)
_responses = nasa_item.upload(NASA_METADATA_PATH,
access_key='a',
secret_key='b')
for resp in _responses:
request = resp.request
headers = {k.lower(): str(v) for k, v in request.headers.items()}
scanner_header = '%20'.join(
resp.headers['x-archive-meta00-scanner'].split('%20')[:4])
headers['x-archive-meta00-scanner'] = scanner_header
assert 'user-agent' in headers
del headers['user-agent']
> assert headers == EXPECTED_S3_HEADERS
E AssertionError: assert {'accept': '*... 'close', ...} == {'accept': '*... 'close', ...}
E Omitting 8 identical items, use -vv to show
E Differing items:
E {'accept-encoding': 'gzip, deflate, br'} != {'accept-encoding': 'gzip, deflate'}
E Full diff:
E {
E 'accept': '*/*',
E - 'accept-encoding': 'gzip, deflate',...
E
E ...Full output truncated (10 lines hidden), use '-vv' to show
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_item.py:323: AssertionError
------------------------------------------------------------------------------------------------------ Captured log setup ------------------------------------------------------------------------------------------------------
DEBUG internetarchive.session:session.py:252 no metadata provided for "nasa", retrieving now.
------------------------------------------------------------------------------------------------------ Captured log call -------------------------------------------------------------------------------------------------------
INFO internetarchive.item:item.py:1095 uploaded nasa.json to https://s3.us.archive.org/nasa/nasa.json
_____________________________________________________________________________________________________ test_upload_metadata _____________________________________________________________________________________________________
nasa_item = Collection(identifier='nasa')
def test_upload_metadata(nasa_item):
with IaRequestsMock(assert_all_requests_are_fired=False) as rsps:
_expected_headers = deepcopy(EXPECTED_S3_HEADERS)
del _expected_headers['x-archive-meta00-scanner']
_expected_headers['x-archive-meta00-foo'] = 'bar'
_expected_headers['x-archive-meta00-subject'] = 'first'
_expected_headers['x-archive-meta01-subject'] = 'second'
_expected_headers['x-archive-meta00-baz'] = (
'uri(%D0%9F%D0%BE%D1%87%D0%B5%D0%BC'
'%D1%83%20%D0%B1%D1%8B%20%D0%B8%20%'
'D0%BD%D0%B5%D1%82...)')
_expected_headers['x-archive-meta00-baz2'] = (
'uri(%D0%9F%D0%BE%D1%87%D0%B5%D0%BC'
'%D1%83%20%D0%B1%D1%8B%20%D0%B8%20%'
'D0%BD%D0%B5%D1%82...)')
rsps.add(responses.PUT, S3_URL_RE,
adding_headers=_expected_headers)
md = {
'foo': 'bar',
'subject': ['first', 'second'],
'baz': 'Почему бы и нет...',
'baz2': ('\u041f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u0438 '
'\u043d\u0435\u0442...'),
}
_responses = nasa_item.upload(NASA_METADATA_PATH,
metadata=md,
access_key='a',
secret_key='b')
for resp in _responses:
request = resp.request
del request.headers['x-archive-meta00-scanner']
headers = {k.lower(): str(v) for k, v in request.headers.items()}
assert 'user-agent' in headers
del headers['user-agent']
> assert headers == _expected_headers
E AssertionError: assert {'accept': '*... 'close', ...} == {'accept': '*... 'close', ...}
E Omitting 12 identical items, use -vv to show
E Differing items:
E {'accept-encoding': 'gzip, deflate, br'} != {'accept-encoding': 'gzip, deflate'}
E Full diff:
E {
E 'accept': '*/*',
E - 'accept-encoding': 'gzip, deflate',...
E
E ...Full output truncated (14 lines hidden), use '-vv' to show
/usr/ports/www/py-internetarchive/work-py39/internetarchive-3.5.0/tests/test_item.py:398: AssertionError
------------------------------------------------------------------------------------------------------ Captured log setup ------------------------------------------------------------------------------------------------------
DEBUG internetarchive.session:session.py:252 no metadata provided for "nasa", retrieving now.
------------------------------------------------------------------------------------------------------ Captured log call -------------------------------------------------------------------------------------------------------
INFO internetarchive.item:item.py:1095 uploaded nasa.json to https://s3.us.archive.org/nasa/nasa.json
=============================================================================================== 15 failed, 128 passed in 39.12s ================================================================================================
*** Error code 1
Version: 3.5.0
Python-3.9
FreeBSD 13.2