mirror of https://github.com/CIRCL/PyCIRCLean
Stub out new unit tests
parent
27cbdc57bc
commit
d3576db35d
|
@ -42,136 +42,111 @@ class TestFileBase:
|
||||||
def file_marked_dangerous(self):
|
def file_marked_dangerous(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# @fixture(params=[
|
|
||||||
# FileBase.make_dangerous,
|
|
||||||
# FileBase.make_unknown,
|
|
||||||
# FileBase.make_binary
|
|
||||||
# ])
|
|
||||||
# def file_marked_all_parameterized(self, request, generic_conf_file):
|
|
||||||
# request.param(generic_conf_file)
|
|
||||||
# return generic_conf_file
|
|
||||||
|
|
||||||
def test_init_identify_filename(self):
|
def test_init_identify_filename(self):
|
||||||
"""Init should identify the filename correctly for src_path."""
|
"""Init should identify the filename correctly for src_path."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def test_init_uppercase_filename(self):
|
||||||
|
"""Init should coerce filenames to lowercase."""
|
||||||
|
pass
|
||||||
|
|
||||||
def test_init_identify_extension(self):
|
def test_init_identify_extension(self):
|
||||||
"""Init should identify the extension for src_path."""
|
"""Init should identify the extension for src_path."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_init_file_doesnt_exist(self):
|
def test_init_uppercase_extension(self):
|
||||||
"""Init should raise an exception if the file doesn't exist."""
|
"""Init should coerce uppercase extension to lowercase"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_init_srcpath_is_directory(self):
|
def test_init_file_doesnt_exist(self):
|
||||||
|
"""Init should raise an exception if the file doesn't exist."""
|
||||||
|
with pytest.raises(FileNotFoundError):
|
||||||
|
FileBase('', '')
|
||||||
|
|
||||||
|
def test_init_srcpath_is_directory(self, tmpdir):
|
||||||
"""Init should raise an exception if given a path to a directory."""
|
"""Init should raise an exception if given a path to a directory."""
|
||||||
|
with pytest.raises(IsADirectoryError):
|
||||||
|
FileBase(tmpdir.strpath, tmpdir.strpath)
|
||||||
|
|
||||||
def test_init_symlink(self):
|
def test_init_symlink(self):
|
||||||
"""Init should properly identify symlinks."""
|
"""Init should properly identify symlinks."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_create_broken(self, tmpdir):
|
def test_is_symlink_attribute(self):
|
||||||
with pytest.raises(TypeError):
|
"""If a file is a symlink, is_symlink should return True."""
|
||||||
FileBase()
|
pass
|
||||||
with pytest.raises(FileNotFoundError):
|
|
||||||
FileBase('', '')
|
|
||||||
with pytest.raises(IsADirectoryError):
|
|
||||||
FileBase(tmpdir.strpath, tmpdir.strpath)
|
|
||||||
# TODO: are there other cases here? path to a file that doesn't exist? permissions?
|
|
||||||
|
|
||||||
def test_extension_uppercase(self, tmpdir):
|
def test_mimetype_attribute_assigned_correctly(self):
|
||||||
file_path = tmpdir.join('TEST.TXT')
|
"""When libmagic returns a given mimetype, the mimetype should be
|
||||||
file_path.write('testing')
|
assigned properly."""
|
||||||
file_path = file_path.strpath
|
pass
|
||||||
file = FileBase(file_path, file_path)
|
|
||||||
assert file.extension == '.txt'
|
|
||||||
|
|
||||||
def test_mimetypes(self, temp_file):
|
def set_property_user_defined(self):
|
||||||
assert temp_file.mimetype == 'text/plain'
|
pass
|
||||||
assert temp_file.maintype == 'text'
|
|
||||||
assert temp_file.subtype == 'plain'
|
|
||||||
assert temp_file.has_mimetype
|
|
||||||
# Need to test something without a mimetype
|
|
||||||
# Need to test something that's a directory
|
|
||||||
# Need to test something that causes the unicode exception
|
|
||||||
|
|
||||||
@skip
|
def set_property_builtin(self):
|
||||||
def test_has_mimetype_no_main_type(self, generic_conf_file):
|
pass
|
||||||
generic_conf_file.maintype = ''
|
|
||||||
assert generic_conf_file.has_mimetype is False
|
|
||||||
|
|
||||||
@skip
|
def get_property_doesnt_exist(self):
|
||||||
def test_has_mimetype_no_sub_type(self, generic_conf_file):
|
pass
|
||||||
generic_conf_file.sub_type = ''
|
|
||||||
assert generic_conf_file.has_mimetype is False
|
|
||||||
|
|
||||||
def test_has_extension(self, temp_file, temp_file_no_ext):
|
def get_property_builtin(self):
|
||||||
assert temp_file.has_extension is True
|
pass
|
||||||
print(temp_file_no_ext.extension)
|
|
||||||
assert temp_file_no_ext.has_extension is False
|
|
||||||
|
|
||||||
def test_set_property(self, temp_file):
|
def get_property_user_defined(self):
|
||||||
temp_file.set_property('test', True)
|
pass
|
||||||
assert temp_file.get_property('test') is True
|
|
||||||
# TODO: split asserts into two tests
|
|
||||||
assert temp_file.get_property('wrong') is None
|
|
||||||
|
|
||||||
@skip
|
def test_has_mimetype_no_main_type(self):
|
||||||
def test_marked_dangerous(self, file_marked_all_parameterized):
|
pass
|
||||||
file_marked_all_parameterized.make_dangerous()
|
|
||||||
assert file_marked_all_parameterized.is_dangerous is True
|
|
||||||
# Should work regardless of weird paths??
|
|
||||||
# Should check file path alteration behavior as well
|
|
||||||
|
|
||||||
@xfail
|
def test_has_mimetype_no_sub_type(self):
|
||||||
def test_has_symlink(self, tmpdir):
|
pass
|
||||||
file_path = tmpdir.join('test.txt')
|
|
||||||
file_path.write('testing')
|
|
||||||
file_path = file_path.strpath
|
|
||||||
symlink_path = tmpdir.join('symlinked.txt')
|
|
||||||
symlink_path = symlink_path.strpath
|
|
||||||
os.symlink(file_path, symlink_path)
|
|
||||||
file = FileBase(file_path, file_path)
|
|
||||||
symlink = FileBase(symlink_path, symlink_path)
|
|
||||||
assert file.is_symlink is False
|
|
||||||
assert symlink.is_symlink is True
|
|
||||||
|
|
||||||
@xfail
|
def test_has_extension_true(self):
|
||||||
def test_has_symlink_fixture(self, symlink_file):
|
pass
|
||||||
assert symlink_file.is_symlink is True
|
|
||||||
|
|
||||||
@skip
|
def test_has_extension_false(self):
|
||||||
def test_force_ext_change(self, generic_conf_file):
|
pass
|
||||||
assert generic_conf_file.has_extension
|
|
||||||
assert generic_conf_file.get_property('extension') == '.conf'
|
|
||||||
assert os.path.splitext(generic_conf_file.dst_path)[1] == '.conf'
|
|
||||||
generic_conf_file.force_ext('.txt')
|
|
||||||
assert os.path.splitext(generic_conf_file.dst_path)[1] == '.txt'
|
|
||||||
assert generic_conf_file.get_property('extension') == '.txt'
|
|
||||||
# should be able to handle weird paths
|
|
||||||
|
|
||||||
@skip
|
def test_add_new_description(self):
|
||||||
def test_force_ext_correct(self, generic_conf_file):
|
pass
|
||||||
assert generic_conf_file.has_extension
|
|
||||||
assert generic_conf_file.get_property('extension') == '.conf'
|
|
||||||
generic_conf_file.force_ext('.conf')
|
|
||||||
assert os.path.splitext(generic_conf_file.dst_path)[1] == '.conf'
|
|
||||||
assert generic_conf_file.get_property('force_ext') is None
|
|
||||||
# shouldn't change a file's extension if it already is right
|
|
||||||
|
|
||||||
@xfail
|
def test_add_description_exists(self):
|
||||||
def test_create_metadata_file(self, temp_file):
|
pass
|
||||||
metadata_file_path = temp_file.create_metadata_file('.metadata.txt')
|
|
||||||
with open(metadata_file_path, 'w+') as metadata_file:
|
def test_add_new_error(self):
|
||||||
metadata_file.write('Have some metadata!')
|
pass
|
||||||
# Shouldn't be able to make a metadata file with no extension
|
|
||||||
assert temp_file.create_metadata_file('') is False
|
def test_add_error_exists(self):
|
||||||
# if metadata file already exists
|
pass
|
||||||
# if there is no metadata to write should this work?
|
|
||||||
|
def test_normal_file_mark_dangerous(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_normal_file_mark_dangerous_filename_change(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_normal_file_mark_dangerous_add_description(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_dangerous_file_mark_dangerous(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def test_safe_copy(self):
|
def test_safe_copy(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def test_force_ext_change(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_force_ext_correct(self, generic_conf_file):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_create_metadata_file_new(self, temp_file):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_create_metadata_file_already_exists(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
@skip
|
@skip
|
||||||
class TestKittenGroomerBase:
|
class TestKittenGroomerBase:
|
||||||
|
|
Loading…
Reference in New Issue