I wrote recently about improving the way I usually create a stub web server for testing my applications that call out to external web services. This is a particularly common occurrence where I work (Point2) because we have separated out our core services which are interacted with through REST apis. As I’ve mentioned before, this was what started the Django REST models open source project.
Well, I’ve written the code to effectively support the previously described testing api. It is currently part of the above project, and can be found here. It has already proved handy in adding a much needed functional test capability for Django REST models, which has already exposed a bug in the awkward to test rest_client code. As an example, here is the test:-
-
class FunctionalTest(unittest.TestCase):
-
def setUp(self):
-
self.server = StubServer(8998)
-
self.server.run()
-
-
def tearDown(self):
-
self.server.stop()
-
self.server.verify()
-
-
def test_get_with_file_call(self):
-
self.server.expect(method="GET", url="/address/\w+$").and_return(mime_type="text/xml", content="<address><number>12</number><street>Early Drive</street><city>Calgary</city></address>")
-
address = Address.objects.get(city="Calgary")
-
self.assertEquals("Early Drive", address.street)
-
With the expanding usage of REST services, and a growing number of Python applications written against those services, this project is starting to gather pace again.

Hi,
Amazing! Not clear for me, how offen you updating your http://www.pyruby.com.
[url=http://www.purimblog.net/]Edwas[/url]