def test_from_uri_base64_header_empty_data(self): e = DataMemoryElement.from_uri('base64://') ntools.assert_is_instance(e, DataMemoryElement) # no base64 data, which should decode to no bytes ntools.assert_equal(e.get_bytes(), six.b(''))
def test_from_uri_data_format(self): e = DataMemoryElement.from_uri(self.VALID_DATA_URI) ntools.assert_is_instance(e, DataMemoryElement) ntools.assert_equal(e.get_bytes(), self.EXPECTED_BYTES) ntools.assert_equal(e.content_type(), self.EXPECTED_CT)
def test_from_uri_empty_string(self): # Should return an element with no byte data e = DataMemoryElement.from_uri('') ntools.assert_is_instance(e, DataMemoryElement) # no base64 data, which should decode to no bytes ntools.assert_equal(e.get_bytes(), six.b(''))
def test_from_uri_base64_header(self): e = DataMemoryElement.from_uri(self.VALID_B64_URI) ntools.assert_is_instance(e, DataMemoryElement) ntools.assert_equal(e.get_bytes(), self.EXPECTED_BYTES) # No content type info in base64 format ntools.assert_equal(e.content_type(), None)
def test_from_uri_data_format_empty_data(self): e = DataMemoryElement.from_uri('data:text/plain;base64,') ntools.assert_is_instance(e, DataMemoryElement) # no base64 data, which should decode to no bytes ntools.assert_equal(e.get_bytes(), six.b('')) ntools.assert_equal(e.content_type(), 'text/plain')
def test_from_uri_base64_header_empty_data(self): e = DataMemoryElement.from_uri('base64://') self.assertIsInstance(e, DataMemoryElement) # no base64 data, which should decode to no bytes self.assertEqual(e.get_bytes(), six.b(''))
def test_from_uri_empty_string(self): # Should return an element with no byte data e = DataMemoryElement.from_uri('') self.assertIsInstance(e, DataMemoryElement) # no base64 data, which should decode to no bytes self.assertEqual(e.get_bytes(), six.b(''))
def test_from_uri_data_format(self): e = DataMemoryElement.from_uri(self.VALID_DATA_URI) self.assertIsInstance(e, DataMemoryElement) self.assertEqual(e.get_bytes(), self.EXPECTED_BYTES) self.assertEqual(e.content_type(), self.EXPECTED_CT)
def test_from_uri_data_format_empty_data(self): e = DataMemoryElement.from_uri('data:text/plain;base64,') self.assertIsInstance(e, DataMemoryElement) # no base64 data, which should decode to no bytes self.assertEqual(e.get_bytes(), six.b('')) self.assertEqual(e.content_type(), 'text/plain')
def test_from_uri_base64_header(self): e = DataMemoryElement.from_uri(self.VALID_B64_URI) self.assertIsInstance(e, DataMemoryElement) self.assertEqual(e.get_bytes(), self.EXPECTED_BYTES) # No content type info in base64 format self.assertEqual(e.content_type(), None)