Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
c9addfc3
Commit
c9addfc3
authored
7 years ago
by
Megan Henning
Browse files
Options
Downloads
Patches
Plain Diff
Add tests
parent
c9099cd1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/placer.py
+1
-0
1 addition, 0 deletions
api/placer.py
tests/integration_tests/python/test_uploads.py
+60
-0
60 additions, 0 deletions
tests/integration_tests/python/test_uploads.py
with
61 additions
and
0 deletions
api/placer.py
+
1
−
0
View file @
c9addfc3
...
...
@@ -567,6 +567,7 @@ class PackfilePlacer(Placer):
# Extra properties on insert
insert_map
=
copy
.
deepcopy
(
query
)
insert_map
.
pop
(
'
subject.code
'
,
None
)
# Remove query term that should not become part of the payload
insert_map
[
'
created
'
]
=
self
.
timestamp
insert_map
.
update
(
self
.
metadata
[
'
session
'
])
insert_map
[
'
subject
'
]
=
containerutil
.
add_id_to_subject
(
insert_map
.
get
(
'
subject
'
),
bson
.
ObjectId
(
self
.
p_id
))
...
...
This diff is collapsed.
Click to expand it.
tests/integration_tests/python/test_uploads.py
+
60
−
0
View file @
c9addfc3
...
...
@@ -1132,6 +1132,66 @@ def test_packfile_upload(data_builder, file_form, as_admin, as_root, api_db):
assert
acquisition
.
get
(
'
label
'
)
==
'
test-packfile-timestamp
'
# Test that acquisition timestamp is used to differenciate acquisitions and session code for sessions
# Make sure there is only one session and one acquisition with the above label to start
sessions
=
list
(
api_db
.
sessions
.
find
({
'
label
'
:
'
test-packfile-timestamp
'
}))
acquisitions
=
list
(
api_db
.
acquisitions
.
find
({
'
label
'
:
'
test-packfile-timestamp
'
}))
assert
len
(
sessions
)
==
1
assert
len
(
acquisitions
)
==
1
r
=
as_admin
.
post
(
'
/projects/
'
+
project
+
'
/packfile-start
'
)
assert
r
.
ok
token
=
r
.
json
()[
'
token
'
]
r
=
as_admin
.
post
(
'
/projects/
'
+
project
+
'
/packfile
'
,
params
=
{
'
token
'
:
token
},
files
=
file_form
(
'
one.csv
'
))
assert
r
.
ok
metadata_json
=
json
.
dumps
({
'
project
'
:
{
'
_id
'
:
project
},
'
session
'
:
{
'
label
'
:
'
test-packfile-timestamp
'
,
'
subject
'
:
{
'
code
'
:
'
new-subject
'
}
},
'
acquisition
'
:
{
'
label
'
:
'
test-packfile-timestamp
'
,
'
timestamp
'
:
'
1999-01-01T00:00:00+00:00
'
},
'
packfile
'
:
{
'
type
'
:
'
test
'
}
})
r
=
as_admin
.
post
(
'
/projects/
'
+
project
+
'
/packfile-end
'
,
params
=
{
'
token
'
:
token
,
'
metadata
'
:
metadata_json
})
assert
r
.
ok
sessions
=
list
(
api_db
.
sessions
.
find
({
'
label
'
:
'
test-packfile-timestamp
'
}))
acquisitions
=
list
(
api_db
.
acquisitions
.
find
({
'
label
'
:
'
test-packfile-timestamp
'
}))
# Ensure a new session was created
assert
len
(
sessions
)
==
2
# Ensure a new acquisition was created
assert
len
(
acquisitions
)
==
2
# Ensure subject code exists on a session
for
s
in
sessions
:
if
s
.
get
(
'
subject
'
,
{}).
get
(
'
code
'
)
==
'
new-subject
'
:
break
else
:
# We didn't fine one
assert
False
# Ensure second acquisition timestamp exists on an acquisition
for
a
in
acquisitions
:
if
str
(
a
.
get
(
'
timestamp
'
))
==
'
1999-01-01 00:00:00
'
:
break
else
:
# We didn't fine one
assert
False
# get another token (start packfile-upload)
r
=
as_admin
.
post
(
'
/projects/
'
+
project
+
'
/packfile-start
'
)
assert
r
.
ok
...
...
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