Example #1
0
 def testGetHandlesForCompany0(self):
     company = Node("Company", name="IBM")
     handle0 = Node("Handle", name="@ibm")
     handle1 = Node("Handle", name="@ibm_support")
     rel0 = Relationship(company, "TWEETS_AS", handle0)
     rel1 = Relationship(company, "TWEETS_AS", handle1)
     self.g.create(rel0)
     self.g.create(rel1)
     C = Company(company)
     handles = list(C.get_handles())
     self.assertIsInstance(handles[0], Handle)
     self.assertIsInstance(handles[1], Handle)
Example #2
0
 def testGetHandlesForCompany0(self):
     company = Node("Company", name="IBM")
     handle0 = Node("Handle", name="@ibm")
     handle1 = Node("Handle", name="@ibm_support")
     rel0 = Relationship(company, "TWEETS_AS", handle0)
     rel1 = Relationship(company, "TWEETS_AS", handle1)
     self.g.create(rel0)
     self.g.create(rel1)
     C = Company(company)
     handles = list(C.get_handles())
     self.assertIsInstance(handles[0], Handle)
     self.assertIsInstance(handles[1], Handle)
Example #3
0
 def testGetCompanyFollowerTweets(self):
     c = Company.new(self.g, {"name": "MyCompany"})
     h = c.add_handles([{"name": "my_company"}])[0]
     mu = h.add_user({"id": "CH"})
     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 c.get_follower_tweets())
     self.assertEqual(result, set(["tw0", "tw1", "tw2", "tw3"]))
Example #4
0
    def testGetCompanyTweets(self):
        c = Company.new(self.g, {"name": "MyCompany"})
        h = c.add_handles([{"name": "my_company"}])[0]
        u = h.add_user({"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 c.get_tweets())
        self.assertEqual(result, set((["tw0", "tw1", "tw2", "tw3"])))
Example #5
0
 def testGetCompanyFollowerTweets(self):
     c = Company.new(self.g, {"name": "MyCompany"})
     h = c.add_handles([{"name": "my_company"}])[0]
     mu = h.add_user({"id": "CH"})
     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 c.get_follower_tweets())
     self.assertEqual(result, set(["tw0", "tw1", "tw2", "tw3"]))
Example #6
0
    def testGetCompanyTweets(self):
        c = Company.new(self.g, {"name": "MyCompany"})
        h = c.add_handles([{"name": "my_company"}])[0]
        u = h.add_user({"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 c.get_tweets())
        self.assertEqual(result, set((["tw0", "tw1", "tw2", "tw3"])))
Example #7
0
 def testGetCompanyForUser(self):
     c = Company.new(self.g, {"name": "FooCorp"})
     h = c.add_handles([{'name': 'foo_corp'}])[0]
     u = h.add_user({'screen_name': 'foo_corp', 'id': 1234})
     self.assertEqual(u.get_company(), c)
Example #8
0
 def testAccessTheGraph(self):
     c = Company.new(self.g, {"name": "IBM"})
     self.assertEqual(c.g, self.g)
Example #9
0
 def testThingDoesExist(self):
     Company.new(self.g, {"name": "IBM"})
     self.assertTrue(Company.exists(self.g, {"name": "IBM"}))
Example #10
0
 def testThingNotExists(self):
     self.assertFalse(Company.exists(self.g, {"name": "fooCorp"}))
Example #11
0
 def testGetCompanyForUser(self):
     c = Company.new(self.g, {"name": "FooCorp"})
     h = c.add_handles([{'name': 'foo_corp'}])[0]
     u = h.add_user({'screen_name': 'foo_corp', 'id': 1234})
     self.assertEqual(u.get_company(), c)
Example #12
0
 def testAccessTheGraph(self):
     c = Company.new(self.g, {"name": "IBM"})
     self.assertEqual(c.g, self.g)
Example #13
0
 def testThingDoesExist(self):
     Company.new(self.g, {"name": "IBM"})
     self.assertTrue(Company.exists(self.g, {"name": "IBM"}))
Example #14
0
 def testThingNotExists(self):
     self.assertFalse(Company.exists(self.g, {"name": "fooCorp"}))
Example #15
0
 def test_dev_graph(self):
     g = get_graph("dev")
     c = Company.new(g, {"name":"foo"})