def test_csv_setup() -> None: t = Twitter() t.graphfile = testpath t.setup_csv() my_file = Path(testpath) assert my_file.is_file()
def test_csv_contents() -> None: t = Twitter() t.graphfile = testpath col = [] with open(t.graphfile, 'r') as csvFile: reader = csv.reader(csvFile, delimiter=',') for row in reader: col.append(str(row)) length = len(col) assert length == 1
def performance(platform: str) -> List[int]: if platform == 'Reddit': reddit = Reddit() follower_count = len(reddit.get_user_followers('')) total_likes = reddit.get_user_likes() elif platform == 'Facebook': facebook = FacebookApi() follower_count = len(facebook.get_user_followers('')) total_likes = facebook.get_user_likes() elif platform == 'Tumblr': tumblr = TumblrApi() follower_count = len(tumblr.get_user_followers('')) total_likes = tumblr.get_user_likes() elif platform == 'Instagram': instagram = Instagram() follower_count = len(instagram.get_user_followers('')) total_likes = instagram.get_user_likes() elif platform == 'Twitter': twitter = Twitter() follower_count = len(twitter.get_user_followers('')) total_likes = twitter.get_user_likes() elif platform == 'Youtube': youtube = Youtube() follower_count = len(youtube.get_user_followers('')) total_likes = youtube.get_user_likes() elif platform == 'Slack': slack = SlackApi() follower_count = len(slack.get_user_followers('')) total_likes = slack.get_user_likes() elif platform == 'Discord': follower_count = 0 total_likes = 0 else: follower_count = 0 total_likes = 0 stats = [follower_count, total_likes] return stats
# Widget helpers from tkinter.scrolledtext import ScrolledText import tkinter.messagebox from tkinter import filedialog from tkinter import StringVar from typing import Iterator from dateutil import parser from postr.twitter_postr import Twitter from postr.schedule.writer import Writer from postr.reddit_postr import Reddit from postr.slack_api import SlackApi from postr.schedule.reader import Reader from postr.instagram_postr import Instagram twitter = Twitter() writer = Writer() reddit = Reddit() slack = SlackApi() reader = Reader() instagram = Instagram() def setup(main_gui: Tk) -> Tk: main_gui.title('Postr') main_gui.geometry('700x400') # a fix for running on OSX - to center the title text vertically if main_gui.tk.call('tk', 'windowingsystem') == 'aqua': # only for OSX s = tkinter.ttk.Style() # Note: the name is specially for the text in the widgets
from postr.reddit_postr import Reddit # from postr import discord_api from postr.twitter_postr import Twitter # from postr.fbchat_api import FacebookChatApi from postr.slack_api import SlackApi # from postr.Tumblr_api import TumblrApi from postr.instagram_postr import Instagram from postr.youtube_postr import Youtube from postr.config import missing_configs_for log = make_logger('task_processor') api_to_instance: Dict[str, Any] = { # 'Discord': Discord_api if missing_configs_for('Discord') == [] else None, 'Reddit': Reddit() if missing_configs_for('Reddit') == [] else None, 'Twitter': Twitter() if missing_configs_for('Twitter') == [] else None, # 'Facebook': FacebookChatApi() if missing_configs_for('Facebook') == [] else None, 'Slack': SlackApi() if missing_configs_for('Slack') == [] else None, # 'Tumblr': TumblrApi() if missing_configs_for('Tumblr') == [] else None, 'Instagram': Instagram() if missing_configs_for('Instagram') == [] else None, 'YouTube': Youtube() if missing_configs_for('YouTube') == [] else None, } # if missing_configs_for('Discord') != []: # api_to_instance['Discord'].main() api_to_function: Dict[str, Any] = { 'Discord': { 'is_async': True, 'supported_actions': { 'post_text': {
def immediate_post(platform: str, post_type: str, text: str, media: str) -> None: # dict = { # 'Comment': 'bahgb comment idiot', # 'MediaPath': 'testpath123', # 'OptionalText': '', # 'Platforms': 'reddit,discord', # 'Action': 'post_text' # } if platform == 'Reddit': reddit = Reddit() if post_type == 'Text': reddit.post_text(text) elif post_type == 'Image': reddit.post_photo(media, text) elif post_type == 'Video': reddit.post_video(media, text) elif post_type == 'Link': reddit.post_link(media, text) elif platform == 'Facebook': facebook = FacebookApi() if post_type == 'Text': facebook.post_text(text) elif post_type == 'Image': facebook.post_photo(media, text) elif post_type == 'Video': facebook.post_video(media, text) elif platform == 'Tumblr': tumblr = TumblrApi() if post_type == 'Text': tumblr.post_text(text) elif post_type == 'Image': tumblr.post_photo(media, text) elif post_type == 'Video': tumblr.post_video(media, text) elif platform == 'Instagram': instagram = Instagram() if post_type == 'Text': instagram.post_text(text) elif post_type == 'Image': instagram.post_photo(media, text) elif post_type == 'Video': instagram.post_video(media, text) elif platform == 'Twitter': twitter = Twitter() if post_type == 'Text': twitter.post_text(text) elif post_type == 'Image': twitter.post_photo(media, text) elif post_type == 'Video': twitter.post_video(media, text) elif platform == 'Youtube': youtube = Youtube() if post_type == 'Text': youtube.post_text(text) elif post_type == 'Image': youtube.post_photo(media, text) elif post_type == 'Video': youtube.post_video(media, text) elif platform == 'Slack': slack = SlackApi() if post_type == 'Text': slack.post_text(text) elif post_type == 'Image': slack.post_photo(media, text) elif post_type == 'Video': slack.post_video(media, text)
def test_polarity() -> None: assert Twitter.polarity('test') == 0 assert Twitter.polarity('positive') > 0
import csv import os from pathlib import Path from postr.twitter_postr import Twitter t = Twitter() t.graphfile = os.path.join('tests/twitter/graphtest2.csv') def test_polarity() -> None: assert Twitter.polarity('test') == 0 assert Twitter.polarity('positive') > 0 def test_sentiment() -> None: # Tests the creation of the blobfile t.blobfile = os.path.join('tests/twitter/blobtest.csv') t.analyzeSentiment() my_file = Path(t.blobfile) assert my_file.is_file() # Tests the numerical sentiment conversion in the blobfile scores = [] with open(t.blobfile, 'r') as csvFile: reader = csv.reader(csvFile, delimiter=',') i = 0