make sure we use a non-existing user - bug 625001 - r=telliott
authorTarek Ziade <tarek@ziade.org>
Thu, 13 Jan 2011 15:03:47 +0100
changeset 468 883f221161bc
parent 467 bfc5f2ae3c08
child 469 14b63f198416
push id63
push usertziade@mozilla.com
push dateThu, 13 Jan 2011 14:04:40 +0000
reviewerstelliott
bugs625001
make sure we use a non-existing user - bug 625001 - r=telliott
tests/functional/server_tests.py
--- a/tests/functional/server_tests.py
+++ b/tests/functional/server_tests.py
@@ -59,29 +59,34 @@ class TestAccountManagement(unittest.Tes
                                  ', '.join(failures))
 
     def _randuser(self):
         return 'weaveunittest_' + randid(size=10, chars=string.lowercase)
 
     def testPasswordReset(self):
         root_url = '%s/user/1.0/' % test_config.SERVER_BASE
 
+        user_id = self._randuser()
+        while not weave.checkNameAvailable(test_config.SERVER_BASE, user_id,
+                                           withHost=test_config.HOST_NAME):
+           user_id = self._randuser()
+
         # unknown user
-        req = urllib2.Request("%s/xxx/password_reset" % root_url)
+        req = urllib2.Request("%s/%s/password_reset" % (root_url, user_id))
         try:
             f = opener.open(req)
             f.read()
         except urllib2.HTTPError, e:
             self.assertEqual(e.read(), '3')
         else:
             raise AssertionError()
 
-        # right user, no captcha
-        userID = self._create_user()
-        req = urllib2.Request("%s/%s/password_reset" % (root_url, userID))
+        # existing user, no captcha
+        user_id = self._create_user()
+        req = urllib2.Request("%s/%s/password_reset" % (root_url, user_id))
         try:
             f = opener.open(req)
             result = f.read()
         except urllib2.HTTPError, e:
             self.assertEqual(e.read(), '12')
         else:
             # seems that the server is not enabled for captcha
             self.assertEqual(result, 'success')