people.User._fetchguid() will now raise an exception when GUID is empty
authorMarek Marecki <marekjm@taistelu.com>
Tue, 20 Aug 2013 12:03:29 +0000 (14:03 +0200)
committerMarek Marecki <marekjm@taistelu.com>
Tue, 20 Aug 2013 12:03:29 +0000 (14:03 +0200)
.gitignore
diaspy/people.py
tests.py

index dd5cdc121163ef6c197be9ff997eb611fd6af80c..12d09bc775ab3b67725653a669defa428c6f9ad4 100644 (file)
@@ -7,8 +7,10 @@ __pycache__/*
 
 check-*.py
 
+# Testing
 testconf.py
 TEST_COUNT
+sketch.py
 
 *.py[cod]
 
index 1ea8eca7895d61f874e978f66b7c3126c77a7d5e..c86067da1dd2b183b8e12f49c4c7a3c22a0e57bb 100644 (file)
@@ -105,8 +105,11 @@ class User():
     def fetchguid(self):
         """Fetch user data and posts using guid.
         """
-        request = self._connection.get('people/{0}.json'.format(self.guid))
-        self._postproc(request)
+        if self.guid:
+            request = self._connection.get('people/{0}.json'.format(self.guid))
+            self._postproc(request)
+        else:
+            raise errors.UserError('GUID not set')
 
     def fetchprofile(self):
         """Fetches user data.
index 57fac8684e270a5e563ffa09dc1d482d5046cdca..5e0adfa06c444d0972846c03d18167d849ad45a7 100644 (file)
--- a/tests.py
+++ b/tests.py
@@ -10,6 +10,7 @@ import requests
 import warnings
 #   actual diaspy code
 import diaspy
+from diaspy import client as dclient
 
 
 ####    SETUP STUFF
@@ -60,25 +61,14 @@ class ConnectionTest(unittest.TestCase):
 
 
 class ClientTests(unittest.TestCase):
-    def testGettingStream(self):
-        client = diaspy.client.Client(test_connection)
-        stream = client.get_stream()
-        if len(stream): self.assertEqual(diaspy.models.Post, type(stream[0]))
-
-    def testGettingNotifications(self):
-        client = diaspy.client.Client(test_connection)
-        notifications = client.get_notifications()
-        self.assertEqual(diaspy.notifications.Notifications, type(notifications))
-        if notifications: self.assertEqual(diaspy.models.Notification, type(notifications[0]))
-
     def testGettingTag(self):
-        client = diaspy.client.Client(test_connection)
+        client = dclient.Client(test_connection)
         tag = client.get_tag('foo')
         self.assertEqual(diaspy.streams.Generic, type(tag))
         if tag: self.assertEqual(diaspy.models.Post, type(tag[0]))
 
     def testGettingMailbox(self):
-        client = diaspy.client.Client(test_connection)
+        client = dclient.Client(test_connection)
         mailbox = client.get_mailbox()
         self.assertEqual(list, type(mailbox))
         self.assertEqual(diaspy.conversations.Conversation, type(mailbox[0]))