Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CaosDB Python Integration Tests
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Python Integration Tests
Commits
a13ee624
Verified
Commit
a13ee624
authored
Jun 26, 2020
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
MAINT: removed nose tests form test_file
parent
accf7e84
No related branches found
No related tags found
2 merge requests
!50
Draft: ENH: file system: core
,
!8
Draft: F filesystem
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_file.py
+56
-61
56 additions, 61 deletions
tests/test_file.py
with
56 additions
and
61 deletions
tests/test_file.py
+
56
−
61
View file @
a13ee624
...
@@ -5,8 +5,9 @@
...
@@ -5,8 +5,9 @@
#
#
# Copyright (C) 2018 Research Group Biomedical Physics,
# Copyright (C) 2018 Research Group Biomedical Physics,
# Max-Planck-Institute for Dynamics and Self-Organization Göttingen
# Max-Planck-Institute for Dynamics and Self-Organization Göttingen
# Copyright (C) 2019 IndiScale GmbH (info@indiscale.com)
# Copyright (C) 2019-2020 IndiScale GmbH <info@indiscale.com>
# Copyright (C) 2019 Daniel Hornung (d.hornung@indiscale.com)
# Copyright (C) 2019 Daniel Hornung <d.hornung@indiscale.com>
# Copyright (C) 2020 Timm Fitschen <t.fitschen@indiscale.com>
#
#
# This program is free software: you can redistribute it and/or modify
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# it under the terms of the GNU Affero General Public License as
...
@@ -34,9 +35,6 @@ from sys import maxsize as maxint
...
@@ -34,9 +35,6 @@ from sys import maxsize as maxint
from
lxml
import
etree
from
lxml
import
etree
from
pytest
import
raises
,
mark
from
pytest
import
raises
,
mark
from
nose.tools
import
(
assert_equal
,
assert_false
,
# @UnresolvedImport
assert_is_not_none
,
assert_raises
,
assert_true
,
nottest
)
from
caosdb
import
Info
from
caosdb
import
Info
from
caosdb
import
administration
as
admin
from
caosdb
import
administration
as
admin
...
@@ -86,8 +84,8 @@ def test_file_with_space():
...
@@ -86,8 +84,8 @@ def test_file_with_space():
file
=
"
test.dat
"
)
file
=
"
test.dat
"
)
file_
.
insert
()
file_
.
insert
()
qfile
=
execute_query
(
"
FIND FILE TestFile
"
,
unique
=
True
)
qfile
=
execute_query
(
"
FIND FILE TestFile
"
,
unique
=
True
)
assert
_equal
(
qfile
.
id
,
file_
.
id
)
assert
qfile
.
id
==
file_
.
id
assert
_equal
(
qfile
.
path
,
"
/testfiles/test file with spaces.dat
"
)
assert
qfile
.
path
==
"
/testfiles/test file with spaces.dat
"
qfile
.
download
(
"
test2.dat
"
)
qfile
.
download
(
"
test2.dat
"
)
...
@@ -108,7 +106,7 @@ def test_pickup_file():
...
@@ -108,7 +106,7 @@ def test_pickup_file():
hex
(
randint
(
0
,
maxint
)),
hex
(
randint
(
0
,
maxint
)),
pickup
=
"
testpickup.dat
"
)
pickup
=
"
testpickup.dat
"
)
file_
.
insert
()
file_
.
insert
()
assert
_
is
_
not
_n
one
(
file_
.
id
)
assert
file_
.
id
is
not
N
one
def
test_pickup_folder
():
def
test_pickup_folder
():
...
@@ -162,8 +160,8 @@ def test_file4():
...
@@ -162,8 +160,8 @@ def test_file4():
c
=
models
.
Container
()
c
=
models
.
Container
()
c
.
extend
([
file1_
,
file2_
])
c
.
extend
([
file1_
,
file2_
])
c
.
insert
()
c
.
insert
()
assert
_
is
_
not
_n
one
(
file1_
.
id
)
assert
file1_
.
id
is
not
N
one
assert
_
is
_
not
_n
one
(
file2_
.
id
)
assert
file2_
.
id
is
not
N
one
finally
:
finally
:
try
:
try
:
c
.
delete
()
c
.
delete
()
...
@@ -186,8 +184,8 @@ def test_upload_complete_folder():
...
@@ -186,8 +184,8 @@ def test_upload_complete_folder():
c
=
models
.
Container
()
c
=
models
.
Container
()
c
.
extend
([
file1_
,
file2_
])
c
.
extend
([
file1_
,
file2_
])
c
.
insert
()
c
.
insert
()
assert
_
is
_
not
_n
one
(
file1_
.
id
)
assert
file1_
.
id
is
not
N
one
assert
_
is
_
not
_n
one
(
file2_
.
id
)
assert
file2_
.
id
is
not
N
one
c
.
delete
()
c
.
delete
()
c
=
models
.
Container
()
c
=
models
.
Container
()
...
@@ -198,7 +196,7 @@ def test_upload_complete_folder():
...
@@ -198,7 +196,7 @@ def test_upload_complete_folder():
file
=
"
testfolder
"
)
file
=
"
testfolder
"
)
c
.
append
(
folder_
)
c
.
append
(
folder_
)
c
.
insert
()
c
.
insert
()
assert
_is_not_none
(
folder_
.
id
)
assert
folder_
.
id
is
not
None
c
.
delete
()
c
.
delete
()
...
@@ -275,8 +273,8 @@ def test_file7():
...
@@ -275,8 +273,8 @@ def test_file7():
file
=
"
test.dat
"
)
file
=
"
test.dat
"
)
file_
.
insert
()
file_
.
insert
()
assert
_
is
_
not
_n
one
(
file_
.
id
)
assert
file_
.
id
is
not
N
one
assert
_true
(
file_
.
is_valid
()
)
assert
file_
.
is_valid
()
is
True
# pickup_folder
# pickup_folder
# and try to store it to testfiles2/
# and try to store it to testfiles2/
...
@@ -302,7 +300,8 @@ def test_file7():
...
@@ -302,7 +300,8 @@ def test_file7():
path
=
"
testfiles2/
"
,
path
=
"
testfiles2/
"
,
pickup
=
"
path
"
)
pickup
=
"
path
"
)
assert_raises
(
EntityError
,
folder_
.
insert
)
with
raises
(
EntityError
):
folder_
.
insert
finally
:
finally
:
try
:
try
:
folder_
.
delete
()
folder_
.
delete
()
...
@@ -470,20 +469,20 @@ def test_insert_files_in_dir_error1():
...
@@ -470,20 +469,20 @@ def test_insert_files_in_dir_error1():
"
InsertFilesInDir
"
:
"
/root
"
})
"
InsertFilesInDir
"
:
"
/root
"
})
# If this fails, it is likely that the server runs with root permissions
# If this fails, it is likely that the server runs with root permissions
# which is discouraged.
# which is discouraged.
assert
_is_not_none
(
c
.
messages
[
"
Error
"
,
0
]
)
assert
c
.
messages
[
"
Error
"
,
0
]
is
not
None
assert
_true
(
c
.
messages
[
"
Error
"
,
0
][
0
].
startswith
(
assert
c
.
messages
[
"
Error
"
,
0
][
0
].
startswith
(
"
Cannot read or enter the desired directory.
"
)
)
"
Cannot read or enter the desired directory.
"
)
is
True
c
=
models
.
Container
()
c
=
models
.
Container
()
c
.
retrieve
(
unique
=
False
,
raise_exception_on_error
=
False
,
c
.
retrieve
(
unique
=
False
,
raise_exception_on_error
=
False
,
flags
=
{
"
InsertFilesInDir
"
:
"
non-existent
"
})
flags
=
{
"
InsertFilesInDir
"
:
"
non-existent
"
})
assert
_is_not_none
(
c
.
messages
[
"
Error
"
,
0
]
)
assert
c
.
messages
[
"
Error
"
,
0
]
is
not
None
assert
_true
(
c
.
messages
[
"
Error
"
,
0
][
0
].
startswith
(
"
No such directory
"
)
)
assert
c
.
messages
[
"
Error
"
,
0
][
0
].
startswith
(
"
No such directory
"
)
is
True
c
.
insert
(
raise_exception_on_error
=
False
,
flags
=
{
c
.
insert
(
raise_exception_on_error
=
False
,
flags
=
{
"
InsertFilesInDir
"
:
"
non-existent
"
})
"
InsertFilesInDir
"
:
"
non-existent
"
})
assert
_is_not_none
(
c
.
messages
[
"
Error
"
,
0
]
)
assert
c
.
messages
[
"
Error
"
,
0
]
is
not
None
assert
_true
(
c
.
messages
[
"
Error
"
,
0
][
0
].
startswith
(
"
No such directory
"
)
)
assert
c
.
messages
[
"
Error
"
,
0
][
0
].
startswith
(
"
No such directory
"
)
is
True
c
=
models
.
Container
()
c
=
models
.
Container
()
c
.
retrieve
(
c
.
retrieve
(
...
@@ -491,8 +490,8 @@ def test_insert_files_in_dir_error1():
...
@@ -491,8 +490,8 @@ def test_insert_files_in_dir_error1():
raise_exception_on_error
=
False
,
raise_exception_on_error
=
False
,
flags
=
{
flags
=
{
"
InsertFilesInDir
"
:
"
.
"
})
"
InsertFilesInDir
"
:
"
.
"
})
assert
_is_not_none
(
c
.
messages
[
"
Error
"
,
0
]
)
assert
c
.
messages
[
"
Error
"
,
0
]
is
not
None
assert
_true
(
c
.
messages
[
"
Error
"
,
0
][
0
].
startswith
(
"
Dir is not allowed
"
)
)
assert
c
.
messages
[
"
Error
"
,
0
][
0
].
startswith
(
"
Dir is not allowed
"
)
is
True
def
test_insert_files_in_dir_with_symlink
():
def
test_insert_files_in_dir_with_symlink
():
...
@@ -522,10 +521,10 @@ def test_insert_files_in_dir_with_symlink():
...
@@ -522,10 +521,10 @@ def test_insert_files_in_dir_with_symlink():
flags
=
{
flags
=
{
"
InsertFilesInDir
"
:
path_on_server
+
"
InsertFilesInDir
"
:
path_on_server
+
"
linked_subfolder
"
})
"
linked_subfolder
"
})
assert
_is_not_none
(
c
.
messages
[
"
Warning
"
,
6
]
)
assert
c
.
messages
[
"
Warning
"
,
6
]
is
not
None
assert
_equal
(
c
.
messages
[
"
Warning
"
,
6
][
0
]
,
assert
c
.
messages
[
"
Warning
"
,
6
][
0
]
==
(
"
Directory or file is symbolic
"
"
Directory or file is symbolic link:
"
+
path_on_server
+
"
link: {}linked_subfolder
"
"
linked_subfold
er
"
)
).
format
(
path_on_serv
er
)
c
=
models
.
Container
()
c
=
models
.
Container
()
c
.
retrieve
(
c
.
retrieve
(
...
@@ -535,11 +534,11 @@ def test_insert_files_in_dir_with_symlink():
...
@@ -535,11 +534,11 @@ def test_insert_files_in_dir_with_symlink():
"
InsertFilesInDir
"
:
"
--force-allow-symlinks
"
+
"
InsertFilesInDir
"
:
"
--force-allow-symlinks
"
+
path_on_server
+
path_on_server
+
"
linked_subfolder
"
})
"
linked_subfolder
"
})
assert
_is_not_none
(
c
.
messages
[
"
Info
"
,
0
]
)
assert
c
.
messages
[
"
Info
"
,
0
]
is
not
None
assert
_equal
(
c
.
messages
[
"
Info
"
,
0
][
0
],
assert
c
.
messages
[
"
Info
"
,
"
Files count in linked_subfolder/: 1
"
)
0
][
0
]
==
"
Files count in linked_subfolder/: 1
"
assert
_equal
(
c
[
0
].
name
,
"
test2.dat
"
)
assert
c
[
0
].
name
==
"
test2.dat
"
assert
_equal
(
c
[
0
].
path
,
"
/linked_subfolder/test2.dat
"
)
assert
c
[
0
].
path
==
"
/linked_subfolder/test2.dat
"
d
=
models
.
Container
()
d
=
models
.
Container
()
d
.
insert
(
d
.
insert
(
...
@@ -549,12 +548,12 @@ def test_insert_files_in_dir_with_symlink():
...
@@ -549,12 +548,12 @@ def test_insert_files_in_dir_with_symlink():
"
InsertFilesInDir
"
:
"
--force-allow-symlinks
"
+
"
InsertFilesInDir
"
:
"
--force-allow-symlinks
"
+
path_on_server
+
path_on_server
+
"
linked_subfolder
"
})
"
linked_subfolder
"
})
assert
_is_not_none
(
c
.
messages
[
"
Info
"
,
0
]
)
assert
c
.
messages
[
"
Info
"
,
0
]
is
not
None
assert
_equal
(
d
.
messages
[
"
Info
"
,
0
][
0
],
assert
d
.
messages
[
"
Info
"
,
"
Files count in linked_subfolder/: 1
"
)
0
][
0
]
==
"
Files count in linked_subfolder/: 1
"
assert
_true
(
d
[
0
].
is_valid
()
)
assert
d
[
0
].
is_valid
()
is
True
assert
_equal
(
d
[
0
].
name
,
"
test2.dat
"
)
assert
d
[
0
].
name
==
"
test2.dat
"
assert
_equal
(
d
[
0
].
path
,
"
/linked_subfolder/test2.dat
"
)
assert
d
[
0
].
path
==
"
/linked_subfolder/test2.dat
"
finally
:
finally
:
try
:
try
:
...
@@ -599,9 +598,8 @@ def test_insert_files_in_dir():
...
@@ -599,9 +598,8 @@ def test_insert_files_in_dir():
raise_exception_on_error
=
False
,
raise_exception_on_error
=
False
,
flags
=
{
flags
=
{
"
InsertFilesInDir
"
:
path_on_server
})
"
InsertFilesInDir
"
:
path_on_server
})
assert_is_not_none
(
c
.
messages
[
"
Info
"
,
0
])
assert
c
.
messages
[
"
Info
"
,
0
]
is
not
None
assert_equal
(
c
.
messages
[
"
Info
"
,
0
][
0
],
assert
c
.
messages
[
"
Info
"
,
0
][
0
]
==
"
Files count in testfolder/: 2
"
"
Files count in testfolder/: 2
"
)
# ACTUAL RUN
# ACTUAL RUN
d
=
models
.
Container
()
d
=
models
.
Container
()
...
@@ -610,10 +608,9 @@ def test_insert_files_in_dir():
...
@@ -610,10 +608,9 @@ def test_insert_files_in_dir():
raise_exception_on_error
=
False
,
raise_exception_on_error
=
False
,
flags
=
{
flags
=
{
"
InsertFilesInDir
"
:
path_on_server
})
"
InsertFilesInDir
"
:
path_on_server
})
assert_is_not_none
(
c
.
messages
[
"
Info
"
,
0
])
assert
c
.
messages
[
"
Info
"
,
0
]
is
not
None
assert_equal
(
d
.
messages
[
"
Info
"
,
0
][
0
],
assert
d
.
messages
[
"
Info
"
,
0
][
0
]
==
"
Files count in testfolder/: 2
"
"
Files count in testfolder/: 2
"
)
assert
d
[
0
].
is_valid
()
is
True
assert_true
(
d
[
0
].
is_valid
())
# create a new file and call insertFilesInDir again
# create a new file and call insertFilesInDir again
test_file3
=
open
(
path
+
"
/test3.dat
"
,
"
w
"
)
test_file3
=
open
(
path
+
"
/test3.dat
"
,
"
w
"
)
...
@@ -626,15 +623,14 @@ def test_insert_files_in_dir():
...
@@ -626,15 +623,14 @@ def test_insert_files_in_dir():
raise_exception_on_error
=
False
,
raise_exception_on_error
=
False
,
flags
=
{
flags
=
{
"
InsertFilesInDir
"
:
path_on_server
})
"
InsertFilesInDir
"
:
path_on_server
})
assert_is_not_none
(
e
.
messages
[
"
Info
"
,
0
])
assert
e
.
messages
[
"
Info
"
,
0
]
is
not
None
assert_equal
(
e
.
messages
[
"
Info
"
,
0
][
0
],
assert
e
.
messages
[
"
Info
"
,
0
][
0
]
==
"
Files count in testfolder/: 3
"
"
Files count in testfolder/: 3
"
)
# only the new file is given back...
# only the new file is given back...
assert
_equal
(
1
,
len
(
e
)
)
assert
1
==
len
(
e
)
assert
_false
(
e
[
0
].
is_valid
()
)
assert
e
[
0
].
is_valid
()
is
False
assert
_equal
(
e
[
0
].
name
,
"
test3.dat
"
)
assert
e
[
0
].
name
==
"
test3.dat
"
assert
_equal
(
e
[
0
].
path
,
"
/testfolder/test3.dat
"
)
assert
e
[
0
].
path
==
"
/testfolder/test3.dat
"
f
=
models
.
Container
()
f
=
models
.
Container
()
f
.
insert
(
f
.
insert
(
...
@@ -642,14 +638,13 @@ def test_insert_files_in_dir():
...
@@ -642,14 +638,13 @@ def test_insert_files_in_dir():
raise_exception_on_error
=
False
,
raise_exception_on_error
=
False
,
flags
=
{
flags
=
{
"
InsertFilesInDir
"
:
path_on_server
})
"
InsertFilesInDir
"
:
path_on_server
})
assert_is_not_none
(
f
.
messages
[
"
Info
"
,
0
])
assert
f
.
messages
[
"
Info
"
,
0
]
is
not
None
assert_equal
(
f
.
messages
[
"
Info
"
,
0
][
0
],
assert
f
.
messages
[
"
Info
"
,
0
][
0
]
==
"
Files count in testfolder/: 3
"
"
Files count in testfolder/: 3
"
)
# only the new file is given back...
# only the new file is given back...
assert
_equal
(
1
,
len
(
f
)
)
assert
1
==
len
(
f
)
assert
_true
(
f
[
0
].
is_valid
()
)
assert
f
[
0
].
is_valid
()
is
True
assert
_equal
(
f
[
0
].
name
,
"
test3.dat
"
)
assert
f
[
0
].
name
==
"
test3.dat
"
assert
_equal
(
f
[
0
].
path
,
"
/testfolder/test3.dat
"
)
assert
f
[
0
].
path
==
"
/testfolder/test3.dat
"
finally
:
finally
:
try
:
try
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment