diff --git a/inspire_schemas/builders/authors.py b/inspire_schemas/builders/authors.py index a5c656c6..aa765ce5 100644 --- a/inspire_schemas/builders/authors.py +++ b/inspire_schemas/builders/authors.py @@ -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. diff --git a/tests/unit/test_author_builder.py b/tests/unit/test_author_builder.py index 7f076e43..24f6e972 100644 --- a/tests/unit/test_author_builder.py +++ b/tests/unit/test_author_builder.py @@ -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('freyablekman@sciencemastodon.com') + + expected = [{"value": "freyablekman@sciencemastodon.com", "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']