Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PrivateStorageio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
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
PrivateStorage
PrivateStorageio
Commits
b065dfa8
Commit
b065dfa8
authored
5 years ago
by
Nicholas Calaway
Browse files
Options
Downloads
Patches
Plain Diff
Added tests for linking and unlinking a file
parent
a474ffb9
No related branches found
No related tags found
1 merge request
!14
Added tests for linking and unlinking a file
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
nixos/modules/tests/exercise-storage.py
+20
-5
20 additions, 5 deletions
nixos/modules/tests/exercise-storage.py
with
20 additions
and
5 deletions
nixos/modules/tests/exercise-storage.py
+
20
−
5
View file @
b065dfa8
...
@@ -21,8 +21,9 @@ def main():
...
@@ -21,8 +21,9 @@ def main():
api_root
=
get_api_root
(
clientDir
)
api_root
=
get_api_root
(
clientDir
)
exercise_immutable
(
api_root
,
someData
)
subject_cap
=
exercise_immutable
(
api_root
,
someData
)
exercise_mkdir
(
api_root
)
newDir
=
exercise_mkdir
(
api_root
)
exercise_link_unlink
(
api_root
,
newDir
,
subject_cap
)
def
exercise_immutable
(
api_root
,
someData
):
def
exercise_immutable
(
api_root
,
someData
):
cap
=
tahoe_put
(
api_root
,
someData
)
cap
=
tahoe_put
(
api_root
,
someData
)
...
@@ -34,6 +35,13 @@ def exercise_mkdir(api_root):
...
@@ -34,6 +35,13 @@ def exercise_mkdir(api_root):
cap
=
tahoe_mkdir
(
api_root
)
cap
=
tahoe_mkdir
(
api_root
)
info
=
tahoe_stat
(
api_root
,
cap
)
info
=
tahoe_stat
(
api_root
,
cap
)
assert
info
assert
info
return
info
[
1
][
u
"
rw_uri
"
]
def
exercise_link_unlink
(
api_root
,
dir_cap
,
subject_cap
):
tahoe_link
(
api_root
,
dir_cap
,
u
"
foo
"
,
subject_cap
)
assert
u
"
foo
"
in
tahoe_stat
(
api_root
,
dir_cap
)[
1
][
u
"
children
"
]
tahoe_unlink
(
api_root
,
dir_cap
,
u
"
foo
"
)
assert
u
"
foo
"
not
in
tahoe_stat
(
api_root
,
dir_cap
)[
1
][
u
"
children
"
]
def
get_api_root
(
path
):
def
get_api_root
(
path
):
with
open
(
path
+
u
"
/node.url
"
)
as
f
:
with
open
(
path
+
u
"
/node.url
"
)
as
f
:
...
@@ -63,9 +71,9 @@ def tahoe_mkdir(api_root):
...
@@ -63,9 +71,9 @@ def tahoe_mkdir(api_root):
return
response
.
text
return
response
.
text
def
tahoe_link
(
api_root
,
dir_cap
,
name
,
subject_cap
):
def
tahoe_link
(
api_root
,
dir_cap
,
name
,
subject_cap
):
response
=
requests
.
p
os
t
(
response
=
requests
.
p
u
t
(
api_root
.
child
(
u
"
uri
"
,
dir_cap
,
name
).
replace
(
query
=
{
u
"
t
"
:
u
"
uri
"
}).
to_uri
(),
api_root
.
child
(
u
"
uri
"
,
dir_cap
,
name
).
replace
(
query
=
{
u
"
t
"
:
u
"
uri
"
}).
to_uri
(),
BytesIO
(
subject_cap
),
BytesIO
(
subject_cap
.
encode
(
"
ascii
"
)
),
)
)
response
.
raise_for_status
()
response
.
raise_for_status
()
return
response
.
text
return
response
.
text
...
@@ -75,7 +83,14 @@ def tahoe_stat(api_root, cap):
...
@@ -75,7 +83,14 @@ def tahoe_stat(api_root, cap):
api_root
.
child
(
u
"
uri
"
,
cap
).
replace
(
query
=
{
u
"
t
"
:
u
"
json
"
}).
to_uri
(),
api_root
.
child
(
u
"
uri
"
,
cap
).
replace
(
query
=
{
u
"
t
"
:
u
"
json
"
}).
to_uri
(),
)
)
response
.
raise_for_status
()
response
.
raise_for_status
()
return
response
.
json
return
response
.
json
()
def
tahoe_unlink
(
api_root
,
dir_cap
,
name
):
response
=
requests
.
delete
(
api_root
.
child
(
u
"
uri
"
,
dir_cap
,
name
).
to_uri
(),
)
response
.
raise_for_status
()
return
response
.
text
if
__name__
==
u
'
__main__
'
:
if
__name__
==
u
'
__main__
'
:
main
()
main
()
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