Add artists robot tests
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
|||||||
DefaultValuePipe,
|
DefaultValuePipe,
|
||||||
Delete,
|
Delete,
|
||||||
Get,
|
Get,
|
||||||
|
InternalServerErrorException,
|
||||||
NotFoundException,
|
NotFoundException,
|
||||||
Param,
|
Param,
|
||||||
ParseIntPipe,
|
ParseIntPipe,
|
||||||
@@ -30,8 +31,12 @@ export class SongController {
|
|||||||
const song = await this.songService.song({ id });
|
const song = await this.songService.song({ id });
|
||||||
if (!song) throw new NotFoundException('Song not found');
|
if (!song) throw new NotFoundException('Song not found');
|
||||||
|
|
||||||
const file = createReadStream(song.midiPath);
|
try {
|
||||||
return new StreamableFile(file);
|
const file = createReadStream(song.midiPath);
|
||||||
|
return new StreamableFile(file, { type: 'audio/midi' });
|
||||||
|
} catch {
|
||||||
|
throw new InternalServerErrorException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id/musicXml')
|
@Get(':id/musicXml')
|
||||||
|
|||||||
@@ -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}
|
||||||
@@ -100,9 +100,10 @@ Find multiples songs filtered by type
|
|||||||
Get midi file
|
Get midi file
|
||||||
&{res}= POST
|
&{res}= POST
|
||||||
... /song
|
... /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
|
Output
|
||||||
Integer response status 201
|
Integer response status 201
|
||||||
GET /song/${res.body.id}/midi
|
GET /song/${res.body.id}/midi
|
||||||
Output
|
Integer response status 200
|
||||||
[Teardown] DELETE /song/${res.body.id}
|
#Output
|
||||||
|
[Teardown] DELETE /song/${res.body.id}
|
||||||
|
|||||||
+2
-3
@@ -24,8 +24,8 @@ def populateFile(path, midi, mxl):
|
|||||||
print(f"Populating {metadata['Name']}")
|
print(f"Populating {metadata['Name']}")
|
||||||
res = requests.post(f"{url}/song", json={
|
res = requests.post(f"{url}/song", json={
|
||||||
"name": metadata["Name"],
|
"name": metadata["Name"],
|
||||||
"midiPath": midi,
|
"midiPath": f"/musics/{midi}",
|
||||||
"musicXmlPath": mxl,
|
"musicXmlPath": f"/musics/{mxl}",
|
||||||
"difficulties": dificulties,
|
"difficulties": dificulties,
|
||||||
"artist": getOrCreateArtist(metadata["Artist"]),
|
"artist": getOrCreateArtist(metadata["Artist"]),
|
||||||
# "album": metadata["Album"],
|
# "album": metadata["Album"],
|
||||||
@@ -40,7 +40,6 @@ def main():
|
|||||||
url = "http://localhost:3000"
|
url = "http://localhost:3000"
|
||||||
print("Searching for files...")
|
print("Searching for files...")
|
||||||
for file in glob.glob("**/*.ini", recursive=True):
|
for file in glob.glob("**/*.ini", recursive=True):
|
||||||
file = os.path.abspath(file)
|
|
||||||
print(f"File found: {file}")
|
print(f"File found: {file}")
|
||||||
path = os.path.splitext(file)[0]
|
path = os.path.splitext(file)[0]
|
||||||
populateFile(file, path + ".midi", path + ".mxl")
|
populateFile(file, path + ".midi", path + ".mxl")
|
||||||
|
|||||||
Reference in New Issue
Block a user