def test_string_from_ndr(self): info = drsblobs.repsFromTo2OtherInfo() info.dns_name1 = "1.example.com" info.dns_name2 = "2.example.com" packed = ndr_pack(info) gc.collect() info_unpacked = ndr_unpack(drsblobs.repsFromTo2OtherInfo, packed) self.assertIsNotNone(info_unpacked) self.assertEqual(info_unpacked.dns_name1, "1.example.com") self.assertEqual(info_unpacked.dns_name2, "2.example.com")
def test_string_modify_in_place(self): info = drsblobs.repsFromTo2OtherInfo() info.dns_name1 = "1.example.com" info.dns_name2 = "%s.example.com" gc.collect() self.assertIsNotNone(info) self.assertEqual(info.dns_name1, "1.example.com") self.assertEqual(info.dns_name2, "%s.example.com") info.dns_name1 += ".co.nz" info.dns_name2 %= 2 self.assertEqual(info.dns_name1, "1.example.com.co.nz") self.assertEqual(info.dns_name2, "2.example.com") del info
def test_string_delete(self): gc.collect() info = drsblobs.repsFromTo2OtherInfo() info.dns_name1 = "1.example.com" info.dns_name2 = "2.example.com" info.dns_name1 = None try: del info.dns_name2 except AttributeError: pass self.assertIsNotNone(info) self.assertIsNone(info.dns_name1) self.assertIsNotNone(info.dns_name2)
def test_string_from_python(self): info = drsblobs.repsFromTo2OtherInfo() info.dns_name1 = "hello.example.com" info.dns_name2 = "goodbye.example.com" gc.collect() self.assertIsNotNone(info) self.assertEqual(info.dns_name1, "hello.example.com") self.assertEqual(info.dns_name2, "goodbye.example.com") info.dns_name1 = "" info.dns_name2 = "goodbye.example.com" self.assertEqual(info.dns_name1, "") self.assertEqual(info.dns_name2, "goodbye.example.com") info.dns_name2 = None self.assertEqual(info.dns_name1, "") self.assertIsNone(info.dns_name2)
def get_info(): info = drsblobs.repsFromTo2OtherInfo() info.dns_name1 = "1.example.com" info.dns_name2 = "2.example.com" return info