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)
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"]))
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"])))
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"]))
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"])))
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)
def testAccessTheGraph(self): c = Company.new(self.g, {"name": "IBM"}) self.assertEqual(c.g, self.g)
def testThingDoesExist(self): Company.new(self.g, {"name": "IBM"}) self.assertTrue(Company.exists(self.g, {"name": "IBM"}))
def testThingNotExists(self): self.assertFalse(Company.exists(self.g, {"name": "fooCorp"}))
def test_dev_graph(self): g = get_graph("dev") c = Company.new(g, {"name":"foo"})