From f3eaa601b025e5885ae0e64f8dd19dbf384b9c97 Mon Sep 17 00:00:00 2001 From: Marek Marecki Date: Fri, 3 May 2013 21:03:18 +0200 Subject: [PATCH] First test for diaspy.people.User() object --- tests.py | 83 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 35 deletions(-) diff --git a/tests.py b/tests.py index 92b0f61..aee11f3 100644 --- a/tests.py +++ b/tests.py @@ -39,41 +39,6 @@ print('[ CONNECTED ]\n') #### Test suite code -class StreamTest(unittest.TestCase): - def testGetting(self): - stream = diaspy.streams.Generic(test_connection) - - def testGettingLength(self): - stream = diaspy.streams.Generic(test_connection) - len(stream) - - def testClearing(self): - stream = diaspy.streams.Stream(test_connection) - stream.clear() - self.assertEqual(0, len(stream)) - - def testPurging(self): - stream = diaspy.streams.Stream(test_connection) - post = stream.post('#diaspy test') - stream.update() - post.delete() - stream.purge() - self.assertNotIn(post.post_id, [p.post_id for p in stream]) - - def testPostingText(self): - stream = diaspy.streams.Stream(test_connection) - post = stream.post('#diaspy test no. {0}'.format(test_count)) - self.assertEqual(diaspy.models.Post, type(post)) - - def testPostingImage(self): - stream = diaspy.streams.Stream(test_connection) - stream.post_picture('./test-image.png') - - def testingAddingTag(self): - ft = diaspy.streams.FollowedTags(test_connection) - ft.add('test') - - class ConnectionTest(unittest.TestCase): def testLoginWithoutUsername(self): connection = diaspy.connection.Connection(pod=__pod__) @@ -119,6 +84,54 @@ class ClientTests(unittest.TestCase): self.assertEqual(diaspy.conversations.Conversation, type(mailbox[0])) +class StreamTest(unittest.TestCase): + def testGetting(self): + stream = diaspy.streams.Generic(test_connection) + + def testGettingLength(self): + stream = diaspy.streams.Generic(test_connection) + len(stream) + + def testClearing(self): + stream = diaspy.streams.Stream(test_connection) + stream.clear() + self.assertEqual(0, len(stream)) + + def testPurging(self): + stream = diaspy.streams.Stream(test_connection) + post = stream.post('#diaspy test') + stream.update() + post.delete() + stream.purge() + self.assertNotIn(post.post_id, [p.post_id for p in stream]) + + def testPostingText(self): + stream = diaspy.streams.Stream(test_connection) + post = stream.post('#diaspy test no. {0}'.format(test_count)) + self.assertEqual(diaspy.models.Post, type(post)) + + def testPostingImage(self): + stream = diaspy.streams.Stream(test_connection) + stream.post_picture('./test-image.png') + + def testingAddingTag(self): + ft = diaspy.streams.FollowedTags(test_connection) + ft.add('test') + + +class UserTests(unittest.TestCase): + def testHandleSeparatorRaisingExceptions(self): + user = diaspy.people.User(test_connection) + handles = ['user.pod.example.com', + 'user@podexamplecom', + '@pod.example.com', + 'use r@pod.example.com', + 'user0@pod300 example.com', + ] + for h in handles: + self.assertRaises(Exception, user._sephandle, handle) + + if __name__ == '__main__': unittest.main() c = diaspy.connection.Connection(__pod__, __username__, __passwd__) -- 2.25.1