Beispiel #1
0
 def follow_user(self, url):
     try:
         self.driver.get(url)
         source = self.driver.page_source
         profile = ParseProfile(source)
         th = profile.twitter_handle
         logging.info("trying to follow %s" % th)
         if (profile.following == False):
             logging.info("following {}".format(th))
             follow_button = self.driver.find_element_by_css_selector('button.follow-text')
             actions = ActionChains(self.driver)
             actions.move_to_element(follow_button)
             actions.wait(1)
             actions.click()
             actions.wait(1)
             actions.perform()
             self.storage.save_user(th)
             sleep(3)
             return True
         else:
             logging.info("already following {}".format(profile.twitter_handle))
             sleep(3)
             return False        
     except WebDriverException as e:
         logging.exception("WebDriverException in follow_user")
         return False
     except AttributeError as e:
         logging.exception("Attribute Error in follow_user")
         return False
Beispiel #2
0
 def unfollow_user(self, url):
     self.driver.get(url)
     source = self.driver.page_source
     profile = ParseProfile(source)
     th = profile.twitter_handle
     logging.info("calling unfollow_user")
     if (profile.follows_back == False):            
         logging.info("unfollowing %s" % th)
         unfollow_button = self.driver.find_element_by_css_selector('button.following-text')
         actions = ActionChains(self.driver)
         actions.move_to_element(unfollow_button).click().perform()
         sleep(10)
     else:
         logging.info ("not unfollowing %s - they follow you back" % th)
Beispiel #3
0
def test_following_count():
    profile = ParseProfile(PROFILE_NOTFOLLOWING_ME)
    assert profile.following_count == 1479
Beispiel #4
0
def test_doesnt_follow_back():
    profile = ParseProfile(PROFILE_NOTFOLLOWING_ME)
    assert profile.follows_back == False
Beispiel #5
0
def test_follows_back():
    profile = ParseProfile(PROFILE_FOLLOWING_ME)
    assert profile.follows_back == True
Beispiel #6
0
def test_following():
    profile = ParseProfile(PROFILE_FOLLOWING_ME)
    assert profile.following == True
Beispiel #7
0
def test_notfollowing_itsme():
    profile = ParseProfile(PROFILE_ME)
    assert profile.following == False
Beispiel #8
0
def test_notfollowing():
    profile = ParseProfile(PROFILE_NOTFOLLOWING_ME)
    assert profile.following == False
Beispiel #9
0
def test_twitter_handle():
    profile = ParseProfile(PROFILE_NOTFOLLOWING_ME)
    assert profile.twitter_handle == '@washingtonpost'
Beispiel #10
0
def test_join_date():
    profile = ParseProfile(PROFILE_NOTFOLLOWING_ME)
    assert profile.join_date == datetime(2007, 3, 27, 7, 19)
Beispiel #11
0
def test_followers_count():
    profile = ParseProfile(PROFILE_NOTFOLLOWING_ME)
    assert profile.follower_count == 12598791