def testSample(self): u1 = User.new(self.g, {"id": "CH"}) u2 = User.new(self.g, {"id": "Cl"}) u3 = User.new(self.g, {"id": "C"}) users = User.sample(self.g, n=2) self.assertEqual(len(users), 2)
def testGetFollowerTweets(self): mu = User.new(self.g, {"id": 1234, "screen_name": "member"}) u = mu.add_followers([ { "id": 2345, "screen_name": "follower" }, ])[0] u.add_tweets([ { "id": 1, "text": "tw0" }, { "id": 2, "text": "tw1" }, { "id": 3, "text": "tw2" }, { "id": 4, "text": "tw3" }, ]) result = set(t["text"] for t in mu.get_follower_tweets()) self.assertEqual(result, set(["tw0", "tw1", "tw2", "tw3"]))
def testGetTweets(self): u = User.new(self.g, {"id": "CH"}) u.add_tweets([ {"id":1, "text":"tw0"}, {"id":2, "text":"tw1"}, {"id":3, "text":"tw2"}, {"id":4, "text":"tw3"}, ]) result = set(t["text"] for t in u.get_tweets()) self.assertEqual(result, set(["tw0", "tw1", "tw2", "tw3"]))
def testGetFollowerTweets(self): mu = User.new(self.g, {"id":1234, "screen_name":"member"}) u =mu.add_followers( [{"id": 2345, "screen_name":"follower"}, ])[0] u.add_tweets([ {"id":1, "text":"tw0"}, {"id":2, "text":"tw1"}, {"id":3, "text":"tw2"}, {"id":4, "text":"tw3"}, ]) result = set(t["text"] for t in mu.get_follower_tweets()) self.assertEqual(result, set(["tw0", "tw1", "tw2", "tw3"]))
def testGetTweets(self): u = User.new(self.g, {"id": "CH"}) u.add_tweets([ { "id": 1, "text": "tw0" }, { "id": 2, "text": "tw1" }, { "id": 3, "text": "tw2" }, { "id": 4, "text": "tw3" }, ]) result = set(t["text"] for t in u.get_tweets()) self.assertEqual(result, set(["tw0", "tw1", "tw2", "tw3"]))
def testAddNewUser(self): u = User.new(self.g, properties=self.USER_DATA) u.get_followers()
def testGraphPush(self): u = User.new(self.g, {"id": 1234, "name": "Froo Froo"}) u.push()
def testAddUserWithExtraAttrs(self): u0 = User.new(self.g, {"id": 123456, "screen_name": "fluffer1"}) u1 = User.find_one(self.g, {"screen_name": "fluffer1"}) self.assertEqual(u0, u1)
def testMergeUser(self): u0 = User.new(self.g, {"id": 123456, "screen_name": "fluffer1"}) u1 = User.new(self.g, {"id": 123456}) self.assertEqual(u0["screen_name"], u1["screen_name"]) self.assertEqual(u1["screen_name"], "fluffer1")
def testInvalidUser(self): with self.assertRaises(MissingProperty): User.new(self.g, {"fod": "foo"})