Пример #1
0
 def test_guesses_content_type_on_file_encoding(self):
     self.assertEqual(b'Content-Type: application/octet-stream',
                      encode_file('IGNORE', 'IGNORE', DummyFile("file.bin"))[2])
     self.assertEqual(b'Content-Type: text/plain',
                      encode_file('IGNORE', 'IGNORE', DummyFile("file.txt"))[2])
     self.assertIn(encode_file('IGNORE', 'IGNORE', DummyFile("file.zip"))[2], (
                     b'Content-Type: application/x-compress',
                     b'Content-Type: application/x-zip',
                     b'Content-Type: application/x-zip-compressed',
                     b'Content-Type: application/zip',))
     self.assertEqual(b'Content-Type: application/octet-stream',
                      encode_file('IGNORE', 'IGNORE', DummyFile("file.unknown"))[2])
Пример #2
0
 def test_file_encoding(self):
     encoded_file = encode_file('TEST_BOUNDARY', 'TEST_KEY', DummyFile('test_name.bin'))
     self.assertEqual(b'--TEST_BOUNDARY', encoded_file[0])
     self.assertEqual(b'Content-Disposition: form-data; name="TEST_KEY"; filename="test_name.bin"', encoded_file[1])
     self.assertEqual(b'TEST_FILE_CONTENT', encoded_file[-1])