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__
, username
=__username__
, password
=__passwd__
)
23 self
.assertEqual(__pod__
, client
.pod
)
24 self
.assertEqual(__username__
, client
._username
)
25 self
.assertEqual(__passwd__
, client
._password
)
26 self
.assertEqual({}, client
._post
_data
)
27 self
.assertEqual(client
._token
_regex
, re
.compile(r
'content="(.*?)"\s+name="csrf-token'))
28 self
.assertEqual(client
._login
_data
['user[username]'], __username__
)
29 self
.assertEqual(client
._login
_data
['user[password]'], __passwd__
)
30 self
.assertEqual(client
._login
_data
['authenticity_token'], client
.get_token())
32 def testGettingUserInfo(self
):
33 client
= diaspy
.client
.Client(__pod__
, __username__
, __passwd__
)
34 info
= client
.get_user_info()
35 self
.assertEqual(dict, type(info
))
37 def testGettingStream(self
):
38 client
= diaspy
.client
.Client(__pod__
, __username__
, __passwd__
)
39 stream
= client
.get_stream()
40 self
.assertEqual(list, type(stream
))
41 if stream
: self
.assertEqual(diaspy
.models
.Post
, type(stream
[0]))
43 def testGettingNotifications(self
):
44 client
= diaspy
.client
.Client(__pod__
, __username__
, __passwd__
)
45 notifications
= client
.get_notifications()
46 self
.assertEqual(list, type(notifications
))
47 if notifications
: self
.assertEqual(dict, type(notifications
[0]))
49 def testGettingTag(self
):
50 client
= diaspy
.client
.Client(pod
=__pod__
, username
=__username__
, password
=__passwd__
)
51 tag
= client
.get_tag('foo')
52 self
.assertEqual(list, type(tag
))
53 if tag
: self
.assertEqual(diaspy
.models
.Post
, type(tag
[0]))
55 def testGettingMailbox(self
):
56 client
= diaspy
.client
.Client(pod
=__pod__
, username
=__username__
, password
=__passwd__
)
57 mailbox
= client
.get_mailbox()
58 self
.assertEqual(list, type(mailbox
))
59 self
.assertEqual(diaspy
.conversations
.Conversation
, type(mailbox
[0]))
61 if __name__
== '__main__': unittest
.main()