]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Update redbot tests to work with current versions of redbot.
authorBen Darnell <ben@bendarnell.com>
Sat, 18 May 2013 23:58:18 +0000 (19:58 -0400)
committerBen Darnell <ben@bendarnell.com>
Sat, 18 May 2013 23:58:18 +0000 (19:58 -0400)
maint/test/redbot/red_test.py
maint/test/redbot/tox.ini

index b6d9e3910857ebb5987939a1ce6b62bdbe876acb..4272b33183cad4615ab9b9d0d26e3af56dc95341 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 import logging
-from redbot.droid import ResourceExpertDroid
+from redbot.resource import HttpResource
 import redbot.speak as rs
 import thor
 import threading
@@ -63,22 +63,22 @@ class TestMixin(object):
                   expected_status=200, allowed_warnings=None,
                   allowed_errors=None):
         url = self.get_url(path)
-        state = self.run_redbot(url, method, body, headers)
-        if not state.res_complete:
-            if isinstance(state.res_error, Exception):
-                logging.warning((state.res_error.desc, vars(state.res_error), url))
-                raise state.res_error
+        red = self.run_redbot(url, method, body, headers)
+        if not red.response.complete:
+            if isinstance(red.response.http_error, Exception):
+                logging.warning((red.response.http_error.desc, vars(red.response.http_error), url))
+                raise red.response.http_error.res_error
             else:
                 raise Exception("unknown error; incomplete response")
 
-        self.assertEqual(int(state.res_status), expected_status)
+        self.assertEqual(int(red.response.status_code), expected_status)
 
         allowed_warnings = (allowed_warnings or []) + self.get_allowed_warnings()
         allowed_errors = (allowed_errors or []) + self.get_allowed_errors()
 
         errors = []
         warnings = []
-        for msg in state.messages:
+        for msg in red.response.notes:
             if msg.level == 'bad':
                 logger = logging.error
                 if not isinstance(msg, tuple(allowed_errors)):
@@ -100,8 +100,8 @@ class TestMixin(object):
                          (len(warnings), len(errors)))
 
     def run_redbot(self, url, method, body, headers):
-        red = ResourceExpertDroid(url, method=method, req_body=body,
-                                  req_hdrs=headers)
+        red = HttpResource(url, method=method, req_body=body,
+                           req_hdrs=headers)
         def work():
             red.run(thor.stop)
             thor.run()
@@ -110,7 +110,7 @@ class TestMixin(object):
         thread.start()
         self.wait()
         thread.join()
-        return red.state
+        return red
 
     def test_hello(self):
         self.check_url('/hello')
index 46ec3a70b37aa48a9a1aecf87aef5d8bc0ac62eb..bf1c2fd2cb4ce3e01250da4c92128919862ab116 100644 (file)
@@ -5,4 +5,6 @@ setupdir=../../..
 [testenv]
 commands = python red_test.py
 deps =
+     # Newer versions of thor have a bug with redbot (5/18/13)
+     thor==0.2.0
      git+https://github.com/mnot/redbot.git