Example #1
0
	def testConversationIdsFromParent(self):
		'''Check that the correct conversation id can be found based on a parent hash'''
		startId = DbClient.getNewConversationId()
		# Does it work on an empty inbox?
		DbClient._getInboxTable().remove()
		nextId = DbClient.getConversationId("some random hash")
		self.assertEqual(startId+1, nextId, "Should increment if hash not found in empty inbox")
		nextId = DbClient.getConversationId(None)
		self.assertEqual(startId+2, nextId, "Should increment if None hash given")
		nextId = DbClient.getConversationId("")
		self.assertEqual(startId+3, nextId, "Should increment if empty string hash given")
		# Now add a message with a hash
		rowToStore = {"messageType":"normal", "fromId":"BCD123EFG456HI78", "timestamp":"2012-01-08-13-18",
			"messageBody":"I do like a day beside the seaside", "recipients":"ABC123DEF456GH78"}
		DbClient.addMessageToInbox(rowToStore)
		nextId = DbClient.getConversationId("some random hash")
		self.assertEqual(startId+5, nextId, "Should increment if hash not found in inbox")
		nextId = DbClient.getConversationId("7b6dd00818a70515ba560efc5a42aab5")
		self.assertEqual(startId+4, nextId, "Should take the old id if hash was found in inbox")
		anotherId = DbClient.getConversationId("7b6dd00818a70515ba560efc5a42aab5")
		self.assertEqual(anotherId, nextId, "Should reuse the same id if hash was found in inbox")
Example #2
0
	def testConversationIds(self):
		'''Check that generating and incrementing conversation ids works using the admin table'''
		DbClient._getAdminTable().remove()
		for i in range(1, 2000):
			nextId = DbClient.getNewConversationId()
			self.assertEqual(nextId, i, "the conversation id " + str(i) + " should match")