def test_connection_with_login_and_password(self): login = os.environ.get('WYKOP_TAKTYK_BOT_LOGIN') password = os.environ.get('WYKOP_TAKTYK_BOT_PASSWORD') api = WykopAPI(ANDROID_APPKEY) api.authenticate(login=login, password=password) conversations = api.conversations_list() assert isinstance(conversations, list)
def create_wykop_api(): if os.path.isfile(KEYS_FILE_NAME): keys = read_keys_from_file() api = MultiKeyWykopAPI(keys, output='clear') else: key, secret, account_key = read_keys_from_envs() api = WykopAPI(key, secret, account_key=account_key, output='clear') api.authenticate() return api
def setUp(self): try: appkey = os.environ['APPKEY'] except KeyError: self.fail("APPKEY not set") try: secretkey = os.environ['SECRETKEY'] except KeyError: self.fail("SECRETKEY not set") self.api = WykopAPI(appkey, secretkey)
def setUp(self): try: appkey = os.environ['APPKEY'] except KeyError: self.fail("APPKEY not set") try: secretkey = os.environ['SECRETKEY'] except KeyError: self.fail("SECRETKEY not set") self.api = WykopAPI(appkey, secretkey) self.api.login = os.environ['LOGIN'] self.api.accountkey = os.environ['ACCOUNTKEY']
def create_base_client(): key = os.environ.get('WYKOP_TAKTYK_KEY') secret = os.environ.get('WYKOP_TAKTYK_SECRET') account_key = os.environ.get('WYKOP_TAKTYK_ACCOUNTKEY') return WykopAPI(key, secret, output='clear', account_key=account_key)
import datetime import os import re import time import logging from typing import NoReturn, Tuple from wykop import WykopAPI key = os.environ.get('WYKOP_TAKTYK_KEY') secret = os.environ.get('WYKOP_TAKTYK_SECRET') api = WykopAPI(key, secret, output='clear') def remove_tags(text) -> str: return re.sub(r'#(\w*[0-9a-zA-Z]+\w*[0-9a-zA-Z])', '', text) def remove_nicknames(text) -> str: return re.sub(r'@(\w*[0-9a-zA-Z]+\w*[0-9a-zA-Z]:)', '', text) def remove_empty_lines_and_format(text: str) -> str: return '\n'.join( [line.strip() for line in text.split("\n") if line.strip()]) def filter_to_short(text, min_words=5) -> str: return '\n'.join([ line for line in text.split('\n') if len(line.split(' ')) >= min_words
class WykopAPITests(unittest.TestCase): def setUp(self): try: appkey = os.environ['APPKEY'] except KeyError: self.fail("APPKEY not set") try: secretkey = os.environ['SECRETKEY'] except KeyError: self.fail("SECRETKEY not set") self.api = WykopAPI(appkey, secretkey) def test_get_link_success(self): self.api.get_link(1) self.assert_(True) def test_get_link_comments_success(self): self.api.get_link_comments(1) self.assert_(True) def test_get_link_reports_success(self): self.api.get_link_reports(1) self.assert_(True) def test_get_link_digs_success(self): self.api.get_link_digs(1) self.assert_(True) def test_get_link_related_success(self): self.api.get_link_related(1) self.assert_(True) def test_get_link_buryreasons_success(self): self.api.get_link_buryreasons() self.assert_(True) def test_get_links_promoted_success(self): self.api.get_links_promoted() self.assert_(True) def test_get_links_upcoming_success(self): self.api.get_links_upcoming() self.assert_(True) def test_get_popular_promoted_success(self): self.api.get_popular_promoted() self.assert_(True) def test_get_popular_upcoming_success(self): self.api.get_popular_upcoming() self.assert_(True) def test_get_top_success(self): self.api.get_top(date.today().year) self.assert_(True) def test_get_top_date_success(self): self.api.get_top_date(date.today().year, date.today().month) self.assert_(True) def test_get_entry_success(self): self.api.get_entry(1) self.assert_(True) def test_get_rank_success(self): self.api.get_rank() self.assert_(True) def test_get_observatory_votes_success(self): self.api.get_observatory_votes() self.assert_(True) def test_get_observatory_comments_success(self): self.api.get_observatory_comments() self.assert_(True) def test_get_observatory_entries_success(self): self.api.get_observatory_entries() self.assert_(True) def test_get_observatory_entries_comments_success(self): self.api.get_observatory_entries_comments() self.assert_(True)
def entry_is_removed(api: WykopAPI, entry_id): api.entry_delete(entry_id)
def get_key(self): self.wykop = WykopAPI(appkey=self.keys[self.key_index][0], secretkey=self.keys[self.key_index][1])
class WykopAPITests(unittest.TestCase): def setUp(self): try: appkey = os.environ['APPKEY'] except KeyError: self.fail("APPKEY not set") try: secretkey = os.environ['SECRETKEY'] except KeyError: self.fail("SECRETKEY not set") self.api = WykopAPI(appkey, secretkey) self.api.login = os.environ['LOGIN'] self.api.accountkey = os.environ['ACCOUNTKEY'] def test_get_link_success(self): self.api.get_link(1) self.assert_(True) def test_get_link_comments_success(self): self.api.get_link_comments(1) self.assert_(True) def test_get_link_reports_success(self): self.api.get_link_reports(1) self.assert_(True) def test_get_link_digs_success(self): self.api.get_link_digs(1) self.assert_(True) def test_get_link_related_success(self): self.api.get_link_related(1) self.assert_(True) def test_get_link_buryreasons_success(self): self.api.get_link_buryreasons() self.assert_(True) def test_get_links_promoted_success(self): self.api.get_links_promoted() self.assert_(True) def test_get_links_upcoming_success(self): self.api.get_links_upcoming() self.assert_(True) def test_get_popular_promoted_success(self): self.api.get_popular_promoted() self.assert_(True) def test_get_popular_upcoming_success(self): self.api.get_popular_upcoming() self.assert_(True) def test_get_top_success(self): self.api.get_top(date.today().year) self.assert_(True) def test_get_top_date_success(self): self.api.get_top_date(date.today().year, date.today().month) self.assert_(True) def test_get_entry_success(self): self.api.get_entry(1) self.assert_(True) def test_get_rank_success(self): self.api.get_rank() self.assert_(True) def test_get_observatory_votes_success(self): self.api.get_observatory_votes() self.assert_(True) def test_get_observatory_comments_success(self): self.api.get_observatory_comments() self.assert_(True) def test_get_observatory_entries_success(self): self.api.get_observatory_entries() self.assert_(True) def test_get_observatory_entries_comments_success(self): self.api.get_observatory_entries_comments() self.assert_(True) def test_add_entry_success(self): f = open('doge.png', 'rb') self.api.add_entry(body='#wykopsdk #wykopsdktest', embed=f) f.close() self.assert_(True)