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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Python Integration Tests
Commits
1602ed91
Verified
Commit
1602ed91
authored
1 year ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
WIP: test for import
parent
908593dc
No related branches found
No related tags found
1 merge request
!53
Draft: ENH: file system: import
Pipeline
#50758
failed
1 year ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_file.py
+129
-6
129 additions, 6 deletions
tests/test_file.py
with
129 additions
and
6 deletions
tests/test_file.py
+
129
−
6
View file @
1602ed91
...
...
@@ -421,21 +421,144 @@ def test_import_directoy_recursively():
c
.
append
(
directory
)
c
.
insert
()
assert
len
(
c
)
==
2
assert
len
(
c
)
==
3
# testfolder, testfolder/subfolder, testfolder/subfolder/some_data.csv
for
e
in
c
:
if
e
.
role
==
"
Directory
"
:
assert
e
.
path
==
"
testfolder/subfolder
"
assert
e
.
path
==
"
/
testfolder/subfolder
"
or
e
.
path
==
"
/testfolder
"
else
:
assert
e
.
role
==
"
File
"
assert
e
.
path
==
"
testfolder/subfolder/some_data.csv
"
assert
e
.
path
==
"
/
testfolder/subfolder/some_data.csv
"
re
=
db
.
execute_query
(
"
FIND Entity WHICH IS STORED AT /testfolder/subfolder*
"
)
re
=
db
.
execute_query
(
"
FIND Entity WHICH IS STORED AT /testfolder/subfolder**
"
)
assert
len
(
re
)
==
2
for
e
in
re
:
if
e
.
role
==
"
Directory
"
:
assert
e
.
path
==
"
testfolder/subfolder
"
assert
e
.
path
==
"
/
testfolder/subfolder
"
else
:
assert
e
.
role
==
"
File
"
assert
e
.
path
==
"
testfolder/subfolder/some_data.csv
"
assert
e
.
path
==
"
/testfolder/subfolder/some_data.csv
"
def
test_import_directoy_recursively_deep
():
path
=
get_config
().
get
(
"
IntegrationTests
"
,
"
test_files.test_import_files_in_dir.local
"
)
if
not
path
.
endswith
(
"
/
"
):
path
=
path
[:
-
1
]
folders
=
[
"
/testfolder
"
+
folder
for
folder
in
[
"
/subfolder1
"
,
"
/subfolder1/subsubfolder1.1
"
,
"
/subfolder2
"
,
"
/subfolder2/subsubfolder2.1
"
,
"
/subfolder2/subsubfolder2.2
"
,
"
/subfolder2/subsubfolder2.2/subsubsubfolder2.2.1
"
,
"
/subfolder3
"
,
"
/subfolder3/subsubfolder3.1
"
,
"
/subfolder3/subsubfolder3.2
"
,
"
/subfolder3/subsubfolder3.2/subsubsubfolder3.2.1
"
,
"
/subfolder3/subsubfolder3.2/subsubsubfolder3.2.2
"
,
"
/subfolder3/subsubfolder3.2/subsubsubfolder3.2.2/subsubsubsubfolder3.2.2.1
"
,
"
/subfolder3/subsubfolder3.3
"
,
"
/subfolder3/subsubfolder3.3/subsubsubfolder3.3.1
"
,
"
/subfolder3/subsubfolder3.3/subsubsubfolder3.3.2
"
,
"
/subfolder3/subsubfolder3.3/subsubsubfolder3.3.2/subsubsubsubfolder3.3.2.1
"
,
"
/subfolder3/subsubfolder3.3/subsubsubfolder3.3.3
"
,
"
/subfolder3/subsubfolder3.3/subsubsubfolder3.3.3/subsubsubsubfolder3.3.3.1
"
,
"
/subfolder3/subsubfolder3.3/subsubsubfolder3.3.3/subsubsubsubfolder3.3.3.2
"
,
"
/subfolder3/subsubfolder3.3/subsubsubfolder3.3.3/subsubsubsubfolder3.3.3.2/subsubsubsubsubfolder3.3.3.2.1
"
,
]]
files
=
[]
for
folder
in
folders
:
os
.
makedirs
(
path
+
folder
)
with
open
(
path
+
folder
+
"
/some_data1.csv
"
,
"
w
"
)
as
test_file1
:
test_file1
.
write
(
f
"
1: hello
{
folder
}
\n
"
)
files
.
append
(
folder
+
"
/some_data1.csv
"
)
with
open
(
path
+
folder
+
"
/some_data2.csv
"
,
"
w
"
)
as
test_file1
:
test_file1
.
write
(
f
"
2: hello
{
folder
}
\n
"
)
files
.
append
(
folder
+
"
/some_data2.csv
"
)
folders
.
append
(
"
/testfolder
"
)
directory
=
db
.
common
.
models
.
Directory
(
recursive_import
=
True
,
path
=
"
testfolder
"
)
c
=
db
.
Container
()
c
.
append
(
directory
)
c
.
insert
()
assert
len
(
c
)
==
20
+
20
+
20
+
1
assert
set
(
folders
+
files
)
==
set
([
e
.
path
for
e
in
c
])
re
=
execute_query
(
"
FIND ENTITY WHICH IS STORED AT testfolder**
"
)
assert
len
(
re
)
==
20
+
20
+
20
+
1
assert
set
(
folders
+
files
)
==
set
([
e
.
path
for
e
in
re
])
def
test_update_import_single_file
():
path
=
get_config
().
get
(
"
IntegrationTests
"
,
"
test_files.test_import_files_in_dir.local
"
)
+
"
testfolder/
"
os
.
makedirs
(
path
)
os
.
makedirs
(
path
+
"
subfolder/
"
)
local_file
=
os
.
path
.
join
(
path
,
"
subfolder
"
,
"
some_data.csv
"
)
with
open
(
local_file
,
"
w
"
)
as
test_file1
:
test_file1
.
write
(
"
hello, world
\n
"
)
file_
=
db
.
File
(
import_file
=
True
,
path
=
"
testfolder/subfolder/some_data.csv
"
)
file_
.
insert
()
version
=
file_
.
version
file_
.
checksum
=
None
file_
.
size
=
None
re
=
file_
.
update
(
sync
=
False
)
assert
re
.
version
==
version
assert
re
.
messages
[
0
].
description
==
"
Nothing to be updated.
"
# update file on the disc
with
open
(
local_file
,
"
w
"
)
as
test_file1
:
test_file1
.
write
(
"
hello, othre worlds
\n
"
)
# do a consistency_check
c
=
runCheck
(
None
,
"
testfolder/subfolder/some_data.csv
"
)
assert
c
.
messages
[
"
Error
"
,
0
][
0
]
==
'
CHANGED:SIZE - DEFAULT:testfolder/subfolder/some_data.csv
'
re
=
file_
.
update
(
sync
=
False
)
assert
re
.
version
!=
version
# update file on the disc
with
open
(
local_file
,
"
w
"
)
as
test_file1
:
test_file1
.
write
(
"
hello, other worlds
\n
"
)
c
=
runCheck
(
None
,
"
testfolder/subfolder/some_data.csv
"
)
assert
c
.
messages
[
"
Error
"
,
0
][
0
]
==
'
CHANGED:HASH - DEFAULT:testfolder/subfolder/some_data.csv
'
re
=
file_
.
update
(
sync
=
False
)
assert
re
.
version
!=
version
def
test_update_import_directory_new_children
():
path
=
get_config
().
get
(
"
IntegrationTests
"
,
"
test_files.test_import_files_in_dir.local
"
)
+
"
testfolder/
"
os
.
makedirs
(
path
)
os
.
makedirs
(
path
+
"
subfolder/
"
)
with
open
(
path
+
"
subfolder/some_data.csv
"
,
"
w
"
)
as
test_file1
:
test_file1
.
write
(
"
hello, world
\n
"
)
directory
=
db
.
common
.
models
.
Directory
(
recursive_import
=
True
,
path
=
"
testfolder/subfolder/
"
)
c
=
db
.
Container
()
c
.
append
(
directory
)
c
.
insert
()
version
=
directory
.
version
with
open
(
path
+
"
subfolder/some_data2.csv
"
,
"
w
"
)
as
test_file1
:
test_file1
.
write
(
"
hello, world2
\n
"
)
re
=
directory
.
update
(
sync
=
False
)
print
(
re
)
assert
re
.
version
!=
version
def
test_consistency_file_was_modified_2
():
...
...
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