5 # failure to import any of the modules below indicates failed tests
6 # modules used by diaspy
13 #### test suite configuration variables: can be adjusted to your liking
15 __pod__
= testconf
.__pod
__
16 __username__
= testconf
.__username
__
17 __passwd__
= testconf
.__passwd
__
20 class ClientTests(unittest
.TestCase
):
21 def testInitialization(self
):
22 client
= diaspy
.client
.Client(pod
=__pod__
,
23 username
=__username__
,
25 self
.assertEqual(__pod__
, client
.pod
)
26 self
.assertEqual(__username__
, client
._username
)
27 self
.assertEqual(__passwd__
, client
._password
)
28 self
.assertEqual({}, client
._post
_data
)
29 self
.assertEqual(client
._token
_regex
,
30 re
.compile(r
'content="(.*?)"\s+name="csrf-token'))
31 self
.assertEqual(client
._login
_data
['user[username]'], 'testuser')
32 self
.assertEqual(client
._login
_data
['user[password]'], 'testpassword')
33 self
.assertEqual(client
._login
_data
['authenticity_token'],
36 def testGettingUserInfo(self
):
37 client
= diaspy
.client
.Client(__pod__
, __username__
, __passwd__
)
38 info
= client
.get_user_info()
39 self
.assertEqual(dict, type(info
))
41 def testGettingStream(self
):
42 client
= diaspy
.client
.Client(__pod__
, __username__
, __passwd__
)
43 stream
= client
.get_stream()
44 self
.assertEqual(list, type(stream
))
45 if stream
: self
.assertEqual(diaspy
.models
.Post
, type(stream
[0]))
47 def testGettingNotifications(self
):
48 client
= diaspy
.client
.Client(__pod__
, __username__
, __passwd__
)
49 notifications
= client
.get_notifications()
50 self
.assertEqual(list, type(notifications
))
51 if notifications
: self
.assertEqual(dict, type(notifications
[0]))
53 def testGettingTag(self
):
54 client
= diaspy
.client
.Client(pod
=__pod__
, username
=__username__
, password
=__passwd__
)
55 tag
= client
.get_tag('foo')
56 self
.assertEqual(list, type(tag
))
57 if tag
: self
.assertEqual(diaspy
.models
.Post
, type(tag
[0]))
59 def testGettingMailbox(self
):
60 client
= diaspy
.client
.Client(pod
=__pod__
, username
=__username__
, password
=__passwd__
)
61 mailbox
= client
.get_mailbox()
62 self
.assertEqual(list, type(mailbox
))
63 self
.assertEqual(diaspy
.conversations
.Conversation
, type(mailbox
[0]))
65 if __name__
== '__main__': unittest
.main()