Skip to content
Snippets Groups Projects
Commit 8fb25a0d authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

Merge branch 'f-test_insert_review' into 'f-test_insert_files_in_dir'

F test fixes

See merge request caosdb/caosdb-pyinttest!22
parents decd849a 2690236e
Branches
Tags
No related merge requests found
...@@ -37,11 +37,12 @@ from nose.tools import (assert_equal, assert_false, # @UnresolvedImport ...@@ -37,11 +37,12 @@ from nose.tools import (assert_equal, assert_false, # @UnresolvedImport
assert_is_not_none, assert_raises, assert_true, assert_is_not_none, assert_raises, assert_true,
nottest, with_setup) nottest, with_setup)
from caosdb import execute_query, get_config, get_connection, Info from caosdb import Info
from caosdb import administration as admin
from caosdb import execute_query, get_config, get_connection
from caosdb.common import models from caosdb.common import models
from caosdb.exceptions import EntityError from caosdb.exceptions import EntityError
from caosdb.utils.checkFileSystemConsistency import runCheck from caosdb.utils.checkFileSystemConsistency import runCheck
from caosdb import administration as admin
def setup_module(): def setup_module():
...@@ -49,9 +50,8 @@ def setup_module(): ...@@ -49,9 +50,8 @@ def setup_module():
def setup(): def setup():
upload_file = open("test.dat", "w") with open("test.dat", "w") as upload_file:
upload_file.write("hello world\n") upload_file.write("hello world\n")
upload_file.close()
os.makedirs("testfolder/subfolder") os.makedirs("testfolder/subfolder")
with open("testfolder/test1.dat", "w") as upload_file: with open("testfolder/test1.dat", "w") as upload_file:
upload_file.write("hello world\n") upload_file.write("hello world\n")
...@@ -354,6 +354,9 @@ def test_consistency_file_was_modified(): ...@@ -354,6 +354,9 @@ def test_consistency_file_was_modified():
assert_equal(c.messages["Info", 0][0], "File system is consistent.") assert_equal(c.messages["Info", 0][0], "File system is consistent.")
# run consistency check with modified warning) # run consistency check with modified warning)
# TODO fix
# This smells badly. The argument is meant to transport the location
# that is checked. Understanding of the code is difficult.
c = runCheck(None, "-c FILE_WAS_MODIFIED") c = runCheck(None, "-c FILE_WAS_MODIFIED")
assert_is_not_none(c.messages["Error", 0]) assert_is_not_none(c.messages["Error", 0])
assert_equal( assert_equal(
...@@ -396,9 +399,8 @@ def test_consistency_file_was_modified(): ...@@ -396,9 +399,8 @@ def test_consistency_file_was_modified():
@with_setup(setup, teardown) @with_setup(setup, teardown)
def test_consistency_file_does_not_exist(): def test_consistency_file_does_not_exist():
try: try:
upload_file = open("test.dat", "w") with open("test.dat", "w") as upload_file:
upload_file.write("hello world\n") upload_file.write("hello world\n")
upload_file.close()
file_ = models.File(name="TestConsistency1", file_ = models.File(name="TestConsistency1",
description="Testfile Desc", description="Testfile Desc",
path="debug/test_file_storage_consistency", path="debug/test_file_storage_consistency",
...@@ -413,6 +415,9 @@ def test_consistency_file_does_not_exist(): ...@@ -413,6 +415,9 @@ def test_consistency_file_does_not_exist():
assert_equal(c.messages["Info", 0][0], assert_equal(c.messages["Info", 0][0],
"File system below debug/ is consistent.") "File system below debug/ is consistent.")
# TODO fix
# This smells badly. The argument is meant to transport the location
# that is checked. Understanding of the code is difficult.
c = runCheck(None, "-c FILE_DOES_NOT_EXIST") c = runCheck(None, "-c FILE_DOES_NOT_EXIST")
assert_is_not_none(c.messages["Error", 0]) assert_is_not_none(c.messages["Error", 0])
assert_equal( assert_equal(
...@@ -453,6 +458,9 @@ def test_consistency_unknown_file(): ...@@ -453,6 +458,9 @@ def test_consistency_unknown_file():
assert_is_not_none(c.messages["Info", 0]) assert_is_not_none(c.messages["Info", 0])
assert_equal(c.messages["Info", 0][0], "File system is consistent.") assert_equal(c.messages["Info", 0][0], "File system is consistent.")
# TODO fix
# This smells badly. The argument is meant to transport the location
# that is checked. Understanding of the code is difficult.
c = runCheck(None, "-c UNKNOWN_FILE") c = runCheck(None, "-c UNKNOWN_FILE")
assert_is_not_none(c.messages["Warning", 0]) assert_is_not_none(c.messages["Warning", 0])
assert_equal(c.messages["Warning", 0][0], 'debug/: Unknown file.') assert_equal(c.messages["Warning", 0][0], 'debug/: Unknown file.')
...@@ -701,10 +709,10 @@ def test_insert_files_in_dir_regex(): ...@@ -701,10 +709,10 @@ def test_insert_files_in_dir_regex():
"InsertFilesInDir": "-e test " + "InsertFilesInDir": "-e test " +
path_on_server}) path_on_server})
assert c.messages["Warning", 2] is not None assert c.messages["Warning", 2] is not None
assert c.messages["Warning", 2][0] == "Explicitly excluded directory or file: {}".format(path_on_server[:-1]) assert c.messages["Warning", 2][0] == "Explicitly excluded directory or file: {}".format(
path_on_server[:-1])
assert len(c) == 0 assert len(c) == 0
finally: finally:
try: try:
c.delete() c.delete()
...@@ -716,7 +724,6 @@ def test_insert_files_in_dir_regex(): ...@@ -716,7 +724,6 @@ def test_insert_files_in_dir_regex():
pass pass
@with_setup(setup, teardown) @with_setup(setup, teardown)
def test_thumbnails(): def test_thumbnails():
file_ = models.File(name="TestFile", file_ = models.File(name="TestFile",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment