def test_get_credentials_from_storage(self): credentials = Credentials(invalid=False) self._storage.get = MagicMock(return_value=credentials) run_flow = MagicMock() auth = Authenticator(self._storage, run_flow) assert auth.get_credentials({}) == credentials run_flow.assert_not_called()
def test_get_credentials_invalid(self): credentials = Credentials(invalid=True) self._storage.get = MagicMock(return_value=credentials) run_flow = MagicMock() auth = Authenticator(self._storage, run_flow) args = {} assert auth.get_credentials({}).authorize run_flow.assert_called_once_with(args)
def test_get_credentials_unknown(self): self._storage.get = MagicMock(return_value=None) credentials = Credentials(invalid=False) run_flow = MagicMock(return_value=credentials) auth = Authenticator(self._storage, run_flow) args = {} assert auth.get_credentials(args).authorize run_flow.assert_called_once_with(args)
def test_get_service(self): credentials = Credentials(invalid=False) self._storage.get = MagicMock(return_value=credentials) run_flow = MagicMock() auth = Authenticator(self._storage, run_flow) assert auth.get_service(credentials).playlists
config_path = environ['FB_YT_PLANNER_CONFIG_FILE'] with open(config_path) as file: config = load(file) storage = Storage(config['storage_file']) scope = 'https://www.googleapis.com/auth/youtube' flow = flow_from_clientsecrets(config['secrets_file'], scope, message="Something went wrong!") def partial_run_flow(args): return run_flow(flow, storage, args) auth = Authenticator(storage, partial_run_flow) now = datetime.now() argparser.add_argument('--title', help='playlist title', default='{0}-{1}-{2}'.format(now.year, now.month, now.day)) argparser.add_argument('--workouts', help="Workout video ids", default=[]) args = argparser.parse_args() video_ids = args.workouts if isinstance(video_ids, str): video_ids = video_ids.split(',') print(video_ids)