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.

78 lines
3.5 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 create_tag_entries, list_tags, run_tag_test, delete_tag_entries
from tests.relationAPI.relate_art import run_art_presence_relation_test
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 = run_tag_test(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}")
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)")
print(f"(Artist) Topic: \t\tN/A")
print(f"Art Collection: \t\tN/A")
print(f"Art2Art Collection: \tN/A")
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)