def test_if_token_file_exists(self):
     """
     Check if token file exists, if it doesn't, returns warning message
     """
     self.assertFalse(retrieve_token_file('test.txt'))
     if not retrieve_token_file():
         self.fail('Token file missing, please provide a token file.')
示例#2
0
 def setUp(self):
     self.scraper = Scraper(retrieve_token_file())
     self.github = '262588213843476'
     self.day_scraped = strftime("%Y-%m-%d_%Hh")
     self.scraper.current_data = {
         'name': 'GitHub',
         'fan_count': 163702,
         'id': '262588213843476',
         'date': '2018-06-19'
     }
     self.scraper.file_name = "262588213843476"
 def test_if_token_is_well_formatted(self):
     """
     Check if token file is well formatted
     """
     FILE_PATH = str(os.getcwd()) + '/scraper/badtoken.ini'
     with open(FILE_PATH, 'w') as testfile:
         testfile.write("[DAFAULT]\ntoken = TestTokenNotValid")
     self.assertEqual(retrieve_token_file('badtoken.ini'),
                      'Token with bad structure')
     try:
         os.remove(str(os.getcwd()) + '/scraper/badtoken.ini')
     except FileNotFoundError:
         pass
示例#4
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.')