Increment version to 0.0.2
[diaspy.git] / tests.py
CommitLineData
94c2d637
MM
1#!/usr/bin/env python3
2
3import unittest
4
313c9233 5# failure to import any of the modules below indicates failed tests
94c2d637 6# modules used by diaspy
88ec6cda
MM
7import requests
8import re
94c2d637
MM
9# actual diaspy code
10import diaspy
11
12
13#### test suite configuration variables: can be adjusted to your liking
fab8b736
MM
14import testconf
15__pod__ = testconf.__pod__
16__username__ = testconf.__username__
17__passwd__ = testconf.__passwd__
94c2d637
MM
18
19
385e7ebe
MM
20class ConnectionTest(unittest.TestCase):
21 def testLoginWithoutUsername(self):
22 connection = diaspy.connection.Connection(pod=__pod__)
23 self.assertRaises(diaspy.connection.LoginError, connection.login, password='foo')
24
25 def testLoginWithoutPassword(self):
26 connection = diaspy.connection.Connection(pod=__pod__)
27 self.assertRaises(diaspy.connection.LoginError, connection.login, username='user')
28
94c2d637 29class ClientTests(unittest.TestCase):
264336e2
MM
30 def testGettingUserInfo(self):
31 client = diaspy.client.Client(__pod__, __username__, __passwd__)
32 info = client.get_user_info()
33 self.assertEqual(dict, type(info))
34
35 def testGettingStream(self):
36 client = diaspy.client.Client(__pod__, __username__, __passwd__)
37 stream = client.get_stream()
38 self.assertEqual(list, type(stream))
39 if stream: self.assertEqual(diaspy.models.Post, type(stream[0]))
40
41 def testGettingNotifications(self):
42 client = diaspy.client.Client(__pod__, __username__, __passwd__)
43 notifications = client.get_notifications()
44 self.assertEqual(list, type(notifications))
45 if notifications: self.assertEqual(dict, type(notifications[0]))
46
fab8b736
MM
47 def testGettingTag(self):
48 client = diaspy.client.Client(pod=__pod__, username=__username__, password=__passwd__)
49 tag = client.get_tag('foo')
50 self.assertEqual(list, type(tag))
51 if tag: self.assertEqual(diaspy.models.Post, type(tag[0]))
52
53 def testGettingMailbox(self):
54 client = diaspy.client.Client(pod=__pod__, username=__username__, password=__passwd__)
55 mailbox = client.get_mailbox()
56 self.assertEqual(list, type(mailbox))
57 self.assertEqual(diaspy.conversations.Conversation, type(mailbox[0]))
58
59if __name__ == '__main__': unittest.main()