-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(tests): fix lint errors in test_chant.py
- Loading branch information
Showing
1 changed file
with
33 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,12 +113,11 @@ def test_chant_edit_link(self): | |
) | ||
|
||
# have to create project manager user - "View | Edit" toggle only visible for those with edit access for a chant's source | ||
self.user = get_user_model().objects.create(email="[email protected]") | ||
self.user.set_password("pass") | ||
self.user.save() | ||
self.client = Client() | ||
pm_user = get_user_model().objects.create(email="[email protected]") | ||
pm_user.set_password("pass") | ||
pm_user.save() | ||
project_manager = Group.objects.get(name="project manager") | ||
project_manager.user_set.add(self.user) | ||
project_manager.user_set.add(pm_user) | ||
self.client.login(email="[email protected]", password="pass") | ||
|
||
response = self.client.get(reverse("chant-detail", args=[chant.id])) | ||
|
@@ -502,7 +501,8 @@ def test_filter_by_melody(self): | |
source=source, | ||
volpiano=make_fake_volpiano(), | ||
) | ||
chant_without_melody = Chant.objects.create(source=source) | ||
# Create a chant without a melody | ||
Chant.objects.create(source=source) | ||
response = self.client.get(reverse("chant-search"), {"melodies": "true"}) | ||
# only chants with melodies should be in the result | ||
self.assertEqual(len(response.context["chants"]), 1) | ||
|
@@ -554,9 +554,11 @@ def test_search_bar_search(self): | |
manuscript_full_text="Full text contains, but does not start with 'the'", | ||
cantus_id="123456", | ||
) | ||
chant_starting_with_a_number = make_fake_chant( | ||
# Create a chant starting with a number that won't be found by either | ||
# search term | ||
make_fake_chant( | ||
manuscript_full_text=( | ||
"1 is a number. " "How unusual, to find an arabic numeral in a chant!" | ||
"1 is a number. How unusual, to find an arabic numeral in a chant!" | ||
), | ||
cantus_id="234567", | ||
) | ||
|
@@ -1371,7 +1373,7 @@ def test_column_header_links(self): | |
# additional properties for which there are search fields | ||
feast = make_fake_feast() | ||
position = make_random_string(1) | ||
chant = make_fake_chant( | ||
make_fake_chant( | ||
manuscript_full_text_std_spelling=fulltext, | ||
service=service, | ||
genre=genre, | ||
|
@@ -1528,7 +1530,7 @@ def test_feast_column(self): | |
url = feast.get_absolute_url() | ||
fulltext = "manuscript full text" | ||
search_term = "full" | ||
chant = make_fake_chant( | ||
make_fake_chant( | ||
source=source, | ||
manuscript_full_text_std_spelling=fulltext, | ||
feast=feast, | ||
|
@@ -1552,7 +1554,7 @@ def test_service_column(self): | |
url = service.get_absolute_url() | ||
fulltext = "manuscript full text" | ||
search_term = "full" | ||
chant = make_fake_chant( | ||
make_fake_chant( | ||
source=source, | ||
manuscript_full_text_std_spelling=fulltext, | ||
service=service, | ||
|
@@ -1576,7 +1578,7 @@ def test_genre_column(self): | |
url = genre.get_absolute_url() | ||
fulltext = "manuscript full text" | ||
search_term = "full" | ||
chant = make_fake_chant( | ||
make_fake_chant( | ||
source=source, | ||
manuscript_full_text_std_spelling=fulltext, | ||
genre=genre, | ||
|
@@ -1819,7 +1821,8 @@ def test_filter_by_melody(self): | |
source=source, | ||
volpiano=make_fake_volpiano, | ||
) | ||
chant_without_melody = Chant.objects.create(source=source) | ||
# Create a chant without melody that won't be in the result | ||
Chant.objects.create(source=source) | ||
response = self.client.get( | ||
reverse("chant-search-ms", args=[source.id]), {"melodies": "true"} | ||
) | ||
|
@@ -1837,11 +1840,11 @@ def test_keyword_search_starts_with(self): | |
source=source, | ||
manuscript_full_text_std_spelling="quick brown fox jumps over the lazy dog", | ||
) | ||
chant_2 = make_fake_chant( | ||
make_fake_chant( | ||
source=source, | ||
manuscript_full_text_std_spelling="brown fox jumps over the lazy dog", | ||
) | ||
chant_3 = make_fake_chant( | ||
make_fake_chant( | ||
source=source, | ||
manuscript_full_text_std_spelling="lazy brown fox jumps quick over the dog", | ||
) | ||
|
@@ -1860,7 +1863,8 @@ def test_keyword_search_contains(self): | |
source=source, | ||
manuscript_full_text_std_spelling="Quick brown fox jumps over the lazy dog", | ||
) | ||
chant_2 = make_fake_chant( | ||
# Make a chant that won't be returned by the search term | ||
make_fake_chant( | ||
source=source, | ||
manuscript_full_text_std_spelling="brown fox jumps over the lazy dog", | ||
) | ||
|
@@ -1886,11 +1890,11 @@ def test_indexing_notes_search_starts_with(self): | |
source=source, | ||
indexing_notes="quick brown fox jumps over the lazy dog", | ||
) | ||
chant_2 = make_fake_chant( | ||
make_fake_chant( | ||
source=source, | ||
indexing_notes="brown fox jumps over the lazy dog", | ||
) | ||
chant_3 = make_fake_chant( | ||
make_fake_chant( | ||
source=source, | ||
indexing_notes="lazy brown fox jumps quick over the dog", | ||
) | ||
|
@@ -1909,7 +1913,8 @@ def test_indexing_notes_search_contains(self): | |
source=source, | ||
indexing_notes="Quick brown fox jumps over the lazy dog", | ||
) | ||
chant_2 = make_fake_chant( | ||
# Make a chant that won't be returned by the search term | ||
make_fake_chant( | ||
source=source, | ||
indexing_notes="brown fox jumps over the lazy dog", | ||
) | ||
|
@@ -1932,13 +1937,13 @@ def test_keyword_search_searching_all_fields(self): | |
doesnt_include_search_term = "longevity is the soul of wit" | ||
source = make_fake_source() | ||
|
||
chant_ms_spelling = make_fake_chant( | ||
make_fake_chant( | ||
source=source, | ||
manuscript_full_text=includes_search_term, # <== includes_search_term | ||
manuscript_full_text_std_spelling=doesnt_include_search_term, | ||
) | ||
|
||
chant_std_spelling = make_fake_chant( | ||
make_fake_chant( | ||
source=source, | ||
manuscript_full_text=doesnt_include_search_term, | ||
manuscript_full_text_std_spelling=includes_search_term, # <== | ||
|
@@ -1955,7 +1960,8 @@ def test_keyword_search_searching_all_fields(self): | |
manuscript_full_text_std_spelling=None, | ||
) | ||
|
||
chant_without_search_term = make_fake_chant( | ||
# This chant contains no search terms | ||
make_fake_chant( | ||
source=source, | ||
manuscript_full_text=doesnt_include_search_term, | ||
manuscript_full_text_std_spelling=doesnt_include_search_term, | ||
|
@@ -2344,7 +2350,7 @@ def test_column_header_links(self): | |
# additional properties for which there are search fields | ||
feast = make_fake_feast() | ||
position = make_random_string(1) | ||
chant = make_fake_chant( | ||
make_fake_chant( | ||
service=service, | ||
genre=genre, | ||
cantus_id=cantus_id, | ||
|
@@ -2450,9 +2456,7 @@ def test_source_link_column(self): | |
url = source.get_absolute_url() | ||
fulltext = "manuscript full text" | ||
search_term = "full" | ||
chant = make_fake_chant( | ||
source=source, manuscript_full_text_std_spelling=fulltext | ||
) | ||
make_fake_chant(source=source, manuscript_full_text_std_spelling=fulltext) | ||
response = self.client.get( | ||
reverse("chant-search-ms", args=[source.id]), | ||
{"keyword": search_term, "op": "contains"}, | ||
|
@@ -2488,7 +2492,7 @@ def test_feast_column(self): | |
url = feast.get_absolute_url() | ||
fulltext = "manuscript full text" | ||
search_term = "full" | ||
chant = make_fake_chant( | ||
make_fake_chant( | ||
source=source, | ||
manuscript_full_text_std_spelling=fulltext, | ||
feast=feast, | ||
|
@@ -2513,7 +2517,7 @@ def test_service_column(self): | |
url = service.get_absolute_url() | ||
fulltext = "manuscript full text" | ||
search_term = "full" | ||
chant = make_fake_chant( | ||
make_fake_chant( | ||
source=source, | ||
manuscript_full_text_std_spelling=fulltext, | ||
service=service, | ||
|
@@ -2538,7 +2542,7 @@ def test_genre_column(self): | |
url = genre.get_absolute_url() | ||
fulltext = "manuscript full text" | ||
search_term = "full" | ||
chant = make_fake_chant( | ||
make_fake_chant( | ||
source=source, | ||
manuscript_full_text_std_spelling=fulltext, | ||
genre=genre, | ||
|