Beispiel #1
0
    def test_create_retrieve_user(self):
        """Create, retrieve, delete, attempt to retrieve again"""
        req = Request.blank(
            "/users", method="POST", POST=json.dumps({"messaging_driver": "fake", "messaging_address": "foo"})
        )
        resp = application(req)
        self.assertEquals(resp.status_int, 200)

        service_id = json.loads(resp.body)["id"]

        req = Request.blank("/users/%s" % service_id)
        resp = application(req)
        self.assertEquals(resp.status_int, 200)

        print resp.body, type(resp.body)
        user = json.loads(resp.body)
        self.assertEquals(user["messaging_driver"], "fake")
        self.assertEquals(user["messaging_address"], "foo")

        req = Request.blank("/users/%s" % service_id, method="DELETE")
        resp = application(req)
        self.assertEquals(resp.status_int, 200)

        req = Request.blank("/users/%s" % service_id)
        resp = application(req)
        self.assertEquals(resp.status_int, 404)
Beispiel #2
0
    def test_send_notification(self):
        req = Request.blank("/users", method="POST", POST=json.dumps({}))
        resp = application(req)
        self.assertEquals(resp.status_int, 200)

        user_id = json.loads(resp.body)["id"]
        req = Request.blank(
            "/users/%s/notifications" % user_id,
            method="POST",
            POST=json.dumps({"timestamp": 13217362355575, "metrics": {"duration": 85000, "response_size": 12435}}),
        )
        resp = application(req)
        self.assertEquals(resp.status_int, 200)
Beispiel #3
0
    def test_create_retrieve_metric(self):
        req = Request.blank("/services", method="POST", POST='{"name": "this_or_the_other"}')
        resp = application(req)
        self.assertEquals(resp.status_int, 200)

        service_id = json.loads(resp.body)["id"]
        req = Request.blank(
            "/services/%s/metrics" % service_id,
            method="POST",
            POST=json.dumps({"timestamp": 13217362355575, "metrics": {"duration": 85000, "response_size": 12435}}),
        )
        resp = application(req)
        self.assertEquals(resp.status_int, 200)

        req = Request.blank("/services/%s/metrics" % service_id)
        resp = application(req)
Beispiel #4
0
    def test_create_retrieve_service(self):
        """Create, retrieve, delete, attempt to retrieve again"""
        req = Request.blank("/services", method="POST", POST=json.dumps({"name": "this_or_the_other"}))
        resp = application(req)
        self.assertEquals(resp.status_int, 200)

        service_id = json.loads(resp.body)["id"]

        req = Request.blank("/services/%s" % service_id)
        resp = application(req)
        self.assertEquals(resp.status_int, 200)

        req = Request.blank("/services/%s" % service_id, method="DELETE")
        resp = application(req)
        self.assertEquals(resp.status_int, 200)

        req = Request.blank("/services/%s" % service_id)
        resp = application(req)
        self.assertEquals(resp.status_int, 404)
Beispiel #5
0
 def test_invalid_url(self):
     req = Request.blank("/stuff")
     resp = application(req)
     self.assertEquals(resp.status_int, 404)