Skip to content
Snippets Groups Projects
Commit d3872d18 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

Merge branch 'f-filesystem-response-url' into 'dev'

TST: filestem response url

See merge request !64
parents 23922244 4b73d0de
No related branches found
No related tags found
1 merge request!64TST: filestem response url
Pipeline #40110 passed
...@@ -60,6 +60,27 @@ def test_file_system_returns_ids(clear_database): ...@@ -60,6 +60,27 @@ def test_file_system_returns_ids(clear_database):
assert search in str(body) assert search in str(body)
def test_file_system_returns_correct_url_with_proxy(clear_database):
c = db.get_connection()
resp = c.retrieve(
entity_uri_segments=["FileSystem"],
headers={"X-Forwarded-Proto": "myscheme"},
reconnect=True)
body = resp.read()
print(body)
search = 'url="myscheme://'
assert search in str(body)
resp = c.retrieve(
entity_uri_segments=["FileSystem"],
headers={"Forwarded": "by=byid;for=forid;host=hostaddress;proto=myother"},
reconnect=True)
body = resp.read()
print(body)
search = 'url="myother://'
assert search in str(body)
def test_sat_query_with_leading_slash(clear_database): def test_sat_query_with_leading_slash(clear_database):
upload_file = open("test.dat", "w") upload_file = open("test.dat", "w")
upload_file.write("hello world\n") upload_file.write("hello world\n")
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
@author: fitschen @author: fitschen
""" """
from nose.tools import assert_equal, assert_is_not_none, assert_true # @UnresolvedImport
import caosdb as h import caosdb as h
import os import os
from caosdb.exceptions import CaosDBException from caosdb.exceptions import CaosDBException
...@@ -52,23 +51,15 @@ Datensätzen ...@@ -52,23 +51,15 @@ Datensätzen
Description oder einer Zahl''' Description oder einer Zahl'''
def setup_module(): def setup_function(function):
try: try:
h.execute_query("FIND Complex*").delete() h.execute_query("FIND ENTITY *").delete()
except Exception as e:
print(e)
try:
h.execute_query("FIND ReferenceProperty").delete()
except Exception as e:
print(e)
try:
h.execute_query("FIND Simple*").delete()
except Exception as e: except Exception as e:
print(e) print(e)
def teardown_module(): def teardown_function(function):
setup_module() setup_function(function)
def test_tenpoints1_1(): def test_tenpoints1_1():
...@@ -77,7 +68,6 @@ def test_tenpoints1_1(): ...@@ -77,7 +68,6 @@ def test_tenpoints1_1():
enthalten (Gewicht, Beschreibung, Identifkationsnummern, etc.) enthalten (Gewicht, Beschreibung, Identifkationsnummern, etc.)
''' '''
try:
c = h.Container() c = h.Container()
c.append( c.append(
h.Property( h.Property(
...@@ -110,18 +100,12 @@ def test_tenpoints1_1(): ...@@ -110,18 +100,12 @@ def test_tenpoints1_1():
name='SimpleDatetimeProperty')) name='SimpleDatetimeProperty'))
c.insert() c.insert()
finally:
try:
c.delete()
except BaseException:
pass
def test_tenpoints1_2(): def test_tenpoints1_2():
''' '''
1.2 Einfügen von RecordTypes, die zusätzlich Dateien referenzieren 1.2 Einfügen von RecordTypes, die zusätzlich Dateien referenzieren
''' '''
try:
c = h.Container() c = h.Container()
c.append( c.append(
h.Property( h.Property(
...@@ -160,11 +144,6 @@ def test_tenpoints1_2(): ...@@ -160,11 +144,6 @@ def test_tenpoints1_2():
name='SimpleFileProperty')) name='SimpleFileProperty'))
c.insert() c.insert()
finally:
try:
c.delete()
except BaseException:
pass
def test_tenpoints1_3(): def test_tenpoints1_3():
...@@ -173,7 +152,6 @@ def test_tenpoints1_3(): ...@@ -173,7 +152,6 @@ def test_tenpoints1_3():
andere RecordTypes enthalten andere RecordTypes enthalten
''' '''
try:
c = h.Container() c = h.Container()
c.append( c.append(
h.Property( h.Property(
...@@ -223,11 +201,6 @@ def test_tenpoints1_3(): ...@@ -223,11 +201,6 @@ def test_tenpoints1_3():
) )
c.insert() c.insert()
finally:
try:
c.delete()
except BaseException:
pass
def test_tenpoints1_4(): def test_tenpoints1_4():
...@@ -245,7 +218,6 @@ def test_tenpoints1_5(): ...@@ -245,7 +218,6 @@ def test_tenpoints1_5():
RecordTypes / Properties RecordTypes / Properties
''' '''
try:
c = h.Container() c = h.Container()
c.append( c.append(
h.Property( h.Property(
...@@ -316,28 +288,6 @@ def test_tenpoints1_5(): ...@@ -316,28 +288,6 @@ def test_tenpoints1_5():
cr2.insert() cr2.insert()
finally:
try:
cr2.delete()
except BaseException:
pass
try:
cr1.delete()
except BaseException:
pass
try:
sr.delete()
except BaseException:
pass
try:
d.delete()
except BaseException:
pass
try:
c.delete()
except BaseException:
pass
def test_tenpoints2_1AND2_2(): def test_tenpoints2_1AND2_2():
''' '''
...@@ -346,7 +296,6 @@ def test_tenpoints2_1AND2_2(): ...@@ -346,7 +296,6 @@ def test_tenpoints2_1AND2_2():
Datensätzen Datensätzen
''' '''
try:
"""data model.""" """data model."""
c = h.Container() c = h.Container()
c.append( c.append(
...@@ -446,34 +395,20 @@ def test_tenpoints2_1AND2_2(): ...@@ -446,34 +395,20 @@ def test_tenpoints2_1AND2_2():
d.insert() d.insert()
e = d.get_entity_by_name("SimpleRecord") e = d.get_entity_by_name("SimpleRecord")
assert_is_not_none(e) assert e is not None
assert_true(e.is_valid()) assert e.is_valid()
fp = e.get_property("SimpleFileProperty") fp = e.get_property("SimpleFileProperty")
assert_is_not_none(fp) assert fp is not None
assert_is_not_none(fp.value) assert fp.value is not None
fr = d.get_entity_by_name("SimpleFileRecord") fr = d.get_entity_by_name("SimpleFileRecord")
assert_is_not_none(fr) assert fr is not None
assert_true(fr.is_valid()) assert fr.is_valid()
assert_is_not_none(fr.id) assert fr.id is not None
assert_equal(int(fp.value), fr.id) assert int(fp.value) == fr.id
print(d) print(d)
finally:
try:
d.delete()
except BaseException:
pass
try:
c.delete()
except BaseException:
pass
try:
os.remove("test.dat")
except BaseException:
pass
try:
"""insert file via dropOffBox.""" """insert file via dropOffBox."""
dob = h.DropOffBox().sync() dob = h.DropOffBox().sync()
if os.path.isdir(dob.path): if os.path.isdir(dob.path):
...@@ -483,17 +418,11 @@ def test_tenpoints2_1AND2_2(): ...@@ -483,17 +418,11 @@ def test_tenpoints2_1AND2_2():
import shutil import shutil
shutil.move("test.dat", dob.path) shutil.move("test.dat", dob.path)
fo = h.File(path='testfiles/testfile2', pickup="test.dat").insert() fo = h.File(path='testfiles/testfile2', pickup="test.dat").insert()
finally:
try:
fo.delete()
except BaseException:
pass
def test_tenpoints2_3(): def test_tenpoints2_3():
'''2.3 Verwendung von Einheiten''' '''2.3 Verwendung von Einheiten'''
try:
"""insert simple property with unit.""" """insert simple property with unit."""
p1 = h.Property(name='unittestproperty', datatype='double', unit='m') p1 = h.Property(name='unittestproperty', datatype='double', unit='m')
p1.insert() p1.insert()
...@@ -501,7 +430,7 @@ def test_tenpoints2_3(): ...@@ -501,7 +430,7 @@ def test_tenpoints2_3():
'''subtyping with unit inheritance''' '''subtyping with unit inheritance'''
p2 = h.Property(name='SubTypeOfUnitTestProperty').add_parent(id=p1.id) p2 = h.Property(name='SubTypeOfUnitTestProperty').add_parent(id=p1.id)
p2.insert() p2.insert()
assert_equal('m', p2.unit) assert 'm' == p2.unit
'''implement property''' '''implement property'''
rt = h.RecordType( rt = h.RecordType(
...@@ -513,29 +442,15 @@ def test_tenpoints2_3(): ...@@ -513,29 +442,15 @@ def test_tenpoints2_3():
rtid = rt.id rtid = rt.id
rt = h.RecordType(id=rtid).retrieve() rt = h.RecordType(id=rtid).retrieve()
print(rt) print(rt)
assert_equal(p2.id, rt.get_properties()[0].id) assert p2.id == rt.get_properties()[0].id
assert_equal('m', rt.get_properties()[0].unit) assert 'm' == rt.get_properties()[0].unit
finally:
try:
rt.delete()
except BaseException:
pass
try:
p2.delete()
except BaseException:
pass
try:
p1.delete()
except BaseException:
pass
def test_tenpoints2_4(): def test_tenpoints2_4():
'''2.4 Nachtägliches Annotieren von Datensätzen, z.B. hinzufügen einer '''2.4 Nachtägliches Annotieren von Datensätzen, z.B. hinzufügen einer
Description oder einer Zahl''' Description oder einer Zahl'''
try:
c = h.Container() c = h.Container()
c.append( c.append(
h.Property( h.Property(
...@@ -650,28 +565,6 @@ def test_tenpoints2_4(): ...@@ -650,28 +565,6 @@ def test_tenpoints2_4():
c.get_entity_by_name("CommentProperty"), c.get_entity_by_name("CommentProperty"),
value="I looove this record!!!!!11.").update() value="I looove this record!!!!!11.").update()
finally:
try:
cr2.delete()
except BaseException:
pass
try:
cr1.delete()
except BaseException:
pass
try:
e.delete()
except BaseException:
pass
try:
d.delete()
except BaseException:
pass
try:
c.delete()
except BaseException:
pass
def test_existence(): def test_existence():
...@@ -693,10 +586,3 @@ def test_existence(): ...@@ -693,10 +586,3 @@ def test_existence():
print("SimpleTextProperty does exist!") print("SimpleTextProperty does exist!")
p.delete() p.delete()
def test_cleanup():
try:
h.execute_query("FIND Simple*").delete()
except BaseException:
pass
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment