示例#1
0
 def test_update_one_by_id(self):
     user = User(first_name="Joe",
                 last_name="Doe",
                 username="******",
                 email="*****@*****.**",
                 password="******")
     user.save()
     namespace_entity = Namespace_Entity()
     endpoint_entity = Endpoint_Entity()
     request_entity = Request_Entity()
     namespace = namespace_entity.insert_one({
         "name": "kevin",
         "is_public": True,
         "user_id": user.pk
     })
     endpoint = endpoint_entity.insert_one({
         "route": "/",
         "method": Endpoint_Entity.GET,
         "target": Endpoint_Entity.DEBUG,
         "route_rules": "{}",
         "headers_rules": "{}",
         "body_rules": "{}",
         "namespace_id": namespace.id
     })
     self.assertTrue(namespace)
     self.assertTrue(namespace.id > 0)
     endpoint_entity = Endpoint_Entity()
     self.assertTrue(
         endpoint_entity.insert_one({
             "route": "/",
             "method": Endpoint_Entity.GET,
             "target": Endpoint_Entity.DEBUG,
             "route_rules": "{}",
             "headers_rules": "{}",
             "body_rules": "{}",
             "namespace_id": namespace.id
         }))
     request = request_entity.insert_one({
         "uri": "/",
         "method": Request_Entity.GET,
         "headers": "{}",
         "body": "{}",
         "status": Request_Entity.DEBUG,
         "endpoint_id": endpoint.id
     })
     self.assertTrue(request)
     self.assertTrue(request.id > 0)
     self.assertTrue(
         request_entity.update_one_by_id(request.id, {"uri": "/new"}))
     request = request_entity.get_one_by_id(request.id)
     self.assertEqual("get/newdebug",
                      request.method + request.uri + request.status)
示例#2
0
 def test_get_one_by_id(self):
     user = User(
         first_name = "Joe",
         last_name = "Doe",
         username = "******",
         email = "*****@*****.**",
         password = "******"
     )
     user.save()
     namespace_entity = Namespace_Entity()
     namespace = namespace_entity.insert_one({
         "name": "kevin",
         "is_public": True,
         "user_id": user.pk
     })
     self.assertTrue(namespace)
     self.assertTrue(namespace.id > 0)
     endpoint_entity = Endpoint_Entity();
     entity = endpoint_entity.insert_one({
         "route": "/",
         "method": Endpoint_Entity.GET,
         "target": Endpoint_Entity.DEBUG,
         "route_rules": "{}",
         "headers_rules": "{}",
         "body_rules": "{}",
         "namespace_id": namespace.id
     })
     entity = endpoint_entity.get_one_by_id(entity.id)
     self.assertEqual("get/debug", entity.method + entity.route + entity.target)
示例#3
0
 def test_insert_many(self):
     user = User(first_name="Joe",
                 last_name="Doe",
                 username="******",
                 email="*****@*****.**",
                 password="******")
     user.save()
     namespace_entity = Namespace_Entity()
     endpoint_entity = Endpoint_Entity()
     request_entity = Request_Entity()
     namespace = namespace_entity.insert_one({
         "name": "kevin",
         "is_public": True,
         "user_id": user.pk
     })
     endpoint = endpoint_entity.insert_one({
         "route": "/",
         "method": Endpoint_Entity.GET,
         "target": Endpoint_Entity.DEBUG,
         "route_rules": "{}",
         "headers_rules": "{}",
         "body_rules": "{}",
         "namespace_id": namespace.id
     })
     self.assertTrue(namespace)
     self.assertTrue(namespace.id > 0)
     endpoint_entity = Endpoint_Entity()
     self.assertTrue(
         endpoint_entity.insert_one({
             "route": "/",
             "method": Endpoint_Entity.GET,
             "target": Endpoint_Entity.DEBUG,
             "route_rules": "{}",
             "headers_rules": "{}",
             "body_rules": "{}",
             "namespace_id": namespace.id
         }))
     request = request_entity.insert_many([{
         "uri": "/",
         "method": Request_Entity.GET,
         "headers": "{}",
         "body": "{}",
         "status": Request_Entity.DEBUG,
         "endpoint_id": endpoint.id
     }, {
         "uri": "/",
         "method": Request_Entity.POST,
         "headers": "{}",
         "body": "{}",
         "status": Request_Entity.DEBUG,
         "endpoint_id": endpoint.id
     }, {
         "uri": "/{id}",
         "method": Request_Entity.GET,
         "headers": "{}",
         "body": "{}",
         "status": Request_Entity.DEBUG,
         "endpoint_id": endpoint.id
     }, {
         "uri": "/{id}",
         "method": Request_Entity.PUT,
         "headers": "{}",
         "body": "{}",
         "status": Request_Entity.DEBUG,
         "endpoint_id": endpoint.id
     }])
     self.assertTrue(request)