`Connection()` object works, `diaply/client.py` partialy ported
[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
20class ClientTests(unittest.TestCase):
264336e2
MM
21 def testGettingUserInfo(self):
22 client = diaspy.client.Client(__pod__, __username__, __passwd__)
23 info = client.get_user_info()
24 self.assertEqual(dict, type(info))
25
26 def testGettingStream(self):
27 client = diaspy.client.Client(__pod__, __username__, __passwd__)
28 stream = client.get_stream()
29 self.assertEqual(list, type(stream))
30 if stream: self.assertEqual(diaspy.models.Post, type(stream[0]))
31
32 def testGettingNotifications(self):
33 client = diaspy.client.Client(__pod__, __username__, __passwd__)
34 notifications = client.get_notifications()
35 self.assertEqual(list, type(notifications))
36 if notifications: self.assertEqual(dict, type(notifications[0]))
37
fab8b736
MM
38 def testGettingTag(self):
39 client = diaspy.client.Client(pod=__pod__, username=__username__, password=__passwd__)
40 tag = client.get_tag('foo')
41 self.assertEqual(list, type(tag))
42 if tag: self.assertEqual(diaspy.models.Post, type(tag[0]))
43
44 def testGettingMailbox(self):
45 client = diaspy.client.Client(pod=__pod__, username=__username__, password=__passwd__)
46 mailbox = client.get_mailbox()
47 self.assertEqual(list, type(mailbox))
48 self.assertEqual(diaspy.conversations.Conversation, type(mailbox[0]))
49
50if __name__ == '__main__': unittest.main()