mirror of https://github.com/CIRCL/PyCIRCLean
Fixup comments, add stubs for new tests
parent
966c577ff8
commit
7b8b175a93
|
@ -81,13 +81,13 @@ class FileBase(object):
|
||||||
|
|
||||||
def _determine_mimetype(self):
|
def _determine_mimetype(self):
|
||||||
if os.path.islink(self.src_path):
|
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'
|
mimetype = 'inode/symlink'
|
||||||
self.set_property('symlink', os.readlink(self.src_path))
|
self.set_property('symlink', os.readlink(self.src_path))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
mt = magic.from_file(self.src_path, mime=True)
|
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:
|
except UnicodeEncodeError as e:
|
||||||
# FIXME: The encoding of the file that triggers this is broken (possibly it's UTF-16 and Python expects utf8)
|
# 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
|
# Note: one of the Travis files will trigger this exception
|
||||||
|
|
|
@ -12,22 +12,9 @@ xfail = pytest.mark.xfail
|
||||||
fixture = pytest.fixture
|
fixture = pytest.fixture
|
||||||
|
|
||||||
|
|
||||||
# FileBase
|
@skip
|
||||||
@xfail
|
|
||||||
class TestFileBase:
|
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
|
@fixture
|
||||||
def symlink_file(self, tmpdir):
|
def symlink_file(self, tmpdir):
|
||||||
file_path = tmpdir.join('test.txt')
|
file_path = tmpdir.join('test.txt')
|
||||||
|
@ -76,9 +63,24 @@ class TestFileBase:
|
||||||
request.param(generic_conf_file)
|
request.param(generic_conf_file)
|
||||||
return 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
|
def test_init_identify_filename(self):
|
||||||
# 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
|
"""Init should identify the filename correctly for src_path."""
|
||||||
# We should probably catch everytime that happens and tell the user explicitly happened (and maybe put it in the log)
|
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):
|
def test_create_broken(self, tmpdir):
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
|
@ -214,6 +216,7 @@ class TestFileBase:
|
||||||
# check that safe copy can handle weird file path inputs
|
# check that safe copy can handle weird file path inputs
|
||||||
|
|
||||||
|
|
||||||
|
@skip
|
||||||
class TestKittenGroomerBase:
|
class TestKittenGroomerBase:
|
||||||
|
|
||||||
@fixture
|
@fixture
|
||||||
|
|
Loading…
Reference in New Issue