def test_friends(): for i in range(0,len(sample_username)): username = sample_username[i] main.authenticate(username,sample_data[username]) for friend in sample_friends[username]: main.addFriends(friend) main.viewFriends()
def test_authentication(): pass_test_token = jwt.encode({'username' : 'my_test', 'email' : '*****@*****.**'}, os.getenv('SECRET'), algorithm='HS256') test_pass_user_data = mainapp.authenticate(pass_test_token) assert test_pass_user_data == {'username' : 'my_test', 'email' : '*****@*****.**'} fail_decode_test_token = pass_test_token[1:] test_fail_user_data = mainapp.authenticate(fail_decode_test_token) assert test_fail_user_data == 'Access token is missing or invalid'
def test_with_empty_credentials(self): self.username = "" self.password = "" print(self.username + ", " + self.password) expected = "Some fields are missing. Please try again." actual = main.authenticate(self.username, self.password) self.message = actual
def test_with_invalid_credentials(self): self.username = "******" self.password = "******" print(self.username + ", " + self.password) expected = "The username/password could not be found. Please try again." actual = main.authenticate(self.username, self.password) self.message = actual
def test_with_valid_credentials(self): self.username = "******" self.password = "******" print(self.username + ", " + self.password) expected = "You have successfully logged in!" actual = main.authenticate(self.username, self.password) self.assertEqual(expected, actual) self.message = actual
def main(): authenticate() me = reddit.user.me() new_saved = me.saved(limit=50) new_saved = list(new_saved)[::-1] saved_posts = pd.read_csv("saved_posts.csv") saved_comments = pd.read_csv("saved_comments.csv") for submission in new_saved: if isinstance(submission, models.Submission): if submission.id in saved_posts.id: continue else: row = { 'id': submission.id, 'subreddit': submission.subreddit.display_name, 'title': submission.title, 'permalink': submission.permalink, 'score': submission.score, 'url': submission.url } saved_posts.loc[-1] = row saved_posts.index = saved_posts.index + 1 saved_posts.sort_index(inplace=True) elif isinstance(submission, models.Comment): if submission.id in saved_comments.id: continue else: row = { 'id': submission.id, 'subreddit': submission.subreddit.display_name, 'body': submission.body, 'permalink': submission.permalink, 'score': submission.score, 'parent_permalink': submission.submission.permalink } saved_comments.loc[-1] = row saved_comments.index = saved_comments.index + 1 saved_comments.sort_index(inplace=True) return saved_posts, saved_comments
def authenticate(self): global imageToDecode, sizeOfBlock, eFromSlider, deltaFromSlider, lumFromSlider, returnedFromAuth abc = main.authenticate(imageToDecode, 8, CALC, deltaFromSlider, eFromSlider, lumFromSlider) returnedFromAuth = abc ones = [0,0,0] count = [0,0,0] wat = 0 for block in abc: ones[wat] = 0 count[wat] = 0 for i in block: for j in i: count[wat] += 1 if j == 1: ones[wat] +=1 wat +=1 first = ones[0]/float(count[0]) second = ones[1]/float(count[1]) third = ones[2]/float(count[2]) auth_text = "Checksum: " + str(ones[0]) + "/" + str(count[0]) + "\nWatermarks: \nA: " + str(ones[0]) + "/" + str(count[0]) + " B: " + str(ones[1]) + "/" + str(count[1]) + " C: " + str(ones[2]) + "/" + str(count[2]) auth_label.configure(text=auth_text) decode_button.configure(state=NORMAL)
def test_postcomment(): for i in range(0,len(sample_username)): username = sample_username[i] main.authenticate(username,sample_data[username]) main.postComment(sample_comment[username][0],sample_comment[username][1])
def test_viewPost(): for i in range(0,len(sample_username)): username = sample_username[i] main.authenticate(username,sample_data[username]) main.viewPosts()
def test_posts(): for i in range(0,len(sample_username)): username = sample_username[i] main.authenticate(username,sample_data[username]) for post in sample_posts[username]: main.postNew(body=post)
def test_profile(): for i in range(0,len(sample_username)): username = sample_username[i] main.authenticate(username,sample_data[username]) main.modifyUserProfile(first_name=sample_user_profile[username][0], last_name=sample_user_profile[username][1], age=sample_user_profile[username][2],relation=sample_user_profile[username][3]) main.viewProfile()
def test_authenticate(): token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3QiLCJlbWFpbCI6InRlc3RAZW1haWwuY29tIn0.CrMEbpHlgJaqcbqiSID8R1VrH-Aiov1KbcqV628CN_I' result = mainapp.authenticate(token) assert result['username'] == 'test' assert result['email'] == '*****@*****.**' assert mainapp.authenticate('nope') == 'Access token is missing or invalid'
downloadbutton = driver.find_elements_by_xpath("//*[contains(text(), 'Download original')]")[0] ActionChains(driver).move_to_element(downloadbutton).perform() downloadbutton.click() time.sleep(1) # We pass the metadata down so get_echo_videos can submit the # download itself. get_echo_videos(driver, metadata[i]) # Click the cancel button cancelbutton = driver.find_element_by_css_selector("[class='btn white medium']") cancelbutton.click() except Exception as e: print("Error: ", e) traceback.print_exc() try: driver.find_element_by_css_selector("a[class='btn white medium']").click() # Click the cancel button except: pass return 0 if __name__ == "__main__": Settings.Settings.get_opts() Settings.Echo.get_opts() driver = main.authenticate(Settings.echo["login_link"]) echoscraping(Settings.echo["echo_link"], driver)