def test_set_data_and_packed_data(self): a = Artifact() self.assertEqual(a.data, None) self.assertEqual(a.packed_data, None) a.data = "Blob" self.assertRaises(ValueError, _set_packed_data, a, "blob") a.data = None a.packed_data = "Blob" self.assertRaises(ValueError, _set_data, a, "blob") a.packed_data = None
def test_set_data_and_packed_data(self): a = Artifact() self.assertEqual(a.data, None) self.assertEqual(a.packed_data, None) a.data = b"Blob" self.assertRaises(ValueError, _set_packed_data, a, u("blob")) a.data = None a.packed_data = u("Blob") self.assertRaises(ValueError, _set_data, a, b"blob") a.packed_data = None
def test_cannot_set_nonascii_artifact_packed_data(self): a = Artifact() a.packed_data = u("\x00abc123\xff") self.assertEqual(six.text_type, type(a.packed_data)) # TODO: Should this raise an error sooner, since there's nothing we can # do at this point? There's no reason that the packed_data should # contain non-ascii characters. self.assertRaises(UnicodeEncodeError, _get_data, a)
def test_cannot_set_nonascii_artifact_packed_data(self): a = Artifact() a.packed_data = u("\x00abc123\xff") self.assertEqual(six.text_type, type(a.packed_data)) #TODO: Should this raise an error sooner, since there's nothing we can # do at this point? There's no reason that the packed_data should # contain non-ascii characters. self.assertRaises(UnicodeEncodeError, _get_data, a)
def test_setting_ascii_artifact_packed_data_no_packaging(self): a = Artifact() a.packed_data = u("abc123") self.assertEqual(six.binary_type, type(a.data)) self.assertEqual(six.text_type, type(a.packed_data))
def test_setting_ascii_artifact_packed_data_no_packaging(self): a = Artifact() a.packed_data = u("abc123") self.assertEqual(six.binary_type, type(a.data)) self.assertEqual(six.text_type, type(a.packed_data))