Skip to content
Snippets Groups Projects
Verified Commit c25e1396 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

enable all tests

parent 96bd4371
No related branches found
No related tags found
2 merge requests!50Draft: ENH: file system: core,!8Draft: F filesystem
Pipeline #7933 failed
...@@ -73,6 +73,21 @@ def teardown(): ...@@ -73,6 +73,21 @@ def teardown():
except Exception as e: except Exception as e:
print(e) print(e)
# remove directories
body = get_connection().retrieve(
entity_uri_segments=[
"Entity"],
query_dict={"query": "FIND ENTITY WITH ID>99"},
reconnect=True).read()
xml = etree.fromstring(body)
delete_ids = []
for d in xml.xpath('/Response/Directory'):
delete_ids.append(d.get("id"))
get_connection().delete(
entity_uri_segments=[
"Entity", "&".join(delete_ids)],
reconnect=True)
def test_file_with_space(): def test_file_with_space():
file_ = models.File(name="TestFile", file_ = models.File(name="TestFile",
...@@ -700,7 +715,6 @@ def test_insert_files_in_dir_regex(): ...@@ -700,7 +715,6 @@ def test_insert_files_in_dir_regex():
pass pass
@mark.xfail(reason="refactoring filesystem")
def test_thumbnails(): def test_thumbnails():
file_ = models.File(name="TestFile", file_ = models.File(name="TestFile",
description="Testfile Desc", description="Testfile Desc",
...@@ -717,3 +731,86 @@ def test_thumbnails(): ...@@ -717,3 +731,86 @@ def test_thumbnails():
xml = etree.fromstring(body) xml = etree.fromstring(body)
assert xml.xpath('/Response/dir/file')[0].get( assert xml.xpath('/Response/dir/file')[0].get(
"thumbnail")[-41:] == "/Thumbnails/testfiles/thumbnails_test.dat" "thumbnail")[-41:] == "/Thumbnails/testfiles/thumbnails_test.dat"
def test_auto_create_parent_dirs():
file_ = models.File(name="TestFile",
path="A/B/C/test.dat",
file="test.dat")
file_.set_flag("autoCreateDirs", "true")
file_.insert()
body = get_connection().retrieve(
entity_uri_segments=[
"FileSystem",
""],
reconnect=True).read()
xml = etree.fromstring(body)
assert len(xml.xpath('/Response/dir')) == 1
root = xml.xpath('/Response/dir')[0]
assert root.get("name") == "/"
assert root.get("path") == ""
assert root.get("url")[-12:] == "/FileSystem/"
assert len(root.xpath('dir')) == 1
assert len(root.xpath('file')) == 0
dir_a = root.xpath('dir')[0]
assert dir_a.get("name") == "A/"
assert dir_a.get("url")[-14:] == "/FileSystem/A/"
body = get_connection().retrieve(
entity_uri_segments=[
"FileSystem",
"A", ""],
reconnect=True).read()
xml = etree.fromstring(body)
assert len(xml.xpath('/Response/dir')) == 1
dir_a = xml.xpath('/Response/dir')[0]
assert dir_a.get("name") == "A/"
assert dir_a.get("path") == "A"
assert dir_a.get("url")[-14:] == "/FileSystem/A/"
assert len(dir_a.xpath('dir')) == 1
assert len(dir_a.xpath('file')) == 0
dir_b = dir_a.xpath('dir')[0]
assert dir_b.get("name") == "B/"
assert dir_b.get("url")[-16:] == "/FileSystem/A/B/"
body = get_connection().retrieve(
entity_uri_segments=[
"FileSystem",
"A", "B", ""],
reconnect=True).read()
xml = etree.fromstring(body)
assert len(xml.xpath('/Response/dir')) == 1
dir_b = xml.xpath('/Response/dir')[0]
assert len(dir_b.xpath('dir')) == 1
assert len(dir_b.xpath('file')) == 0
dir_c = dir_b.xpath('dir')[0]
assert dir_c.get("name") == "C/"
assert dir_c.get("url")[-18:] == "/FileSystem/A/B/C/"
body = get_connection().retrieve(
entity_uri_segments=[
"FileSystem",
"A", "B", "C", ""],
reconnect=True).read()
xml = etree.fromstring(body)
assert len(xml.xpath('/Response/dir')) == 1
dir_c = xml.xpath('/Response/dir')[0]
assert len(dir_c.xpath('dir')) == 0
assert len(dir_c.xpath('file')) == 1
file_1 = dir_c.xpath("file")[0]
assert file_1.get("name") == "test.dat"
assert file_1.get("url")[-26:] == "/FileSystem/A/B/C/test.dat"
...@@ -30,7 +30,6 @@ from nose.tools import (assert_equal, assert_is_not_none, # @UnresolvedImport ...@@ -30,7 +30,6 @@ from nose.tools import (assert_equal, assert_is_not_none, # @UnresolvedImport
assert_not_equal, assert_true, nottest, assert_not_equal, assert_true, nottest,
with_setup) with_setup)
from pytest import mark
import caosdb as db import caosdb as db
from caosdb import (Container, Info, Property, Record, RecordType, from caosdb import (Container, Info, Property, Record, RecordType,
execute_query) execute_query)
...@@ -44,7 +43,6 @@ def setup(): ...@@ -44,7 +43,6 @@ def setup():
print(e) print(e)
@mark.xfail(reason="refactoring filesystem")
@with_setup(setup=setup, teardown=setup) @with_setup(setup=setup, teardown=setup)
def test_file_system_returns_ids(): def test_file_system_returns_ids():
upload_file = open("test.dat", "w") upload_file = open("test.dat", "w")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment