|
8 | 8 | import io |
9 | 9 | import os |
10 | 10 | import random |
| 11 | +import re |
11 | 12 | import shutil |
12 | 13 | import six |
13 | 14 |
|
|
21 | 22 | from django.urls import reverse as urlreverse |
22 | 23 | from django.conf import settings |
23 | 24 | from django.contrib.auth.models import User |
| 25 | +from django.test import Client |
24 | 26 |
|
25 | 27 | import debug # pyflakes:ignore |
26 | 28 |
|
@@ -300,6 +302,26 @@ def do_test_materials(self, meeting, session): |
300 | 302 | kwargs=dict(num=meeting.number, document=session.minutes())) |
301 | 303 | r = self.client.get(url) |
302 | 304 | self.assertContains(r, "1. More work items underway") |
| 305 | + |
| 306 | + |
| 307 | + cont_disp = r._headers.get('content-disposition', ('Content-Disposition', ''))[1] |
| 308 | + cont_disp = re.split('; ?', cont_disp) |
| 309 | + cont_disp_settings = dict( e.split('=', 1) for e in cont_disp if '=' in e ) |
| 310 | + filename = cont_disp_settings.get('filename', '').strip('"') |
| 311 | + if filename.endswith('.md'): |
| 312 | + for accept, cont_type, content in [ |
| 313 | + ('text/html,text/plain,text/markdown', 'text/html', '<li><p>More work items underway</p></li>'), |
| 314 | + ('text/markdown,text/html,text/plain', 'text/markdown', '1. More work items underway'), |
| 315 | + ('text/plain,text/markdown, text/html', 'text/plain', '1. More work items underway'), |
| 316 | + ('text/html', 'text/html', '<li><p>More work items underway</p></li>'), |
| 317 | + ('text/markdown', 'text/markdown', '1. More work items underway'), |
| 318 | + ('text/plain', 'text/plain', '1. More work items underway'), |
| 319 | + ]: |
| 320 | + client = Client(HTTP_ACCEPT=accept) |
| 321 | + r = client.get(url) |
| 322 | + rtype = r['Content-Type'].split(';')[0] |
| 323 | + self.assertEqual(cont_type, rtype) |
| 324 | + self.assertContains(r, content) |
303 | 325 |
|
304 | 326 | # test with explicit meeting number in url |
305 | 327 | if meeting.number.isdigit(): |
|
0 commit comments