Configure tests and add support for postgres & solr8
Showing 7 of 15 files from the diff.
mep/books/views.py
changed.
mep/books/queryset.py
changed.
mep/people/views.py
changed.
Other files ignored by Codecov
mep/books/fixtures/sample_works.json
has changed.
ci/testsettings.py
has changed.
mep/footnotes/fixtures/sample_cards.json
has changed.
mep/accounts/fixtures/test_events.json
has changed.
README.rst
has changed.
.github/workflows/unit_tests.yml
has changed.
requirements.txt
has changed.
mep/books/fixtures/multi_creator_work.json
has changed.
@@ -108,7 +108,7 @@
Loading
108 | 108 | ||
109 | 109 | # add one each of author, editor, and translator |
|
110 | 110 | Creator.objects.create( |
|
111 | - | creator_type=author_type, person=author1, work=work) |
|
111 | + | creator_type=author_type, person=author1, work=work, order=1) |
|
112 | 112 | Creator.objects.create( |
|
113 | 113 | creator_type=editor_type, person=editor, work=work) |
|
114 | 114 | Creator.objects.create( |
@@ -120,7 +120,7 @@
Loading
120 | 120 | ||
121 | 121 | # add second author |
|
122 | 122 | Creator.objects.create(creator_type=author_type, person=author2, |
|
123 | - | work=work) |
|
123 | + | work=work, order=2) |
|
124 | 124 | assert len(work.authors) == 2 |
|
125 | 125 | assert author1 in work.authors |
|
126 | 126 | assert author2 in work.authors |
@@ -267,12 +267,12 @@
Loading
267 | 267 | author_type = CreatorType.objects.get(name='Author') |
|
268 | 268 | author1 = Person.objects.create(name='Smith', slug='s') |
|
269 | 269 | Creator.objects.create( |
|
270 | - | creator_type=author_type, person=author1, work=work) |
|
270 | + | creator_type=author_type, person=author1, work=work, order=1) |
|
271 | 271 | assert work.author_list() == 'Smith' |
|
272 | 272 | # multiple authors |
|
273 | 273 | author2 = Person.objects.create(name='Jones', slug='j') |
|
274 | 274 | Creator.objects.create( |
|
275 | - | creator_type=author_type, person=author2, work=work) |
|
275 | + | creator_type=author_type, person=author2, work=work, order=2) |
|
276 | 276 | assert work.author_list() == 'Smith; Jones' |
|
277 | 277 | ||
278 | 278 | def test_sort_author_list(self): |
@@ -111,7 +111,7 @@
Loading
111 | 111 | # instead of hard-coding here |
|
112 | 112 | ||
113 | 113 | #: bib data query alias field syntax (configured defaults is edismax) |
|
114 | - | search_bib_query = '{!qf=$bib_qf pf=$bib_pf v=$bib_query}' |
|
114 | + | search_bib_query = '{!type=edismax qf=$bib_qf pf=$bib_pf v=$bib_query}' |
|
115 | 115 | ||
116 | 116 | def get_queryset(self): |
|
117 | 117 | # NOTE faceting so that response doesn't register as an error; |
@@ -14,6 +14,10 @@
Loading
14 | 14 | # and from winthrop-django |
|
15 | 15 | ||
16 | 16 | ||
17 | + | skipif_postgres = pytest.mark.skipif(settings.DATABASES["default"]["ENGINE"].endswith('postgresql'), |
|
18 | + | reason="doesn't work on postgres") |
|
19 | + | ||
20 | + | ||
17 | 21 | @pytest.mark.last |
|
18 | 22 | class TestMigrations(TransactionTestCase): |
|
19 | 23 |
@@ -133,6 +137,8 @@
Loading
133 | 137 | # to be present by other tests. |
|
134 | 138 | # Django test runner runs transaction test cases after simple test cases, |
|
135 | 139 | # but pytest / pytest-django do not. |
|
140 | + | ||
141 | + | @skipif_postgres |
|
136 | 142 | @pytest.mark.second_to_last |
|
137 | 143 | class TestCopyPrecisions(DatePrecisionCopies): |
|
138 | 144 |
@@ -163,6 +169,7 @@
Loading
163 | 169 | self.check_copy_precisions(self.old_purchases, Purchase) |
|
164 | 170 | ||
165 | 171 | ||
172 | + | @skipif_postgres |
|
166 | 173 | @pytest.mark.last |
|
167 | 174 | class TestRevertPrecisionCopy(DatePrecisionCopies): |
|
168 | 175 | migrate_from = '0028_generic_event_partial_dates' |
@@ -28,7 +28,7 @@
Loading
28 | 28 | } |
|
29 | 29 | ||
30 | 30 | # edismax alias for searching on admin work pseudo-field |
|
31 | - | admin_work_qf = '{!qf=$admin_work_qf pf=$admin_work_pf v=$work_query}' |
|
31 | + | admin_work_qf = '{!type=edismax qf=$admin_work_qf pf=$admin_work_pf v=$work_query}' |
|
32 | 32 | ||
33 | 33 | def search_admin_work(self, search_term): |
|
34 | 34 | return self.search(self.admin_work_qf) \ |
@@ -6,20 +6,20 @@
Loading
6 | 6 | @pytest.mark.last |
|
7 | 7 | class TestPersonGenerateSlugs(TestMigrations): |
|
8 | 8 | ||
9 | - | app = 'people' |
|
10 | - | migrate_from = '0015_add_person_optional_slug' |
|
11 | - | migrate_to = '0017_person_require_unique_slugs' |
|
9 | + | app = "people" |
|
10 | + | migrate_from = "0015_add_person_optional_slug" |
|
11 | + | migrate_to = "0017_person_require_unique_slugs" |
|
12 | 12 | ||
13 | 13 | def setUpBeforeMigration(self, apps): |
|
14 | - | Person = apps.get_model('people', 'Person') |
|
14 | + | Person = apps.get_model("people", "Person") |
|
15 | 15 | self.Person = Person |
|
16 | 16 | ||
17 | 17 | # create people to test slug logic |
|
18 | 18 | # - unique last name |
|
19 | - | self.hemingway = Person.objects.create(sort_name='Hemingway, Ernest') |
|
19 | + | self.hemingway = Person.objects.create(sort_name="Hemingway, Ernest") |
|
20 | 20 | # variants in special characters |
|
21 | - | self.erna = Person.objects.create(sort_name='Döblin, Erna Reiss') |
|
22 | - | self.alfred = Person.objects.create(sort_name='Döblin, Alfred') |
|
21 | + | self.erna = Person.objects.create(sort_name="Döblin, Erna Reiss") |
|
22 | + | self.alfred = Person.objects.create(sort_name="Döblin, Alfred") |
|
23 | 23 | # variants in case |
|
24 | 24 | self.destaing1 = Person.objects.create(sort_name="D'Estaing") |
|
25 | 25 | self.destaing2 = Person.objects.create(sort_name="d'Estaing") |
@@ -35,23 +35,27 @@
Loading
35 | 35 | # get fresh copies of records to see changes |
|
36 | 36 | hemingway = self.Person.objects.get(pk=self.hemingway.pk) |
|
37 | 37 | # lastname only if sufficient |
|
38 | - | assert hemingway.slug == 'hemingway' |
|
38 | + | assert hemingway.slug == "hemingway" |
|
39 | 39 | # group Dö/Dö properly |
|
40 | 40 | erna = self.Person.objects.get(pk=self.erna.pk) |
|
41 | - | assert erna.slug == 'doblin-erna-reiss' |
|
41 | + | assert erna.slug == "doblin-erna-reiss" |
|
42 | 42 | alfred = self.Person.objects.get(pk=self.alfred.pk) |
|
43 | - | assert alfred.slug == 'doblin-alfred' |
|
43 | + | assert alfred.slug == "doblin-alfred" |
|
44 | 44 | # group upper/lowercase properly |
|
45 | 45 | destaing1 = self.Person.objects.get(pk=self.destaing1.pk) |
|
46 | - | assert destaing1.slug == 'destaing' |
|
47 | 46 | destaing2 = self.Person.objects.get(pk=self.destaing2.pk) |
|
48 | - | assert destaing2.slug == 'destaing-2' |
|
47 | + | # NOTE: postgres sorts differently than mysql, but that |
|
48 | + | # doesn't really matter here; just check that |
|
49 | + | # both slugs were generated as expected |
|
50 | + | destaing_slugs = [destaing1.slug, destaing2.slug] |
|
51 | + | assert "destaing" in destaing_slugs |
|
52 | + | assert "destaing-2" in destaing_slugs |
|
53 | + | ||
49 | 54 | # multiples |
|
50 | 55 | adams1 = self.Person.objects.get(pk=self.adams1.pk) |
|
51 | 56 | adams2 = self.Person.objects.get(pk=self.adams2.pk) |
|
52 | 57 | adams3 = self.Person.objects.get(pk=self.adams3.pk) |
|
53 | 58 | adams4 = self.Person.objects.get(pk=self.adams4.pk) |
|
54 | - | assert adams1.slug == 'adams' |
|
55 | - | assert adams2.slug == 'adams-2' |
|
56 | - | assert adams3.slug == 'adams-3' |
|
57 | - | assert adams4.slug == 'adams-4' |
|
59 | + | adams_slugs = [adams1.slug, adams2.slug, adams3.slug, adams4.slug] |
|
60 | + | for slug in ["adams", "adams-2", "adams-3", "adams-4"]: |
|
61 | + | assert slug in adams_slugs |
@@ -119,7 +119,7 @@
Loading
119 | 119 | return min_max_ranges |
|
120 | 120 | ||
121 | 121 | #: name query alias field syntax (type defaults to edismax in solr config) |
|
122 | - | search_name_query = '{!qf=$name_qf pf=$name_pf v=$name_query}' |
|
122 | + | search_name_query = '{!type=edismax qf=$name_qf pf=$name_pf v=$name_query}' |
|
123 | 123 | ||
124 | 124 | # map form sort to solr sort field |
|
125 | 125 | solr_sort = { |
@@ -73,7 +73,11 @@
Loading
73 | 73 | self.cmd.get_date(date='1920-05', mode='report') |
|
74 | 74 | ||
75 | 75 | def test_find_events(self): |
|
76 | - | borrow = Event.objects.filter(borrow__isnull=False).first() |
|
76 | + | borrow = Event.objects.filter( |
|
77 | + | borrow__isnull=False, start_date__isnull=False, end_date__isnull=False, |
|
78 | + | start_date_precision__knownyear=True, end_date_precision__knownyear=True) \ |
|
79 | + | .first() |
|
80 | + | ||
77 | 81 | # borrow — both start date and end date |
|
78 | 82 | assert borrow in self.cmd.find_events(borrow.start_date) |
|
79 | 83 | assert borrow in self.cmd.find_events(borrow.end_date) |
Files | Coverage |
---|---|
mep | 98.44% |
srcmedia/ts | 86.55% |
manage.py | 0.00% |
Project Totals (233 files) | 97.92% |
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file.
The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files.
The size and color of each slice is representing the number of statements and the coverage, respectively.