Ejemplo n.º 1
0
    def test_put(self):
        def op(url, **kw):
            response, content = request_and_verify(self, 200, url, "GET", **kw)
            feed_hash = json.loads(content)
            missing = Hashes.missing_fields(feed_hash,
                                            ("url", "source", "active"))
            if missing:
                self.fail("missing fields: %s" % missing)

        url = self.__feed_url(test_id(self))
        source_name = self.test_id

        feed = self.__feed_hash()
        body = json.dumps(feed)
        headers = api_login_headers()

        try:
            create_put_wrapper(self, url, op, headers=headers, body=body)
        finally:
            # hack to delete source for feed
            request_and_verify(self,
                               204,
                               "%s/%s" % (self.base_sources_url, source_name),
                               "DELETE",
                               headers=headers)
Ejemplo n.º 2
0
 def test_delete(self):
     url = self._test_url()
     create_put_wrapper(self, url, lambda url, **kw: None, headers=self._request_headers(),
         **self._request_keywords())
     
     # verifies that delete works
     request_and_verify(self, 404, url, "GET", headers=self._request_headers(),
         **self._request_keywords())
Ejemplo n.º 3
0
 def source_op(url, **kw):
     feed = self.__feed_hash()
     body = json.dumps(feed)
     feed_url = self.__feed_url(source_name)
     create_put_wrapper(self,
                        feed_url,
                        lambda url, **kw: True,
                        body=body,
                        **kw)
Ejemplo n.º 4
0
 def _test_put_duplicate(self):
     feed = self.__feed_hash()
     request_body = json.dumps(feed)
     
     def op(url, **kw):
         # post content again
         request_and_verify(self, 409, url, "PUT", **kw)
     
     url = self.__feed_url(test_id(self))
     create_put_wrapper(self, url, op, headers=api_login_headers(), body=request_body)
Ejemplo n.º 5
0
 def test_put_existing_source(self):
     source_name = test_id(self)
     source_url = "%s/%s" % (self.base_sources_url, source_name)
     
     def source_op(url, **kw):
         feed = self.__feed_hash()
         body = json.dumps(feed)
         feed_url = self.__feed_url(source_name)
         create_put_wrapper(self, feed_url, lambda url, **kw: True, body=body, **kw)
         
     create_put_wrapper(self, source_url, source_op, headers=api_login_headers())
Ejemplo n.º 6
0
 def test_put(self):
     def op(url, **kw):
         response, content = request_and_verify(self, 200, url, "GET", **kw)
         feed_hash = json.loads(content)
         missing = Hashes.missing_fields(feed_hash, ("name", "count"))
         if missing:
             self.fail("missing fields: %s" % missing)
     
     url = self._test_url()    
     feed = self.__feed_hash()
     body = json.dumps(feed)
     create_put_wrapper(self, url, op, headers=self._request_headers(), body=body,
         **self._request_keywords())
Ejemplo n.º 7
0
    def _test_put_duplicate(self):
        feed = self.__feed_hash()
        request_body = json.dumps(feed)

        def op(url, **kw):
            # post content again
            request_and_verify(self, 409, url, "PUT", **kw)

        url = self.__feed_url(test_id(self))
        create_put_wrapper(self,
                           url,
                           op,
                           headers=api_login_headers(),
                           body=request_body)
Ejemplo n.º 8
0
    def test_delete(self):
        url = self._test_url()
        create_put_wrapper(self,
                           url,
                           lambda url, **kw: None,
                           headers=self._request_headers(),
                           **self._request_keywords())

        # verifies that delete works
        request_and_verify(self,
                           404,
                           url,
                           "GET",
                           headers=self._request_headers(),
                           **self._request_keywords())
Ejemplo n.º 9
0
    def test_put(self):
        def op(url, **kw):
            response, content = request_and_verify(self, 200, url, "GET", **kw)
            feed_hash = json.loads(content)
            missing = Hashes.missing_fields(feed_hash, ("name", "count"))
            if missing:
                self.fail("missing fields: %s" % missing)

        url = self._test_url()
        feed = self.__feed_hash()
        body = json.dumps(feed)
        create_put_wrapper(self,
                           url,
                           op,
                           headers=self._request_headers(),
                           body=body,
                           **self._request_keywords())
Ejemplo n.º 10
0
    def test_put_existing_source(self):
        source_name = test_id(self)
        source_url = "%s/%s" % (self.base_sources_url, source_name)

        def source_op(url, **kw):
            feed = self.__feed_hash()
            body = json.dumps(feed)
            feed_url = self.__feed_url(source_name)
            create_put_wrapper(self,
                               feed_url,
                               lambda url, **kw: True,
                               body=body,
                               **kw)

        create_put_wrapper(self,
                           source_url,
                           source_op,
                           headers=api_login_headers())
Ejemplo n.º 11
0
 def test_put(self):
     def op(url, **kw):
         response, content = request_and_verify(self, 200, url, "GET", **kw)
         feed_hash = json.loads(content)
         missing = Hashes.missing_fields(feed_hash, ("url", "source", "active"))
         if missing:
             self.fail("missing fields: %s" % missing)
     
     url = self.__feed_url(test_id(self))
     source_name = self.test_id
     
     feed = self.__feed_hash()
     body = json.dumps(feed)
     headers = api_login_headers()
     
     try:
         create_put_wrapper(self, url, op, headers=headers, body=body)
     finally:
         # hack to delete source for feed
         request_and_verify(self, 204, "%s/%s" % (self.base_sources_url, source_name), "DELETE", headers=headers)
Ejemplo n.º 12
0
 def source_op(url, **kw):
     feed = self.__feed_hash()
     body = json.dumps(feed)
     feed_url = self.__feed_url(source_name)
     create_put_wrapper(self, feed_url, lambda url, **kw: True, body=body, **kw)