Skip to content

Commit

Permalink
authors: builder add bluesky and mastodon
Browse files Browse the repository at this point in the history
  • Loading branch information
drjova authored and miguelgrc committed Dec 3, 2024
1 parent 1c7b32f commit f075b21
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
32 changes: 32 additions & 0 deletions inspire_schemas/builders/authors.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,38 @@ def add_twitter(self, id_):
},
)

@filter_empty_parameters
def add_bluesky(self, id_):
"""Add a Bluesky id.
Args:
:param id_: Identifier of Bluesky profile.
:type id_: string
"""
self._append_to(
'ids',
{
'value': id_,
'schema': 'BLUESKY',
},
)

@filter_empty_parameters
def add_mastodon(self, id_):
"""Add a Mastdon id.
Args:
:param id_: Identifier of Mastodon profile.
:type id_: string
"""
self._append_to(
'ids',
{
'value': id_,
'schema': 'MASTODON',
},
)

@filter_empty_parameters
def add_orcid(self, id_):
"""Add a ORCID identifier.
Expand Down
28 changes: 28 additions & 0 deletions tests/unit/test_author_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,34 @@ def test_add_twitter():
assert expected == result


def test_add_bluesky():
schema = load_schema('authors')
subschema = schema['properties']['ids']

author = AuthorBuilder()
author.add_bluesky('kylecranmer.bsky.social')

expected = [{"value": "kylecranmer.bsky.social", "schema": "BLUESKY"}]
result = author.obj['ids']

assert validate(result, subschema) is None
assert expected == result


def test_add_mastodon():
schema = load_schema('authors')
subschema = schema['properties']['ids']

author = AuthorBuilder()
author.add_mastodon('[email protected]')

expected = [{"value": "[email protected]", "schema": "MASTODON"}]
result = author.obj['ids']

assert validate(result, subschema) is None
assert expected == result


def test_add_orcid():
schema = load_schema('authors')
subschema = schema['properties']['ids']
Expand Down

0 comments on commit f075b21

Please sign in to comment.