Beispiel #1
0
 def setUp(self):
     self.scraper = Scraper(retrieve_token_file())
     self.github = '262588213843476'
     self.day_scraped = strftime("%Y-%m-%d_%Hh")
     if not self.scraper.check_valid_token():
         if retrieve_password_file():
             try:
                 collect_token_automatically(*get_user_password_decrypted())
             except Exception as inst:
                 print(inst)
                 self.fail('Token has expired, please renew it.')
         else:
             self.fail('There is no token.')
 def test_collect_token_automatically_with_correct_id(self):
     if retrieve_password_file():
         user, password = get_user_password_decrypted()
         self.assertEqual(type(collect_token_automatically(user, password)),
                          type(Scraper('')))
     else:
         self.fail('No user/password informed. Use autotoken.')
 def test_collect_token_automatically_without_internet(self):
     url = 'https://www.google.com/'
     if requests.get(url).status_code != 200:
         self.assertEqual(
             collect_token_automatically('user', 'hugepassword',
                                         'default.ini'),
             'Não foi possível abrir o Facebook. Você está online?')
     else:
         pass
 def test_collect_token_automatically_with_wrong_id(self):
     self.assertEqual(
         collect_token_automatically('user',
                                     'hugepasswordwithnumbers123',
                                     file='default.ini'),
         'Wrong Facebook user or password')
     try:
         os.remove(str(os.getcwd()) + '/scraper/default.ini')
     except FileNotFoundError:
         pass