Ejemplo n.º 1
0
    def test_intercepting_url(self):
        httpretty.register_uri(httpretty.GET,
                               "http://www.omdbapi.com/",
                               body='{"Title": "Demo movie", "Date": "2014"}',
                               content_type="application/json")

        apiRest = ApiRest()
        mongo_client = mongomock.MongoClient()
        cache = MongoDBMoviesCache(mongo_client)

        capturer = JsonCapturer()

        restCache = RestCache(apiRest, cache)
        restCache.show = capturer.capture
        restCache.search_movie("aliens")

        self.assertEqual(capturer.doc['Title'], "Demo movie")