Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nomad-FAIR
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
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
nomad-lab
nomad-FAIR
Commits
1a00d327
Commit
1a00d327
authored
6 years ago
by
Markus Scheidgen
Browse files
Options
Downloads
Patches
Plain Diff
Initial commit of some code for new uploads impl.
parent
3880448a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+1
-1
1 addition, 1 deletion
.gitignore
tests/test_uploads.py
+90
-0
90 additions, 0 deletions
tests/test_uploads.py
with
91 additions
and
1 deletion
.gitignore
+
1
−
1
View file @
1a00d327
...
@@ -11,7 +11,7 @@ __pycache__
...
@@ -11,7 +11,7 @@ __pycache__
.coverage
.coverage
try.http
try.http
project/
project/
test_*
test_*
/
local/
local/
target/
target/
*.swp
*.swp
This diff is collapsed.
Click to expand it.
tests/test_uploads.py
0 → 100644
+
90
−
0
View file @
1a00d327
# Copyright 2018 Markus Scheidgen
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an"AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
os
import
os.path
import
shutil
import
pytest
from
nomad
import
config
from
nomad.uploads
import
Metadata
,
MetadataTimeout
class
TestMetadata
:
@pytest.fixture
(
scope
=
'
function
'
)
def
test_dir
(
self
):
path
=
os
.
path
.
join
(
config
.
fs
.
tmp
,
'
test_dir
'
)
os
.
makedirs
(
path
)
yield
path
shutil
.
rmtree
(
path
)
@pytest.fixture
(
scope
=
'
function
'
)
def
md
(
self
,
test_dir
):
with
Metadata
(
test_dir
)
as
md
:
yield
md
def
test_open_empty
(
self
,
test_dir
):
with
Metadata
(
test_dir
):
pass
def
test_modify
(
self
,
test_dir
):
with
Metadata
(
test_dir
)
as
md
:
md
.
data
[
'
key
'
]
=
'
value
'
with
Metadata
(
test_dir
)
as
md
:
assert
'
key
'
in
md
.
data
assert
md
.
data
[
'
key
'
]
==
'
value
'
assert
len
(
md
.
data
)
==
1
def
test_lock
(
self
,
test_dir
):
timeout
=
False
with
Metadata
(
test_dir
):
try
:
with
Metadata
(
test_dir
,
lock_timeout
=
0.1
):
pass
except
MetadataTimeout
:
timeout
=
True
assert
timeout
def
test_insert
(
self
,
md
:
Metadata
):
md
.
insert
(
dict
(
hash
=
'
0
'
,
data
=
'
test
'
))
assert
len
(
md
.
data
)
==
1
assert
'
0
'
in
md
.
data
assert
md
.
data
[
'
0
'
][
'
data
'
]
==
'
test
'
def
test_insert_fail
(
self
,
md
:
Metadata
):
failed
=
False
md
.
insert
(
dict
(
hash
=
'
0
'
,
data
=
'
test
'
))
try
:
md
.
insert
(
dict
(
hash
=
'
0
'
,
data
=
'
test
'
))
except
Exception
:
failed
=
True
assert
failed
assert
len
(
md
.
data
)
==
1
def
test_update
(
self
,
md
:
Metadata
):
md
.
insert
(
dict
(
hash
=
'
0
'
,
data
=
'
test
'
))
md
.
update
(
dict
(
hash
=
'
0
'
,
data
=
'
updated
'
))
assert
len
(
md
.
data
)
==
1
assert
md
.
data
[
'
0
'
][
'
data
'
]
==
'
updated
'
def
test_update_fail
(
self
,
md
:
Metadata
):
failed
=
False
try
:
md
.
update
(
dict
(
hash
=
'
0
'
,
data
=
'
updated
'
))
except
KeyError
:
failed
=
True
assert
failed
assert
len
(
md
.
data
)
==
0
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