def test_get_identities(self): test_id = "test_ont_id" wallet = WalletData(default_id=test_id) size = 10 id_list = list() for i in range(size): rand_id = DID_ONT + str(randint(0, 1000000000)) identity = Identity(ont_id=rand_id) wallet.add_identity(identity) id_list.append(rand_id) self.assertEqual(len(wallet.get_identities()), i + 1) identities = wallet.get_identities() self.assertEqual(len(identities), size)
def test_deep_copy(self): wallet_1 = WalletData() size = 10 id_list = list() for i in range(size): rand_id = DID_ONT + str(randint(0, 1000000000)) identity = Identity(ont_id=rand_id) wallet_1.add_identity(identity) id_list.append(rand_id) self.assertEqual(len(wallet_1.get_identities()), i + 1) wallet_2 = copy.deepcopy(wallet_1) self.assertNotEqual(id(wallet_1), id(wallet_2)) self.assertEqual(wallet_1.name, wallet_2.name) wallet_2.name = 'newWallet' self.assertNotEqual(id(wallet_1.name), id(wallet_2.name)) for i in range(size): self.assertEqual(wallet_1.identities[i].ont_id, wallet_2.identities[i].ont_id) rand_id = DID_ONT + str(randint(0, 1000000000)) wallet_1.identities[i].ont_id = rand_id try: wallet_1.identities[i].ont_id = str(randint(0, 1000000000)) except SDKException as e: self.assertTrue(isinstance(e, SDKException)) self.assertNotEqual(wallet_1.identities[i].ont_id, wallet_2.identities[i].ont_id) self.assertNotEqual(id(wallet_1.identities[i]), id(wallet_2.identities[i]))
def test_remove_identity(self): test_id = "test_ont_id" w = WalletData(default_id=test_id) size = 10 id_list = list() for i in range(size): rand_id = random.randint(0, 1000000000) identity = Identity(ont_id=rand_id) w.add_identity(identity) id_list.append(rand_id) self.assertEqual(len(w.get_identities()), i + 1) for i in range(size): rand_id = random.choice(id_list) w.remove_identity(rand_id) id_list.remove(rand_id) self.assertEqual(len(w.get_identities()), size - i - 1)
def test_add_identity(self): test_id = "test_ont_id" wallet = WalletData(default_id=test_id) size = 10 for i in range(size): rand_id = DID_ONT + str(randint(0, 1000000000)) identity = Identity(ont_id=rand_id) wallet.add_identity(identity) self.assertEqual(len(wallet.get_identities()), i + 1)
def test_add_identity(self): test_id = "test_ont_id" w = WalletData(default_id=test_id) size = 10 for i in range(size): rand_id = random.randint(0, 1000000000) identity = Identity(ont_id=rand_id) w.add_identity(identity) self.assertEqual(len(w.get_identities()), i + 1)
def test_remove_identity(self): test_id = "test_ont_id" wallet = WalletData(default_id=test_id) size = 10 id_list = list() for i in range(size): try: rand_id = str(randint(0, 1000000000)) Identity(ont_id=rand_id) except SDKException as e: self.assertTrue(isinstance(e, SDKException)) rand_id = DID_ONT + str(randint(0, 1000000000)) identity = Identity(ont_id=rand_id) wallet.add_identity(identity) id_list.append(rand_id) self.assertEqual(len(wallet.get_identities()), i + 1) for i in range(size): rand_id = choice(id_list) wallet.remove_identity(rand_id) id_list.remove(rand_id) self.assertEqual(len(wallet.get_identities()), size - i - 1)