Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
synnefo
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
itminedu
synnefo
Commits
bbfb8fbe
Commit
bbfb8fbe
authored
12 years ago
by
Sofia Papagiannaki
Browse files
Options
Downloads
Patches
Plain Diff
pithos: Add test for updating an object from version
parent
498eeba5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
snf-pithos-app/pithos/api/test/objects.py
+89
-0
89 additions, 0 deletions
snf-pithos-app/pithos/api/test/objects.py
with
89 additions
and
0 deletions
snf-pithos-app/pithos/api/test/objects.py
+
89
−
0
View file @
bbfb8fbe
...
@@ -1160,6 +1160,95 @@ class ObjectPost(PithosAPITest):
...
@@ -1160,6 +1160,95 @@ class ObjectPost(PithosAPITest):
source_data
[:
upto
-
offset
+
1
]
+
source_data
[:
upto
-
offset
+
1
]
+
initial_data
[
upto
+
1
:]))
initial_data
[
upto
+
1
:]))
def
test_update_range_from_invalid_other_object
(
self
):
src
=
self
.
object
dest
=
get_random_name
()
url
=
join_urls
(
self
.
pithos_path
,
self
.
user
,
self
.
container
,
src
)
r
=
self
.
get
(
url
)
# update zero length object
url
=
join_urls
(
self
.
pithos_path
,
self
.
user
,
self
.
container
,
dest
)
initial_data
=
get_random_data
()
length
=
len
(
initial_data
)
r
=
self
.
put
(
url
,
data
=
initial_data
)
self
.
assertEqual
(
r
.
status_code
,
201
)
offset
=
random
.
randint
(
1
,
length
-
2
)
upto
=
random
.
randint
(
offset
,
length
-
1
)
# source object does not start with /
r
=
self
.
post
(
url
,
HTTP_CONTENT_RANGE
=
'
bytes %s-%s/*
'
%
(
offset
,
upto
),
HTTP_X_SOURCE_OBJECT
=
'
%s/%s
'
%
(
self
.
container
,
src
))
self
.
assertEqual
(
r
.
status_code
,
400
)
# source object does not exist
r
=
self
.
post
(
url
,
HTTP_CONTENT_RANGE
=
'
bytes %s-%s/*
'
%
(
offset
,
upto
),
HTTP_X_SOURCE_OBJECT
=
'
/%s/%s1
'
%
(
self
.
container
,
src
))
self
.
assertEqual
(
r
.
status_code
,
404
)
def
test_update_from_other_version
(
self
):
versions
=
[]
info
=
self
.
get_object_info
(
self
.
container
,
self
.
object
)
versions
.
append
(
info
[
'
X-Object-Version
'
])
pre_length
=
int
(
info
[
'
Content-Length
'
])
# update object
d1
,
r
=
self
.
upload_object
(
self
.
container
,
self
.
object
,
length
=
pre_length
-
1
)[
1
:]
self
.
assertTrue
(
'
X-Object-Version
'
in
r
)
versions
.
append
(
r
[
'
X-Object-Version
'
])
# update object
d2
,
r
=
self
.
upload_object
(
self
.
container
,
self
.
object
,
length
=
pre_length
-
2
)[
1
:]
self
.
assertTrue
(
'
X-Object-Version
'
in
r
)
versions
.
append
(
r
[
'
X-Object-Version
'
])
# get previous version
url
=
join_urls
(
self
.
pithos_path
,
self
.
user
,
self
.
container
,
self
.
object
)
r
=
self
.
get
(
'
%s?version=list&format=json
'
%
url
)
self
.
assertEqual
(
r
.
status_code
,
200
)
l
=
json
.
loads
(
r
.
content
)[
'
versions
'
]
self
.
assertEqual
(
len
(
l
),
3
)
self
.
assertEqual
([
str
(
v
[
0
])
for
v
in
l
],
versions
)
# update with the previous version
r
=
self
.
post
(
url
,
HTTP_CONTENT_RANGE
=
'
bytes 0-/*
'
,
HTTP_X_SOURCE_OBJECT
=
'
/%s/%s
'
%
(
self
.
container
,
self
.
object
),
HTTP_X_SOURCE_VERSION
=
versions
[
0
])
self
.
assertEqual
(
r
.
status_code
,
204
)
# check content
r
=
self
.
get
(
url
)
content
=
r
.
content
self
.
assertEqual
(
len
(
content
),
pre_length
)
self
.
assertEqual
(
content
,
self
.
object_data
)
# update object
d3
,
r
=
self
.
upload_object
(
self
.
container
,
self
.
object
,
length
=
len
(
d2
)
+
1
)[
1
:]
self
.
assertTrue
(
'
X-Object-Version
'
in
r
)
versions
.
append
(
r
[
'
X-Object-Version
'
])
# update with the previous version
r
=
self
.
post
(
url
,
HTTP_CONTENT_RANGE
=
'
bytes 0-/*
'
,
HTTP_X_SOURCE_OBJECT
=
'
/%s/%s
'
%
(
self
.
container
,
self
.
object
),
HTTP_X_SOURCE_VERSION
=
versions
[
-
2
])
self
.
assertEqual
(
r
.
status_code
,
204
)
# check content
r
=
self
.
get
(
url
)
content
=
r
.
content
self
.
assertEqual
(
content
,
d2
+
d3
[
-
1
])
class
ObjectDelete
(
PithosAPITest
):
class
ObjectDelete
(
PithosAPITest
):
def
setUp
(
self
):
def
setUp
(
self
):
...
...
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