예제 #1
0
파일: test_idroutine.py 프로젝트: yinyin/dp
	def test_dup_gen(self):
		""" allocate id twice """

		objrepo = {}

		mobj = MockIdentifiableObject_1(1)
		mid_a = dpcore.allocate_object_id(mobj, "T", objrepo)
		mid_b = dpcore.allocate_object_id(mobj, "T", objrepo)

		self.assertTrue(mid_a is not None)
		self.assertTrue(mid_b is not None)
		self.assertEqual(mid_a, mid_b)
		self.assertEqual(len(objrepo), 1)
		self.assertEqual(objrepo[mid_a], mobj)
예제 #2
0
파일: test_idroutine.py 프로젝트: yinyin/dp
	def test_allocate_for_diffobj(self):
		""" allocate for different objects """

		objrepo = {}

		mobj_a = MockIdentifiableObject_1(1)
		mobj_b = MockIdentifiableObject_1("a")
		mid_a = dpcore.allocate_object_id(mobj_a, "T", objrepo)
		mid_b = dpcore.allocate_object_id(mobj_b, "T", objrepo)

		self.assertTrue(mid_a is not None)
		self.assertTrue(mid_b is not None)
		self.assertNotEqual(mid_a, mid_b)
		self.assertEqual(len(objrepo), 2)
		self.assertEqual(objrepo[mid_a], mobj_a)
		self.assertEqual(objrepo[mid_b], mobj_b)
예제 #3
0
파일: test_idroutine.py 프로젝트: yinyin/dp
	def test_allocate_w_empty_object(self):
		""" allocate id for empty (object signature is None) object """

		objrepo = {}

		mobj = MockIdentifiableObject_1(None)
		mid = dpcore.allocate_object_id(mobj, "T", objrepo)

		self.assertTrue(mid is None)
		self.assertEqual(len(objrepo), 0)