--- /dev/null
+## Configuration file for diapsy's
+## test suite (./tests.py)
+##
+## It is essential that a developer/tester fills
+## the variables because thay are supplied empty
+## by default - after first commit the `testconf.py`
+## was added to .gitignore to avoid posting personal
+## data of developer/tester.
+
+
+# You have to set the varaiables yourself.
+# Their values have to be valid.
+
+# __pod__ = 'https://pod.example.com'
+__pod__ = ''
+__username__ = ''
+__passwd__ = ''
#### test suite configuration variables: can be adjusted to your liking
-# pod used by tests (has to be valid)
-__pod__ = 'http://pod.orkz.net'
-__username__ = 'testuser'
-__passwd__ = 'testpassword'
+import testconf
+__pod__ = testconf.__pod__
+__username__ = testconf.__username__
+__passwd__ = testconf.__passwd__
class ClientTests(unittest.TestCase):
def testInitialization(self):
- """This test checks initialization of Client() instance.
- """
client = diaspy.client.Client(pod=__pod__, username=__username__, password=__passwd__)
self.assertEqual(__pod__, client.pod)
self.assertEqual(__username__, client._username)
self.assertEqual(__passwd__, client._password)
- self.assertEqual(None, client._post_data)
+ self.assertEqual({}, client._post_data)
self.assertEqual(client._token_regex, re.compile(r'content="(.*?)"\s+name="csrf-token'))
- self.assertEqual(client._login_data['user[username]'], 'testuser')
- self.assertEqual(client._login_data['user[password]'], 'testpassword')
+ self.assertEqual(client._login_data['user[username]'], __username__)
+ self.assertEqual(client._login_data['user[password]'], __passwd__)
self.assertEqual(client._login_data['authenticity_token'], client.get_token())
-if __name__ == '__main__':
- __passwd__ = getpass.getpass(prompt='Password used for testing: ')
- if __passwd__ == '': __passwd__ = 'testpassword'
- unittest.main()
+ def testGettingTag(self):
+ client = diaspy.client.Client(pod=__pod__, username=__username__, password=__passwd__)
+ tag = client.get_tag('foo')
+ self.assertEqual(list, type(tag))
+ if tag: self.assertEqual(diaspy.models.Post, type(tag[0]))
+
+ def testGettingMailbox(self):
+ client = diaspy.client.Client(pod=__pod__, username=__username__, password=__passwd__)
+ mailbox = client.get_mailbox()
+ self.assertEqual(list, type(mailbox))
+ self.assertEqual(diaspy.conversations.Conversation, type(mailbox[0]))
+
+if __name__ == '__main__': unittest.main()