forked from and3rson/nineapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeyring_tests.py
31 lines (25 loc) · 1023 Bytes
/
keyring_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from unittest import TestCase
from nineapi.client import Client, APIException
import os
import sys
import keyring
#While using the program the follwing command should be run only once,the system will store the creds.
username=""
password="" #This should be removed after setting the password
keyring.set_password('9gag',username,password)
class APITest(TestCase):
def setUp(self):
self.client = Client()
self.username = username
self.password = keyring.get_password('9gag',username)
def test_log_in_good(self):
response = self.client.log_in(self.username, self.password)
self.assertEqual(response, True)
def test_log_in_bad(self):
self.assertRaises(APIException, lambda: self.client.log_in(self.username, self.password + 'wrong'))
def test_get_posts(self):
self.test_log_in_good()
posts = self.client.get_posts()
self.assertEqual(len(posts), 10)
#Delete keyring since it is for test only
keyring.delete_password('9gag',username)