Exemplo n.º 1
0
	def test_follower_change(self):
		# user1 was followed by 2 users.
		# user1 <- user2
		# user1 <- user3 (unfollow)
		# user1 <- user4

		# new follower is
		followers = [2,3,5]
		
		db_update.update_followers(
				user_id = 1,
				followers = followers
				)

		# Now, user1 is followed by 3 users.
		# user1 <- user2
		# user1 <- user3 (followed)
		# user1 <- user4 (unfollow)
		# user1 <- user5

		#data = serializers.serialize("json", UserFriend.objects.all())
		#print(data)

		now = time.time()
		inner = Q(start_date__lte = now, end_date__gt = now)

		ufollowers = UserProfile.objects.get(user_id = 1).followers

		self.assertNotEquals(ufollowers.get(       user = 2).unfollow, True)
		self.assertNotEquals(ufollowers.get(inner, user = 3).unfollow, True)
		self.assertEquals   (ufollowers.get(inner, user = 4).unfollow, True)
		self.assertNotEquals(ufollowers.get(inner, user = 5).unfollow, True)
Exemplo n.º 2
0
	def test_follower_change_new_user(self):
		followers = [2,3,5]
		
		db_update.update_followers(
				user_id = u'6',
				followers = followers
				)
		try:
			user = UserProfile.objects.get(user_id = 6)
		except:
			self.fail('user not created')

		now = time.time()
		inner = Q(start_date__lte = now, end_date__gt = now)

		ufollowers = user.followers

		self.assertNotEquals(ufollowers.get(inner, user = 2).unfollow, True)
		self.assertNotEquals(ufollowers.get(inner, user = 3).unfollow, True)
		self.assertNotEquals(ufollowers.get(inner, user = 5).unfollow, True)