Пример #1
0
 def test_parsing(self):
     raw_bytes, mime_type = data_uri.data_uri_parse(SAMPLE_DATA_URI)
     self.assertEqual(raw_bytes, PNG_BIN)
     self.assertEqual(mime_type[:2], (b("text"), b("css")))
     self.assertDictEqual(mime_type[2], {
         b("charset"): b("utf-8"),
     })
     raw_bytes, mime_type = data_uri.data_uri_parse(RFC_NOTE_DATA_URI)
     self.assertEqual(raw_bytes, b("A brief note"))
     self.assertEqual(mime_type[:2], (b("text"), b("plain")))
     self.assertDictEqual(mime_type[2], {
         b("charset"): b("US-ASCII"),
     })
Пример #2
0
 def test_identity(self):
     self.assertEqual(
         data_uri.data_uri_parse(
             data_uri.data_uri_encode(PNG_BIN, b("image/png"),
                                      charset=None)),
         (PNG_BIN, (b("image"), b("png"), {})))
     self.assertEqual(
         data_uri.data_uri_parse(
             data_uri.data_uri_encode(PNG_BIN,
                                      b("image/png"),
                                      charset=None,
                                      encoder=None)),
         (PNG_BIN, (b("image"), b("png"), {})))
Пример #3
0
 def test_parsing(self):
   raw_bytes, mime_type = data_uri.data_uri_parse(SAMPLE_DATA_URI)
   self.assertEqual(raw_bytes, PNG_BIN)
   self.assertEqual(mime_type[:2], (b("text"), b("css")))
   self.assertDictEqual(mime_type[2], {
       b("charset"): b("utf-8"),
       })
   raw_bytes, mime_type = data_uri.data_uri_parse(RFC_NOTE_DATA_URI)
   self.assertEqual(raw_bytes, b("A brief note"))
   self.assertEqual(mime_type[:2], (b("text"), b("plain")))
   self.assertDictEqual(mime_type[2], {
       b("charset"): b("US-ASCII"),
       })
Пример #4
0
 def test_identity(self):
   self.assertEqual(
       data_uri.data_uri_parse(
           data_uri.data_uri_encode(PNG_BIN, b("image/png"),
                                    charset=None)),
       (PNG_BIN, (b("image"), b("png"), {}))
       )
   self.assertEqual(
       data_uri.data_uri_parse(
           data_uri.data_uri_encode(PNG_BIN, b("image/png"),
                                    charset=None, encoder=None)),
       (PNG_BIN, (b("image"), b("png"), {}))
       )
Пример #5
0
 def test_parsing_no_metadata(self):
     raw_bytes, mime_type = data_uri.data_uri_parse(NO_META_DATA_URI)
     self.assertEqual(raw_bytes, PNG_BIN)
     self.assertEqual(mime_type[:2], (b("text"), b("plain")))
     self.assertDictEqual(mime_type[2], {
         b("charset"): b("US-ASCII"),
     })
Пример #6
0
 def test_parsing_no_metadata(self):
   raw_bytes, mime_type = data_uri.data_uri_parse(NO_META_DATA_URI)
   self.assertEqual(raw_bytes, PNG_BIN)
   self.assertEqual(mime_type[:2], (b("text"), b("plain")))
   self.assertDictEqual(mime_type[2], {
       b("charset"): b("US-ASCII"),
       })