You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
4.6 KiB
Python

from tests.createAPI.create_delete_art import run_art_test, list_art, delete_art_entries
from tests.createAPI.create_delete_presence import run_presence_test, list_presences
from tests.createAPI.create_delete_artist import delete_artist_entries, list_artists, run_artist_test
from tests.createAPI.create_delete_tag_category import delete_category_entries, list_tag_categories, \
run_tag_category_test
from tests.createAPI.create_delete_tag import list_tags, run_tag_test, delete_tag_entries
from tests.createAPI.create_delete_topic import list_topics, run_topic_tests, delete_all_topics
from tests.createAPI.create_delete_collection import run_collection_tests
from tests.relationAPI.relate_art import run_art_presence_relation_test
from tests.relationAPI.relate_art_to_collection import run_art2collections_tests
def run_tests(url: str, port: int):
"""
Run unit tests against all API interfaces
:param url:
:param port:
:return:
"""
if len(list_artists(url, port)) > 0:
print("Deleting leftover artists ...")
delete_artist_entries(url, port)
if len(list_art(url, port)) > 0:
print("Deleting leftover art ...")
delete_art_entries(url, port)
if len(list_tag_categories(url, port)) > 0:
print("Deleting leftover tag categories ...")
delete_category_entries(url, port)
if len(list_tags(url, port)) > 0:
print("Deleting leftover tags ...")
delete_tag_entries(url, port)
create_artist_result, delete_artist_result = run_artist_test(url, port)
create_presence_result, delete_presence_result, cascade_delete_presence_result = run_presence_test(url, port)
create_art_result, update_art_result, delete_art_result = run_art_test(url, port)
create_art2presence_result, delete_art2presence_result = run_art_presence_relation_test(url, port)
create_category_result, update_category_result, delete_category_result = run_tag_category_test(url, port)
create_tag_result, update_tag_result, delete_tag_result, delete_tag_category_cascade_result = run_tag_test(url, port)
create_topic_result, update_topic_result, delete_topic_result = run_topic_tests(url, port)
create_collection_result, update_collection_result, delete_collection_result = run_collection_tests(url, port)
create_art2collection_result, update_art2collection_result, delete_art2collection_result = \
run_art2collections_tests(url, port)
print()
print("-------- Test Results ---------")
print("Leftover DB Objects:")
r = list_artists(url, port)
print(f"Artists: {len(r)}, {r}")
r = list_presences(url, port)
print(f"Presences: {len(r)}, {r}")
r = list_art(url, port)
print(f"Art: {len(r)}, {r}")
r = list_tag_categories(url, port)
print(f"Tag Categories: {len(r)}, {r}")
r = list_tags(url, port)
print(f"Tags: {len(r)}, {r}")
r = list_topics(url, port)
print(f"Topics: {len(r)}, {r}")
print()
print("Functions:")
print(f"Artists: \t\t\t\tCreate: {create_artist_result} \tUpdate: {'N/A'} "
f"\tDelete: {delete_artist_result} \t(Direct)")
print(f"Presences: \t\t\t\tCreate: {create_presence_result} \tUpdate: {'N/A'} "
f"\tDelete: {delete_presence_result} \t(Direct), {cascade_delete_presence_result} \t(cascade@artist)")
print(f"Art: \t\t\t\t\tCreate: {create_art_result} \tUpdate: {update_art_result} "
f"\tDelete: {delete_art_result} \t(Direct)")
print(f"Art2Presence: \t\t\tCreate: {create_art2presence_result} \tUpdate: {'N/A'} "
f"\tDelete: {delete_art2presence_result} \t(Direct)")
print(f"Tag Category: \t\t\tCreate: {create_category_result} \tUpdate: {update_category_result} "
f"\tDelete: {delete_category_result} \t(Direct)")
print(f"Tag: \t\t\t\t\tCreate: {create_tag_result} \tUpdate: {update_tag_result} "
f"\tDelete: {delete_tag_result} \t(Direct), {delete_tag_category_cascade_result} \t(cascade@category)")
print(f"(Artist) Topic: \t\tCreate: {create_topic_result} \tUpdate: {update_topic_result} "
f"\tDelete: {delete_topic_result} \t(Direct)")
print(f"Art Collection: \t\tCreate: {create_collection_result} \tUpdate: {update_collection_result} "
f"\tDelete: {delete_collection_result} \t(Direct)")
print(f"Art2Art Collection: \tCreate: {create_art2collection_result} \tUpdate: {update_art2collection_result}"
f"\tDelete: {delete_art2collection_result} \t(Direct)")
print(f"Artist2Topic: \t\t\tN/A")
print(f"Art2Tag: \t\t\t\tN/A")
print(f"Tag Alias: \t\t\t\tN/A")
print(f"Tag Implication: \t\tN/A")
print("-------------------------------")
if __name__ == "__main__":
run_tests("127.0.0.1", 8000)