Added very basic test

This commit is contained in:
Manuel Cortez 2018-12-20 11:59:35 -06:00
parent bc863a3345
commit 344d2f3dac
3 changed files with 36 additions and 0 deletions

0
src/test/__init__.py Normal file
View File

View File

@ -0,0 +1,27 @@
import unittest
import testconfig
import languageHandler
from sessionmanager import utils
from sessionmanager import renderers
class renderersTestCase(unittest.TestCase):
def setUp(self):
languageHandler.setLanguage("en")
vk = testconfig.get_vk()
self.vk = vk.get_api()
def test_render_person(self):
""" Test the person renderer function."""
user = self.vk.users.get(user_ids=1, fields="first_name, last_name, last_seen")
self.assertIsInstance(user, list)
self.assertEquals(len(user), 1)
user = user[0]
rendered_object = renderers.render_person(user, user["last_seen"])
self.assertIsInstance(rendered_object, list)
self.assertEquals(len(rendered_object), 2)
self.assertIsInstance(rendered_object[0], unicode)
self.assertIsInstance(rendered_object[1], unicode)
if __name__ == "__main__":
unittest.main()

9
src/test/testconfig.py Normal file
View File

@ -0,0 +1,9 @@
import os
from vk_api import VkApi
def get_vk():
login = os.environ['LOGIN']
password = os.environ['PASSWORD']
vk = VkApi(login, password)
vk.auth(token_only=True)
return vk