diff --git a/api-tests/test.py b/api-tests/test.py index 23c5832..603f8ac 100644 --- a/api-tests/test.py +++ b/api-tests/test.py @@ -2,32 +2,48 @@ import requests as req class CreateItemChecks: - def createAuthor (result): + def createAuthor (this, result): + return 'response' in result + + def invalidType (this, result): return 'response' in result class CreateItemActions: - def createAuthor (): + def createAuthor (this): return req.post( "http://127.0.0.1:8080/api/v/1.0/create-item?response_format=json", json={ - "type" : "author" + "type" : "author", + "name" : "TestAuthor" + } + ).json() + + def invalidType (this): + return req.post( + "http://127.0.0.1:8080/api/v/1.0/create-item?response_format=json", + json={ + "type" : "asdasdsad", + "name" : "TestAuthor" } ).json() createItemActions = CreateItemActions() createItemChecks = CreateItemChecks() -def test (id, action, isDone): +def test (id, action, isDone, nextTest=lambda:None): try: print("""Test {id} runned..""") result = action() if isDone(result): print("""Test {id} success!""") + nextTest() else: print("""Test {id} ERROR""") print(result) except Exception as exc: print(exc) -test(1, createItemActions.createAuthor, createItemChecks.createAuthor) \ No newline at end of file +test_3 = lambda : test(3, createItemActions.createAuthor, createItemChecks.createAuthor) +test_2 = lambda : test(2, createItemActions.createAuthor, createItemChecks.createAuthor) +test_1 = test(1, createItemActions.invalidType, createItemChecks.invalidType, test) \ No newline at end of file diff --git a/server.js b/server.js index c95caa9..4033b70 100644 --- a/server.js +++ b/server.js @@ -64,8 +64,8 @@ app.use((req, res, next) => { ); }); -app.use("/", async (rq, rs, next) => next(), require("./page-view")); -app.use("/api", async (rq, rs, next) => next(), require("./api")); +app.use("/", require("./page-view")); +app.use("/api", require("./api")); // Подключение через HTTPS let server;