diff --git a/tests/test_file.py b/tests/test_file.py index 3398707728793b993d17af0072bca195ec85ee69..e56ff18b424c2a402c0d8b1ae5cc1e0386377acd 100644 --- a/tests/test_file.py +++ b/tests/test_file.py @@ -592,6 +592,7 @@ def test_insert_files_in_dir(): test_file2.write("hello world2\n") test_file2.close() + # DRY-RUN c = models.Container() c.retrieve( unique=False, @@ -601,11 +602,8 @@ def test_insert_files_in_dir(): assert_is_not_none(c.messages["Info", 0]) assert_equal(c.messages["Info", 0][0], "Files count in testfolder/: 2") - #assert_equal(c[0].name, "test.dat") - #assert_equal(c[0].path, "/testfolder/subfolder/test.dat") - #assert_equal(c[1].name, "test2.dat") - #assert_equal(c[1].path, "/testfolder/subfolder/test2.dat") + # ACTUAL RUN d = models.Container() d.insert( unique=False, @@ -616,10 +614,6 @@ def test_insert_files_in_dir(): assert_equal(d.messages["Info", 0][0], "Files count in testfolder/: 2") assert_true(d[0].is_valid()) - #assert_equal(d[0].name, "test.dat") - #assert_equal(d[0].path, "/testfolder/subfolder/test.dat") - #assert_equal(d[1].name, "test2.dat") - #assert_equal(d[1].path, "/testfolder/subfolder/test2.dat") # create a new file and call insertFilesInDir again test_file3 = open(path + "/test3.dat", "w") @@ -676,6 +670,48 @@ def test_insert_files_in_dir(): pass +@with_setup(setup, teardown) +def test_insert_files_in_dir_regex(): + # TODO + path = get_config().get("IntegrationTests", + "test_files.test_insert_files_in_dir.local") + "testfolder/" + path_on_server = get_config().get("IntegrationTests", + "test_files.test_insert_files_in_dir.server") + "testfolder/" + try: + os.makedirs(path) + os.makedirs(path + "subfolder/") + test_file1 = open(path + "subfolder/test.dat", "w") + test_file1.write("hello world\n") + test_file1.close() + + test_file2 = open(path + "subfolder/test2.dat", "w") + test_file2.write("hello world2\n") + test_file2.close() + + c = models.Container() + c.retrieve( + unique=False, + raise_exception_on_error=False, + flags={ + "InsertFilesInDir": "-e test " + + path_on_server}) + 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 len(c) == 0 + + + finally: + try: + c.delete() + except BaseException: + pass + try: + shutil.rmtree(path) + except BaseException: + pass + + + @with_setup(setup, teardown) def test_thumbnails(): file_ = models.File(name="TestFile",