diff --git a/tests/test_file.py b/tests/test_file.py index 013a470d21dd62b278ed84d8aa4047e31f84c79d..bb17d8da6a522cd1e3cb3853d436e0adb3577975 100644 --- a/tests/test_file.py +++ b/tests/test_file.py @@ -5,6 +5,8 @@ # # Copyright (C) 2018 Research Group Biomedical Physics, # Max-Planck-Institute for Dynamics and Self-Organization Göttingen +# Copyright (C) 2019 IndiScale GmbH (info@indiscale.com) +# Copyright (C) 2019 Daniel Hornung (d.hornung@indiscale.com) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -35,7 +37,7 @@ from nose.tools import (assert_equal, assert_false, # @UnresolvedImport assert_is_not_none, assert_raises, assert_true, nottest, with_setup) -from caosdb import execute_query, get_config, get_connection +from caosdb import execute_query, get_config, get_connection, Info from caosdb.common import models from caosdb.exceptions import EntityError from caosdb.utils.checkFileSystemConsistency import runCheck @@ -50,13 +52,10 @@ def setup(): upload_file.write("hello world\n") upload_file.close() os.mkdir("testfolder") - os.mkdir("testfolder/subfolder") - upload_file = open("testfolder/test1.dat", "w") - upload_file.write("hello world\n") - upload_file.close() - upload_file = open("testfolder/subfolder/test2.dat", "w") - upload_file.write("hello world\n") - upload_file.close() + with open("testfolder/test1.dat", "w") as upload_file: + upload_file.write("hello world\n") + with open("testfolder/subfolder/test2.dat", "w") as upload_file: + upload_file.write("hello world\n") def teardown(): @@ -79,7 +78,7 @@ def teardown(): @with_setup(setup, teardown) -def test_file_with_empty_space(): +def test_file_with_space(): file_ = models.File(name="TestFile", description="Testfile Desc", path="testfiles/test file with spaces.dat", @@ -696,3 +695,10 @@ def test_thumbnails(): # TODO find a better way to check this assert_equal(xml[1][0].get("thumbnail")[-41:], "/Thumbnails/testfiles/thumbnails_test.dat") + + +@with_setup(setup, teardown) +def test_empty_folder(): + """The file system has has problems with empty subfolders.""" + os.mkdir("testfolder/subfolder") + Info()