Skip to content

Commit

Permalink
Fix keys in project metadata (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
imagejan authored Jul 6, 2024
1 parent 79c67e9 commit 82686f2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mobie/metadata/project_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ def create_project_metadata(root, description=None, references=None):
"datasets": []
}
if description is not None:
metadata[description] = description
metadata["description"] = description
if references is not None:
metadata[references] = references
metadata["references"] = references
write_project_metadata(root, metadata)


Expand Down
18 changes: 18 additions & 0 deletions test/metadata/test_project_metadata.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import json
import unittest
import tempfile

from jsonschema import ValidationError
from mobie import SPEC_VERSION
from mobie.metadata import create_project_metadata, read_project_metadata, add_dataset
from mobie.validation.utils import validate_with_schema


Expand Down Expand Up @@ -60,6 +62,22 @@ def test_project_metadata(self):
with self.assertRaises(ValidationError):
validate_with_schema(metadata, "project")

def test_create_project_metadata(self):
description = "Test project"
schema = self.get_schema()
with tempfile.TemporaryDirectory() as tempdir:
create_project_metadata(
root=tempdir,
description=description,
)
add_dataset(
root=tempdir,
dataset_name="alpha",
is_default=True,
)
metadata = read_project_metadata(tempdir)
validate_with_schema(metadata, schema)


if __name__ == '__main__':
unittest.main()

0 comments on commit 82686f2

Please sign in to comment.