Ejemplo n.º 1
0
 def test_encoding_of_binary_image_files(self):
     self.assertEqual(
         data_uri.data_uri_encode(read_binary_content(IMAGES_FILE_PNG_PATH),
                                  b("image/png"),
                                  charset=None), IMAGES_FILE_PNG_DATA_URI)
     self.assertEqual(
         data_uri.data_uri_encode(read_binary_content(IMAGES_FILE_JPG_PATH),
                                  b("image/jpg"),
                                  charset=None), IMAGES_FILE_JPG_DATA_URI)
     self.assertEqual(
         data_uri.data_uri_encode(read_binary_content(IMAGES_FILE_GIF_PATH),
                                  b("image/gif"),
                                  charset=None), IMAGES_FILE_GIF_DATA_URI)
Ejemplo n.º 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"), {})))
Ejemplo n.º 3
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"), {}))
       )
Ejemplo n.º 4
0
 def test_encoding_of_binary_image_files(self):
   self.assertEqual(data_uri.data_uri_encode(
       read_binary_content(IMAGES_FILE_PNG_PATH),
       b("image/png"),
       charset=None),
                    IMAGES_FILE_PNG_DATA_URI)
   self.assertEqual(data_uri.data_uri_encode(
       read_binary_content(IMAGES_FILE_JPG_PATH),
       b("image/jpg"),
       charset=None),
                    IMAGES_FILE_JPG_DATA_URI)
   self.assertEqual(data_uri.data_uri_encode(
       read_binary_content(IMAGES_FILE_GIF_PATH),
       b("image/gif"),
       charset=None),
                    IMAGES_FILE_GIF_DATA_URI)
Ejemplo n.º 5
0
  def test_encoding(self):
    self.assertEqual(data_uri.data_uri_encode(PNG_BIN, b("image/png"),
                                              charset=None),
                     PNG_DATA_URI)
    self.assertEqual(data_uri.data_uri_encode(PNG_BIN, b("image/png"),
                                              charset=None, encoder=None),
                     PNG_DATA_URI_QUOTED)

    self.assertEqual(data_uri.data_uri_encode(RFC_GIF, b("image/gif"),
                                              charset=None),
                     RFC_GIF_DATA_URI)
    # self.assertEqual(data_uri.data_uri_encode(RFC_GIF, b("image/gif"),
    #                                           charset=None),
    #                  RFC_GIF_DATA_URI_QUOTED)
    self.assertEqual(data_uri.data_uri_encode(b("A brief note"),
                                              b(""),
                                              b(""), None), RFC_NOTE_DATA_URI)
Ejemplo n.º 6
0
  def test_encoding(self):
    self.assertEqual(data_uri.data_uri_encode(PNG_BIN, b("image/png"),
                                              charset=None),
                     PNG_DATA_URI)
    self.assertEqual(data_uri.data_uri_encode(PNG_BIN, b("image/png"),
                                              charset=None, encoder=None),
                     PNG_DATA_URI_QUOTED)

    self.assertEqual(data_uri.data_uri_encode(RFC_GIF, b("image/gif"),
                                              charset=None),
                     RFC_GIF_DATA_URI)
    # self.assertEqual(data_uri.data_uri_encode(RFC_GIF, b("image/gif"),
    #                                           charset=None),
    #                  RFC_GIF_DATA_URI_QUOTED)
    self.assertEqual(data_uri.data_uri_encode(b("A brief note"),
                                              b(""),
                                              b(""), None), RFC_NOTE_DATA_URI)