Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix keys in project metadata #138

Merged
merged 1 commit into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()