First test for diaspy.people.User() object
authorMarek Marecki <triviuss@gmail.com>
Fri, 3 May 2013 19:03:18 +0000 (21:03 +0200)
committerMarek Marecki <triviuss@gmail.com>
Fri, 3 May 2013 19:03:18 +0000 (21:03 +0200)
tests.py

index 92b0f61db74e6677fb6dc931e641f927fcea169b..aee11f3e8312c03febeafb6315e53f59c55644c1 100644 (file)
--- 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__)