add: more tests
This commit is contained in:
parent
6728ef9264
commit
4dd8329484
5 changed files with 166 additions and 42 deletions
|
@ -43,21 +43,8 @@ add_custom_target(run
|
||||||
DEPENDS core
|
DEPENDS core
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||||
)
|
)
|
||||||
add_custom_target(debug
|
|
||||||
COMMAND valgrind -s ./core start
|
|
||||||
DEPENDS core
|
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
|
||||||
)
|
|
||||||
add_custom_target(debug-leak
|
|
||||||
COMMAND valgrind --leak-check=full --show-leak-kinds=all ./core start
|
|
||||||
DEPENDS core
|
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
|
||||||
)
|
|
||||||
add_custom_target(debug-callgrind
|
|
||||||
COMMAND valgrind --tool=callgrind ./core start
|
|
||||||
DEPENDS core
|
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
|
||||||
)
|
|
||||||
add_custom_target(docs
|
add_custom_target(docs
|
||||||
COMMAND doxygen
|
COMMAND doxygen
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
@ -73,8 +60,27 @@ add_custom_target(test-callgrind
|
||||||
DEPENDS core
|
DEPENDS core
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
|
||||||
)
|
)
|
||||||
|
|
||||||
|
IF(CMAKE_BUILD_TYPE MATCHES DEBUG)
|
||||||
|
message("debug mode")
|
||||||
|
add_custom_target(debug
|
||||||
|
COMMAND valgrind -s ./core start
|
||||||
|
DEPENDS core
|
||||||
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||||
|
)
|
||||||
|
add_custom_target(debug-leak
|
||||||
|
COMMAND valgrind --leak-check=full --show-leak-kinds=all ./core start
|
||||||
|
DEPENDS core
|
||||||
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||||
|
)
|
||||||
|
add_custom_target(debug-callgrind
|
||||||
|
COMMAND valgrind --tool=callgrind ./core start
|
||||||
|
DEPENDS core
|
||||||
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||||
|
)
|
||||||
add_custom_target(coverage
|
add_custom_target(coverage
|
||||||
COMMAND gcovr -s --root ${CMAKE_SOURCE_DIR} -e ${CMAKE_SOURCE_DIR}/vendor --html-details ${CMAKE_BINARY_DIR}/coverage.html --html-title "Emgauwa Core Coverage" ${CMAKE_BINARY_DIR}/CMakeFiles/core.dir
|
COMMAND gcovr -s --root ${CMAKE_SOURCE_DIR} -e ${CMAKE_SOURCE_DIR}/vendor --html-details ${CMAKE_BINARY_DIR}/coverage.html --html-title "Emgauwa Core Coverage" ${CMAKE_BINARY_DIR}/CMakeFiles/core.dir
|
||||||
DEPENDS test
|
DEPENDS test
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
|
ENDIF(CMAKE_BUILD_TYPE MATCHES DEBUG)
|
||||||
|
|
16
tests/tavern_tests/0.1.test_basics.tavern.yaml
Normal file
16
tests/tavern_tests/0.1.test_basics.tavern.yaml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
test_name: "[test_basics] Test basic calls"
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- name: "[test_basics] get index"
|
||||||
|
request:
|
||||||
|
url: "http://localhost:5000/"
|
||||||
|
method: GET
|
||||||
|
response:
|
||||||
|
status_code: 200
|
||||||
|
|
||||||
|
- name: "[test_basics] get 404"
|
||||||
|
request:
|
||||||
|
url: "http://localhost:5000/invalid_url_for_testing_do_not_use"
|
||||||
|
method: GET
|
||||||
|
response:
|
||||||
|
status_code: 404
|
|
@ -26,7 +26,7 @@ stages:
|
||||||
extra_kwargs:
|
extra_kwargs:
|
||||||
relay_count: !int "{returned_relay_count:d}"
|
relay_count: !int "{returned_relay_count:d}"
|
||||||
|
|
||||||
- name: "[controller_relays_basic] get controller relays, check length"
|
- name: "[controller_relays_basic] get controller relay"
|
||||||
request:
|
request:
|
||||||
method: GET
|
method: GET
|
||||||
url: "http://localhost:5000/api/v1/controllers/{returned_id}/relays/5"
|
url: "http://localhost:5000/api/v1/controllers/{returned_id}/relays/5"
|
||||||
|
@ -40,3 +40,69 @@ stages:
|
||||||
function: validate_relay:check_number
|
function: validate_relay:check_number
|
||||||
extra_kwargs:
|
extra_kwargs:
|
||||||
number: 5
|
number: 5
|
||||||
|
|
||||||
|
- name: "[controller_relays_basic] get controller relay with invalid uid"
|
||||||
|
request:
|
||||||
|
method: GET
|
||||||
|
url: "http://localhost:5000/api/v1/controllers/INVALID-UUID/relays/5"
|
||||||
|
response:
|
||||||
|
status_code: 400
|
||||||
|
|
||||||
|
- name: "[controller_relays_basic] get controller relay with unavailable uid"
|
||||||
|
request:
|
||||||
|
method: GET
|
||||||
|
url: "http://localhost:5000/api/v1/controllers/00000000-0000-0000-0000-000000000000/relays/5"
|
||||||
|
response:
|
||||||
|
status_code: 404
|
||||||
|
|
||||||
|
- name: "[controller_relays_basic] get controller relay with invalid number"
|
||||||
|
request:
|
||||||
|
method: GET
|
||||||
|
url: "http://localhost:5000/api/v1/controllers/{returned_id}/relays/not_a_number"
|
||||||
|
response:
|
||||||
|
status_code: 404
|
||||||
|
|
||||||
|
- name: "[controller_relays_basic] get controller relay with unavailable number"
|
||||||
|
request:
|
||||||
|
method: GET
|
||||||
|
url: "http://localhost:5000/api/v1/controllers/{returned_id}/relays/9001"
|
||||||
|
response:
|
||||||
|
status_code: 404
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
- name: "[controller_relays_basic] pulse relay"
|
||||||
|
request:
|
||||||
|
method: POST
|
||||||
|
url: "http://localhost:5000/api/v1/controllers/{returned_id}/relays/6/pulse"
|
||||||
|
response:
|
||||||
|
status_code: 200
|
||||||
|
|
||||||
|
- name: "[controller_relays_basic] pulse relay with invalid uid"
|
||||||
|
request:
|
||||||
|
method: POST
|
||||||
|
url: "http://localhost:5000/api/v1/controllers/INVALID-UUID/relays/6/pulse"
|
||||||
|
response:
|
||||||
|
status_code: 400
|
||||||
|
|
||||||
|
- name: "[controller_relays_basic] pulse relay with unavailable uid"
|
||||||
|
request:
|
||||||
|
method: POST
|
||||||
|
url: "http://localhost:5000/api/v1/controllers/00000000-0000-0000-0000-000000000000/relays/6/pulse"
|
||||||
|
response:
|
||||||
|
status_code: 404
|
||||||
|
|
||||||
|
- name: "[controller_relays_basic] pulse relay with invalid number"
|
||||||
|
request:
|
||||||
|
method: POST
|
||||||
|
url: "http://localhost:5000/api/v1/controllers/{returned_id}/relays/not_a_number/pulse"
|
||||||
|
response:
|
||||||
|
status_code: 404
|
||||||
|
|
||||||
|
- name: "[controller_relays_basic] pulse relay with unavailable number"
|
||||||
|
request:
|
||||||
|
method: POST
|
||||||
|
url: "http://localhost:5000/api/v1/controllers/{returned_id}/relays/9001/pulse"
|
||||||
|
response:
|
||||||
|
status_code: 404
|
||||||
|
|
|
@ -98,6 +98,13 @@ stages:
|
||||||
controller_id: "{returned_id}"
|
controller_id: "{returned_id}"
|
||||||
tag: "{returned_tag}"
|
tag: "{returned_tag}"
|
||||||
|
|
||||||
|
- name: "[tags] get returned tag with relays and schedules"
|
||||||
|
request:
|
||||||
|
method: GET
|
||||||
|
url: "http://localhost:5000/api/v1/tags/{returned_tag}"
|
||||||
|
response:
|
||||||
|
status_code: 200
|
||||||
|
|
||||||
- name: "[tags] get tags"
|
- name: "[tags] get tags"
|
||||||
request:
|
request:
|
||||||
method: GET
|
method: GET
|
||||||
|
@ -106,3 +113,47 @@ stages:
|
||||||
status_code: 200
|
status_code: 200
|
||||||
verify_response_with:
|
verify_response_with:
|
||||||
function: validate_tag:multiple
|
function: validate_tag:multiple
|
||||||
|
|
||||||
|
- name: "[tags] get unavailable tag"
|
||||||
|
request:
|
||||||
|
method: GET
|
||||||
|
url: "http://localhost:5000/api/v1/tags/invalid_unavailable_tag"
|
||||||
|
response:
|
||||||
|
status_code: 404
|
||||||
|
|
||||||
|
- name: "[tags] post tag"
|
||||||
|
request:
|
||||||
|
method: POST
|
||||||
|
url: "http://localhost:5000/api/v1/tags/"
|
||||||
|
json:
|
||||||
|
tag: "unused_tag_1"
|
||||||
|
response:
|
||||||
|
status_code: 201
|
||||||
|
|
||||||
|
- name: "[tags] get posted tag"
|
||||||
|
request:
|
||||||
|
method: GET
|
||||||
|
url: "http://localhost:5000/api/v1/tags/unused_tag_1"
|
||||||
|
response:
|
||||||
|
status_code: 200
|
||||||
|
|
||||||
|
- name: "[tags] delete posted tag"
|
||||||
|
request:
|
||||||
|
method: DELETE
|
||||||
|
url: "http://localhost:5000/api/v1/tags/unused_tag_1"
|
||||||
|
response:
|
||||||
|
status_code: 200
|
||||||
|
|
||||||
|
- name: "[tags] get deleted tag"
|
||||||
|
request:
|
||||||
|
method: GET
|
||||||
|
url: "http://localhost:5000/api/v1/tags/unused_tag_1"
|
||||||
|
response:
|
||||||
|
status_code: 404
|
||||||
|
|
||||||
|
- name: "[tags] delete deleted tag again"
|
||||||
|
request:
|
||||||
|
method: DELETE
|
||||||
|
url: "http://localhost:5000/api/v1/tags/unused_tag_1"
|
||||||
|
response:
|
||||||
|
status_code: 404
|
||||||
|
|
|
@ -11,24 +11,9 @@ def multiple(response):
|
||||||
for tag in response.json():
|
for tag in response.json():
|
||||||
_verify_single(tag)
|
_verify_single(tag)
|
||||||
|
|
||||||
#def find(response, name=None, number=None, controller_id=None, tag=None):
|
def find(response, tag):
|
||||||
# print(response.json())
|
print(response.json())
|
||||||
# for tag in response.json():
|
for response_tag in response.json():
|
||||||
# if number != None and number != tag.get("number"):
|
if response_tag == tag:
|
||||||
# continue
|
return
|
||||||
#
|
assert False, "tag not found in list"
|
||||||
# if name != None and name != tag.get("name"):
|
|
||||||
# continue
|
|
||||||
#
|
|
||||||
# if controller_id != None and controller_id != tag.get("controller_id"):
|
|
||||||
# continue
|
|
||||||
#
|
|
||||||
# if tag != None:
|
|
||||||
# found_in_response = False
|
|
||||||
# for response_tag in tag.get("tags"):
|
|
||||||
# if response_tag == tag:
|
|
||||||
# found_in_response = True
|
|
||||||
# if not found_in_response:
|
|
||||||
# continue
|
|
||||||
# return
|
|
||||||
# assert False, "tag not found in list"
|
|
||||||
|
|
Loading…
Reference in a new issue