6 # failure to import any of the modules below indicates failed tests
7 # modules used by diaspy
13 #### test suite configuration variables: can be adjusted to your liking
14 # pod used by tests (has to be valid)
15 __pod__
= 'http://pod.orkz.net'
16 __username__
= 'testuser'
17 __passwd__
= 'testpassword'
20 class ClientTests(unittest
.TestCase
):
21 def testInitialization(self
):
22 """This test checks initialization of Client() instance.
24 client
= diaspy
.client
.Client(pod
=__pod__
, username
=__username__
, password
=__passwd__
)
25 self
.assertEqual(__pod__
, client
.pod
)
26 self
.assertEqual(__username__
, client
._username
)
27 self
.assertEqual(__passwd__
, client
._password
)
28 self
.assertEqual(None, client
._post
_data
)
29 self
.assertEqual(client
._token
_regex
, re
.compile(r
'content="(.*?)"\s+name="csrf-token'))
30 self
.assertEqual(client
._login
_data
['user[username]'], 'testuser')
31 self
.assertEqual(client
._login
_data
['user[password]'], 'testpassword')
32 self
.assertEqual(client
._login
_data
['authenticity_token'], client
.get_token())
34 def testPreparationOfPostData(self
):
35 """This test checks correctness of data set for posting.
40 if __name__
== '__main__':
41 __passwd__
= getpass
.getpass(prompt
='Password used for testing: ')
42 if __passwd__
== '': __passwd__
= 'testpassword'