diff --git a/app.py b/app.py index 08486c2..faac81c 100644 --- a/app.py +++ b/app.py @@ -344,27 +344,27 @@ def get_transactions(): # Notes -@app.route('/api/v1/notes/', methods=['GET']) +@app.route('/api/v1/note/', methods=['GET']) def get_note_by_id(entity_id): """Returns the note according to its id""" controller = NoteController return controller.get_by_id(MySQLFactory.get(), entity_id) -@app.route('/api/v1/notes', methods=['POST']) +@app.route('/api/v1/note', methods=['POST']) @token_required def create_note(): """Create a note""" controller = NoteController return controller.create(MySQLFactory.get()) -@app.route('/api/v1/notes/', methods=['PATCH']) +@app.route('/api/v1/note/', methods=['PATCH']) @token_required def update_note(entity_id): """Update the note according to its id""" controller = NoteController return controller.update(MySQLFactory.get(), entity_id) -@app.route('/api/v1/notes/', methods=['DELETE']) +@app.route('/api/v1/note/', methods=['DELETE']) @token_required def delete_note(entity_id): """Delete the note according to its id""" @@ -373,6 +373,6 @@ def delete_note(entity_id): @app.route('/api/v1/notes', methods=['GET']) def get_notes(): - """Get the transactions""" + """Get the notes""" controller = NoteController return controller.get_list(MySQLFactory.get()) diff --git a/test/functional/test_notes.py b/test/functional/test_notes.py index 34eed6f..5deb979 100644 --- a/test/functional/test_notes.py +++ b/test/functional/test_notes.py @@ -2,31 +2,31 @@ class TestNotes(AbstractTests): def test_commons(self): - super().check_all_routes_error_bad_user_token('notes') - super().check_all_routes_error_missing_user_token('notes') + super().check_all_routes_error_bad_user_token('note') + super().check_all_routes_error_missing_user_token('note') def test_get_note(self): # Does not exist - resp = self.api_call('get', 'notes/666', {}, True) + resp = self.api_call('get', 'note/666', {}, True) self.assertEqual(404, resp.status_code) self.assertEqual({'message': "The resource of type 'note' with id #666 has not been found.", 'code': 1}, resp.json()) # Exist - resp = self.api_call('get', 'notes/1', {}, True) + resp = self.api_call('get', 'note/1', {}, True) self.assertEqual(200, resp.status_code) self.assertEqual({'id': 1, 'title': 'Note 1', 'content': 'Some comment 1.'}, resp.json()) def test_create_incomplete_payload(self): - resp = self.api_call('post', 'notes', {}, True) + resp = self.api_call('post', 'note', {}, True) self.assertEqual(400, resp.status_code) self.assertEqual({'message': 'The following field is missing: title.', 'code': 6}, resp.json()) def test_create_update_delete_success(self): # Create - resp = self.api_call('post', 'notes', {'title': 'Genesis', 'content': 'Pues'}, True) + resp = self.api_call('post', 'note', {'title': 'Genesis', 'content': 'Pues'}, True) self.assertEqual(200, resp.status_code) self.assertEqual('Genesis', resp.json()["title"]) @@ -34,16 +34,16 @@ def test_create_update_delete_success(self): note_id = str(resp.json()["id"]) # Patch - resp = self.api_call('patch', 'notes/' + note_id, {'title': 'Playstation III'}, True) + resp = self.api_call('patch', 'note/' + note_id, {'title': 'Playstation III'}, True) self.assertEqual(200, resp.status_code) self.assertEqual('Playstation III', resp.json()["title"]) # Delete - resp = self.api_call('delete', 'notes/' + note_id, {}, True) + resp = self.api_call('delete', 'note/' + note_id, {}, True) self.assertEqual(200, resp.status_code) - resp = self.api_call('delete', 'notes/' + note_id, {}, True) + resp = self.api_call('delete', 'note/' + note_id, {}, True) self.assertEqual(404, resp.status_code) self.assertEqual({'message': "The resource of type 'note' with id #4 has not been found.", 'code': 1}, resp.json())