Skip to content

Commit

Permalink
MusicComposition: don't fail if a language isn't provided
Browse files Browse the repository at this point in the history
  • Loading branch information
alastair committed Oct 22, 2020
1 parent 1de2fb3 commit cabadfc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/data/musiccomposition/create_musiccomposition.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ title: "Das Lied von der Erde"
format: "text/html"
subject: "Music Composition"
source: "https://www.cpdl.org/Das_Lied_von_der_Erde"
language: en
inLanguage: "de"
name: "The Song of the Earth"
language: en
) {
identifier
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ title: "Das Lied von der Erde: I. Das Trinklied vom Jammer der Erde"
format: "text/html"
subject: "Music Composition"
source: "https://musicbrainz.org/work/ff15c2ab-0775-3757-975a-331357299635"
language: de
inLanguage: "de"
name: "Das Lied von der Erde: I. Das Trinklied vom Jammer der Erde"
description: "First composition of a song-cycle by Mahler"
position: 1
language: de
) {
identifier
}
Expand Down
8 changes: 8 additions & 0 deletions tests/mutations/test_musiccomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ def test_create(self):
)
assert created_musiccomposition == expected

def test_create_no_language(self):
"""A musiccomposition can be missing a language value, and this should generate a valid mutation"""
musiccomposition.mutation_create_music_composition(
title="Das Lied von der Erde", contributor="https://www.cpdl.org", creator="https://www.upf.edu",
source="https://www.cpdl.org/Das_Lied_von_der_Erde", format_="text/html", subject="Music Composition",
inlanguage="de", name="The Song of the Earth"
)

def test_create_all_arguments(self):
created_musiccomposition = musiccomposition.mutation_create_music_composition(
title="Das Lied von der Erde: I. Das Trinklied vom Jammer der Erde", contributor="https://musicbrainz.org",
Expand Down
7 changes: 4 additions & 3 deletions trompace/mutations/musiccomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ def mutation_create_music_composition(*, title: str, contributor: str, creator:
"format": format_,
"subject": subject,
"source": source,
"language": StringConstant(language.lower()),
"inLanguage": inlanguage,
"name": name,
"description": description,
"position": position
}
if language is not None:
args["language"] = StringConstant(language.lower())

args = filter_none_args(args)

Expand Down Expand Up @@ -101,8 +102,8 @@ def mutation_update_music_composition(identifier: str, *, title: str = None, con
"format": format_,
"name": name,
"description": description,
"position": position}

"position": position
}
if language is not None:
args["language"] = StringConstant(language.lower())

Expand Down

0 comments on commit cabadfc

Please sign in to comment.