Fixup comments, add stubs for new tests

pull/16/head
Dan Puttick 2017-07-11 14:31:24 -04:00
parent 966c577ff8
commit 7b8b175a93
2 changed files with 23 additions and 20 deletions

View File

@ -81,13 +81,13 @@ class FileBase(object):
def _determine_mimetype(self):
if os.path.islink(self.src_path):
# magic will throw an IOError on a broken symlink
# libmagic will throw an IOError on a broken symlink
mimetype = 'inode/symlink'
self.set_property('symlink', os.readlink(self.src_path))
else:
try:
mt = magic.from_file(self.src_path, mime=True)
# Note: libmagic will always return something, even if it's just 'data'
# libmagic will always return something, even if it's just 'data'
except UnicodeEncodeError as e:
# FIXME: The encoding of the file that triggers this is broken (possibly it's UTF-16 and Python expects utf8)
# Note: one of the Travis files will trigger this exception
@ -148,7 +148,7 @@ class FileBase(object):
@property
def is_symlink(self):
"""True if file is a symlink, else False."""
"""True if file is a symlink, else False."""
if self._file_props['symlink'] is False:
return False
else:

View File

@ -12,22 +12,9 @@ xfail = pytest.mark.xfail
fixture = pytest.fixture
# FileBase
@xfail
@skip
class TestFileBase:
@fixture
def source_file(self):
return 'tests/normal/blah.conf'
@fixture
def dest_file(self):
return 'tests/dst/blah.conf'
@fixture
def generic_conf_file(self, source_file, dest_file):
return FileBase(source_file, dest_file)
@fixture
def symlink_file(self, tmpdir):
file_path = tmpdir.join('test.txt')
@ -76,9 +63,24 @@ class TestFileBase:
request.param(generic_conf_file)
return generic_conf_file
# What are the various things that can go wrong with file paths? We should have fixtures for them
# What should FileBase do if it's given a path that isn't a file (doesn't exist or is a dir)? Currently magic throws an exception
# We should probably catch everytime that happens and tell the user explicitly happened (and maybe put it in the log)
def test_init_identify_filename(self):
"""Init should identify the filename correctly for src_path."""
pass
def test_init_identify_extension(self):
"""Init should identify the extension for src_path."""
pass
def test_init_file_doesnt_exist(self):
"""Init should raise an exception if the file doesn't exist."""
pass
def test_init_srcpath_is_directory(self):
"""Init should raise an exception if given a path to a directory."""
def test_init_symlink(self):
"""Init should properly identify symlinks."""
pass
def test_create_broken(self, tmpdir):
with pytest.raises(TypeError):
@ -214,6 +216,7 @@ class TestFileBase:
# check that safe copy can handle weird file path inputs
@skip
class TestKittenGroomerBase:
@fixture