comparison test/test_liveserver.py @ 6897:d9c9f5b81d4d

application/javascript is now text/javascript ubuntu-22.04 chnged js file mime type from the depricated application/javascript. to text/javascript. client.py cache text/javascript like application/javascript test_liveserver: use current environment's mapping for .js files to mimetype.
author John Rouillard <rouilj@ieee.org>
date Thu, 01 Sep 2022 15:06:53 -0400
parents 6b636fb29740
children 9ff091537f43
comparison
equal deleted inserted replaced
6896:8987508cff03 6897:d9c9f5b81d4d
1 import shutil, errno, pytest, json, gzip, os, re 1 import shutil, errno, pytest, json, gzip, mimetypes, os, re
2 2
3 from roundup import i18n 3 from roundup import i18n
4 from roundup import password 4 from roundup import password
5 from roundup.anypy.strings import b2s 5 from roundup.anypy.strings import b2s
6 from roundup.cgi.wsgi_handler import RequestDispatcher 6 from roundup.cgi.wsgi_handler import RequestDispatcher
46 # so only allow one port number 46 # so only allow one port number
47 port_range = (9001, 9001) # default is (8080, 8090) 47 port_range = (9001, 9001) # default is (8080, 8090)
48 48
49 dirname = '_test_instance' 49 dirname = '_test_instance'
50 backend = 'anydbm' 50 backend = 'anydbm'
51 51
52 js_mime_type = mimetypes.guess_type("utils.js")[0]
53
52 @classmethod 54 @classmethod
53 def setup_class(cls): 55 def setup_class(cls):
54 '''All tests in this class use the same roundup instance. 56 '''All tests in this class use the same roundup instance.
55 This instance persists across all tests. 57 This instance persists across all tests.
56 Create the tracker dir here so that it is ready for the 58 Create the tracker dir here so that it is ready for the
525 'Accept': '*/*'}) 527 'Accept': '*/*'})
526 print(f.status_code) 528 print(f.status_code)
527 print(f.headers) 529 print(f.headers)
528 530
529 self.assertEqual(f.status_code, 200) 531 self.assertEqual(f.status_code, 200)
530 expected = { 'Content-Type': 'application/javascript', 532 expected = { 'Content-Type': self.js_mime_type,
531 'Content-Encoding': 'gzip', 533 'Content-Encoding': 'gzip',
532 'Vary': 'Accept-Encoding', 534 'Vary': 'Accept-Encoding',
533 } 535 }
534 536
535 # use dict comprehension to remove fields like date, 537 # use dict comprehension to remove fields like date,
584 'Accept': '*/*'}) 586 'Accept': '*/*'})
585 print(f.status_code) 587 print(f.status_code)
586 print(f.headers) 588 print(f.headers)
587 589
588 self.assertEqual(f.status_code, 200) 590 self.assertEqual(f.status_code, 200)
589 expected = { 'Content-Type': 'application/javascript', 591 expected = { 'Content-Type': self.js_mime_type,
590 'Content-Encoding': 'gzip', 592 'Content-Encoding': 'gzip',
591 'Vary': 'Accept-Encoding', 593 'Vary': 'Accept-Encoding',
592 'Content-Length': '69', 594 'Content-Length': '69',
593 } 595 }
594 596
610 'Accept': '*/*'}) 612 'Accept': '*/*'})
611 print(f.status_code) 613 print(f.status_code)
612 print(f.headers) 614 print(f.headers)
613 615
614 self.assertEqual(f.status_code, 200) 616 self.assertEqual(f.status_code, 200)
615 expected = { 'Content-Type': 'application/javascript', 617 expected = { 'Content-Type': self.js_mime_type,
616 'Content-Encoding': 'br', 618 'Content-Encoding': 'br',
617 'Vary': 'Accept-Encoding', 619 'Vary': 'Accept-Encoding',
618 'Content-Length': '960', 620 'Content-Length': '960',
619 } 621 }
620 622
644 'Accept': '*/*'}) 646 'Accept': '*/*'})
645 print(f.status_code) 647 print(f.status_code)
646 print(f.headers) 648 print(f.headers)
647 649
648 self.assertEqual(f.status_code, 200) 650 self.assertEqual(f.status_code, 200)
649 expected = { 'Content-Type': 'application/javascript', 651 expected = { 'Content-Type': self.js_mime_type,
650 'Content-Encoding': 'gzip', 652 'Content-Encoding': 'gzip',
651 'Vary': 'Accept-Encoding', 653 'Vary': 'Accept-Encoding',
652 } 654 }
653 655
654 # use dict comprehension to remove fields like date, 656 # use dict comprehension to remove fields like date,
822 'Accept': '*/*'}) 824 'Accept': '*/*'})
823 print(f.status_code) 825 print(f.status_code)
824 print(f.headers) 826 print(f.headers)
825 827
826 self.assertEqual(f.status_code, 200) 828 self.assertEqual(f.status_code, 200)
827 expected = { 'Content-Type': 'application/javascript', 829 expected = { 'Content-Type': self.js_mime_type,
828 'Content-Encoding': method, 830 'Content-Encoding': method,
829 'Vary': 'Accept-Encoding', 831 'Vary': 'Accept-Encoding',
830 } 832 }
831 833
832 # compare to byte string as f.content may be compressed. 834 # compare to byte string as f.content may be compressed.

Roundup Issue Tracker: http://roundup-tracker.org/