Add artists robot tests

This commit is contained in:
Zoe Roux
2022-10-25 11:57:50 +09:00
committed by Bluub
parent 89dbee0b17
commit 7bcdc4ff22
4 changed files with 127 additions and 9 deletions

View File

@@ -6,6 +6,7 @@ import {
DefaultValuePipe,
Delete,
Get,
InternalServerErrorException,
NotFoundException,
Param,
ParseIntPipe,
@@ -30,8 +31,12 @@ export class SongController {
const song = await this.songService.song({ id });
if (!song) throw new NotFoundException('Song not found');
const file = createReadStream(song.midiPath);
return new StreamableFile(file);
try {
const file = createReadStream(song.midiPath);
return new StreamableFile(file, { type: 'audio/midi' });
} catch {
throw new InternalServerErrorException();
}
}
@Get(':id/musicXml')

View File

@@ -0,0 +1,113 @@
*** Settings ***
Documentation Tests of the /artist route.
... Ensures that the artist CRUD works corectly.
Resource ../rest.resource
*** Test Cases ***
Create a artist
[Documentation] Create a artist
&{res}= POST
... /artist
... {"name": "Mama mia"}
Output
Integer response status 201
[Teardown] DELETE /artist/${res.body.id}
Duplicate a artist
[Documentation] Duplicate a artist
&{res}= POST
... /artist
... {"name": "Mama mia"}
Output
Integer response status 201
&{res2}= POST
... /artist
... {"name": "Mama mia"}
Output
Integer response status 409
Should Be Equal ${res.body.id} ${res2.body.id}
[Teardown] DELETE /artist/${res.body.id}
Find a artist
[Documentation] Create a artist and find it
&{res}= POST
... /artist
... {"name": "Mama mia"}
Output
Integer response status 201
&{get}= GET /artist/${res.body.id}
Output
Integer response status 200
Should Be Equal ${res.body} ${get.body}
[Teardown] DELETE /artist/${res.body.id}
Find a artist non existant
[Documentation] Find non existant artist
&{get}= GET /artist/9999
Integer response status 404
Find multiples artists
[Documentation] Create two artists and find them
&{res}= POST
... /artist
... {"name": "Mama mia"}
Output
Integer response status 201
&{res2}= POST
... /artist
... {"name": "Toto"}
Output
Integer response status 201
&{get}= GET /artist
Output
Integer response status 200
Should Contain ${get.body.data} ${res.body}
Should Contain ${get.body.data} ${res2.body}
[Teardown] Run Keywords DELETE /artist/${res.body.id}
... AND DELETE /artist/${res2.body.id}
Find multiples artists filtered
[Documentation] Create two artists and find them
&{res}= POST
... /artist
... {"name": "Mamamia"}
Output
Integer response status 201
&{res2}= POST
... /artist
... {"name": "jkgnsg"}
Output
Integer response status 201
&{get}= GET /artist?name=Mamamia
Output
Integer response status 200
Should Contain ${get.body.data} ${res.body}
Should Not Contain ${get.body.data} ${res2.body}
[Teardown] Run Keywords DELETE /artist/${res.body.id}
... AND DELETE /artist/${res2.body.id}
Find multiples artists filtered by type
[Documentation] Create two artists and find them
&{res}= POST
... /artist
... {"name": "Mama mia"}
Output
Integer response status 201
&{res2}= POST
... /artist
... {"name": "kldngsd"}
Output
Integer response status 201
&{get}= GET /artist?id=${res.body.id}
Output
Integer response status 200
Should Contain ${get.body.data} ${res.body}
Should Not Contain ${get.body.data} ${res2.body}
[Teardown] Run Keywords DELETE /artist/${res.body.id}
... AND DELETE /artist/${res2.body.id}

View File

@@ -100,9 +100,10 @@ Find multiples songs filtered by type
Get midi file
&{res}= POST
... /song
... {"name": "Mama mia", "difficulties": {}, "midiPath": "/musics/Beethoven-125-4.midi", "musicXmlPath": "/musics/Beethoven-125-4.mxl"}
... {"name": "Mama mia", "difficulties": {}, "midiPath": "/musics/Beethoven-125-4/Beethoven-125-4.midi", "musicXmlPath": "/musics/Beethoven-125-4/Beethoven-125-4.mxl"}
Output
Integer response status 201
GET /song/${res.body.id}/midi
Output
[Teardown] DELETE /song/${res.body.id}
GET /song/${res.body.id}/midi
Integer response status 200
#Output
[Teardown] DELETE /song/${res.body.id}

View File

@@ -24,8 +24,8 @@ def populateFile(path, midi, mxl):
print(f"Populating {metadata['Name']}")
res = requests.post(f"{url}/song", json={
"name": metadata["Name"],
"midiPath": midi,
"musicXmlPath": mxl,
"midiPath": f"/musics/{midi}",
"musicXmlPath": f"/musics/{mxl}",
"difficulties": dificulties,
"artist": getOrCreateArtist(metadata["Artist"]),
# "album": metadata["Album"],
@@ -40,7 +40,6 @@ def main():
url = "http://localhost:3000"
print("Searching for files...")
for file in glob.glob("**/*.ini", recursive=True):
file = os.path.abspath(file)
print(f"File found: {file}")
path = os.path.splitext(file)[0]
populateFile(file, path + ".midi", path + ".mxl")