Skip to content

Commit

Permalink
refactor(metadata): rename contact to author
Browse files Browse the repository at this point in the history
Renamed contact to author since unlike REST APIs a workflow is most likely developed by several individuals or organizations.

Also added the option to have multiple authors for a workflow.
  • Loading branch information
mostaphaRoudsari committed Feb 23, 2020
1 parent d72b3a4 commit cb32a7a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
15 changes: 8 additions & 7 deletions queenbee/schema/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,24 @@

from queenbee.schema.qutil import BaseModel
from pydantic import Field
from typing import List, Union


class Contact(BaseModel):
"""Contact information."""
class Author(BaseModel):
"""Author information."""
name: str = Field(
...,
description='The name of the contact person or organization.'
description='The name of the author person or organization.'
)

url: str = Field(
None,
description='The url pointing to the contact information.'
description='The url pointing to the author information.'
)

email: str = Field(
None,
description='The email address of the contact person or organization.'
description='The email address of the author person or organization.'
)


Expand All @@ -48,9 +49,9 @@ class MetaData(BaseModel):
description='A short description of the workflow.'
)

contact: Contact = Field(
author: Union[Author, List[Author]] = Field(
None,
description='The contact information.'
description='A single author or list of workflow authors.'
)

license: License = Field(
Expand Down
25 changes: 25 additions & 0 deletions tests/schema/metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from queenbee.schema.metadata import MetaData

single_author = {
'description': 'test metadata',
'author': {
'name': 'John Dao',
'email': '[email protected]'
}
}

multi_authors = {
'description': 'test metadata',
'author': [
{'name': 'John Smith', 'email': '[email protected]'},
{'name': 'Jane Smith', 'email': '[email protected]'},
]
}


def test_load_single_author():
MetaData.parse_obj(single_author)


def test_load_multi_authors():
MetaData.parse_obj(multi_authors)

0 comments on commit cb32a7a

Please sign in to comment.