Skip to content

Commit 04b5f4f

Browse files
committed
Add test
1 parent 81c3ec7 commit 04b5f4f

8 files changed

Lines changed: 59 additions & 3 deletions

File tree

lunes_cms/api/v1/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
name="swagger-ui",
6161
),
6262
path(
63-
"documents_by_string/<word>",
63+
"search_duplicate/<word>",
6464
find_duplicates_for_word,
65-
name="documents_by_string",
65+
name="search_duplicate",
6666
),
6767
]

lunes_cms/cms/fixtures/test_data.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13412,6 +13412,20 @@
1341213412
"creator_is_admin": true
1341313413
}
1341413414
},
13415+
{
13416+
"model": "cms.document",
13417+
"pk": 2332,
13418+
"fields": {
13419+
"word_type": "Verb",
13420+
"word": "implementieren",
13421+
"singular_article": 0,
13422+
"definition": "in ein bestehendes Computersystem einsetzen, einbauen und so ein funktionsfähiges Programm erstellen",
13423+
"example_sentence": "eine neue Software implementieren",
13424+
"creation_date": "2021-04-13T15:58:10.468Z",
13425+
"created_by": null,
13426+
"creator_is_admin": true
13427+
}
13428+
},
1341513429
{
1341613430
"model": "cms.alternativeword",
1341713431
"pk": 1,

lunes_cms/static/js/toggle_plural_field.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ $(document).ready(() => {
8383
if ($(event.target).val().length > 0) {
8484
$.ajax({
8585
type: 'GET',
86-
url: '/api/documents_by_string/' + $(event.target).val(),
86+
url: '/api/search_duplicate/' + $(event.target).val(),
8787
dataType: "json",
8888
success: function(data) {
8989
showDuplicates(data, $(event.target).closest(".card-body"));

tests/api/api_config.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,26 @@
388388
},
389389
]
390390

391+
392+
SEARCH_DUPLICATE_ENDPOINTS = [
393+
{
394+
"endpoint": "/api/search_duplicate/implementieren",
395+
"expected_result": "tests/api/expected-results/duplicate_implementieren.json",
396+
},
397+
{
398+
"endpoint": "/api/search_duplicate/Schere",
399+
"expected_result": "tests/api/expected-results/duplicate_Schere.json",
400+
},
401+
{
402+
"endpoint": "/api/search_duplicate/Ei",
403+
"expected_result": "tests/api/expected-results/duplicate_Ei.json",
404+
},
405+
{
406+
"endpoint": "/api/search_duplicate/neueswort",
407+
"expected_result": "tests/api/expected-results/duplicate_neueswort.json",
408+
},
409+
]
410+
391411
#: The API endpoints
392412
API_ENDPOINTS = (
393413
DISCIPLINE_ENDPOINTS
@@ -396,6 +416,7 @@
396416
+ GROUP_ENDPOINTS
397417
+ FEEDBACK_ENDPOINTS
398418
+ SPONSOR_ENDPOINTS
419+
+ SEARCH_DUPLICATE_ENDPOINTS
399420
)
400421

401422
#: Convert the dicts to tuples with a fixed length
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"message": "This word is already registered in the system.",
3+
"word": "📷 (das) Ei (Nomen)",
4+
"definition": "Definition: Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua",
5+
"training_sets": "Training sets: Zutaten"
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"message": "This word is already registered in the system.",
3+
"word": "📷 (die) Schere (Nomen)",
4+
"definition": "Definition: No definition is provided for this word.",
5+
"training_sets": "Training sets: Grundlagen Werkzeuge, Grundlagen Rezeption"
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"message": "This word is already registered in the system.",
3+
"word": "⚠ (keiner) implementieren (Verb)",
4+
"definition": "Definition: in ein bestehendes Computersystem einsetzen, einbauen und so ein funktionsfähiges Programm erstellen",
5+
"training_sets": "Training sets: This word is assigned to no training set."
6+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"message": "This word is not yet registered in the system"
3+
}

0 commit comments

Comments
 (0)