Main #5
@ -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)
|
||||
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)
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user