Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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"]))
Ejemplo n.º 4
0
    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"]))
Ejemplo n.º 5
0
    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"]))
Ejemplo n.º 6
0
    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"]))
Ejemplo n.º 7
0
 def testAddNewUser(self):
     u = User.new(self.g, properties=self.USER_DATA)
     u.get_followers()
Ejemplo n.º 8
0
 def testGraphPush(self):
     u = User.new(self.g, {"id": 1234, "name": "Froo Froo"})
     u.push()
Ejemplo n.º 9
0
 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)
Ejemplo n.º 10
0
    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")
Ejemplo n.º 11
0
 def testInvalidUser(self):
     with self.assertRaises(MissingProperty):
         User.new(self.g, {"fod": "foo"})
Ejemplo n.º 12
0
 def testGraphPush(self):
     u = User.new(self.g, {"id": 1234, "name": "Froo Froo"})
     u.push()
Ejemplo n.º 13
0
 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)
Ejemplo n.º 14
0
    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")
Ejemplo n.º 15
0
 def testInvalidUser(self):
     with self.assertRaises(MissingProperty):
         User.new(self.g, {"fod": "foo"})
Ejemplo n.º 16
0
 def testAddNewUser(self):
     u = User.new(self.g, properties=self.USER_DATA)
     u.get_followers()