class FixtureFixtureLinkManagementTest(TestCase):
    
    def setUp(self):
        self._facebook_fixture = FaceBookFixture(APP_ID, CLIENT_SECRET)
        self._link_user    = self._facebook_fixture.add_user(permissions='read_stream,share_item', user_key="link_user")
        self._friend_user = self._facebook_fixture.add_user(permissions='read_stream, publish_stream', user_key="friend_user")
        self._facebook_fixture.create_friends(self._link_user, self._friend_user)
        self._facebook_link_repository = FaceBookLinkRepository()
        
    def tearDown(self):
        self._facebook_fixture.delete_all_users()
        
    def _create_test_link(self):
        facebook_link = self._facebook_fixture.create_link(self._link_user,
                                           'Article Title',
                                           'http://www.example.com/article.html',
                                           'http://www.example.com/article-thumbnail.jpg',
                                           'Caption for the link',
                                           'Longer description of the link',
                                           'User Message')
        return facebook_link
    
    def test_create_link(self):        
        #SUT
        facebook_link = self._create_test_link()
        
        #Assertions
        user_links = self._facebook_link_repository.find_links(self._link_user)
        self.assertTrue(facebook_link in user_links)
                
    def test_create_comment(self):
        #Fixture
        facebook_link = self._create_test_link()
        
        #SUT
        comment_id = self._facebook_fixture.create_comment(facebook_link, self._friend_user, "My 2 cents")
        
        #Assertions
        updated_link = self._facebook_link_repository.find_link(self._link_user, facebook_link.id)
        
        self.assertTrue(comment_id in [comment.id for comment in updated_link.comments],
                         "Comment %s not found in %s" % (comment_id, [comment.id for comment in updated_link.comments]))
 def setUp(self):
     self._facebook_fixture = FaceBookFixture(APP_ID, CLIENT_SECRET)
     self._link_user    = self._facebook_fixture.add_user(permissions='read_stream,share_item', user_key="link_user")
     self._friend_user = self._facebook_fixture.add_user(permissions='read_stream, publish_stream', user_key="friend_user")
     self._facebook_fixture.create_friends(self._link_user, self._friend_user)
     self._facebook_link_repository = FaceBookLinkRepository()