AMMICO/ammico/test/test_display.py
Petr Andriushchenko 8d8ea52287
changed summmary.py logic (#121)
* changed summmary.py logic

* fixing test_summary

* added macos for testing

* fixed_display_test

* fixed docs and exceptions

* added dropout menu for summary

* added new SummaryDetector to AnalysisExplorer

* bug fixing

* code improving

* fixed test_display

* fixed code smells

* reduce tests for macos

* added some tests and exceptions for summary init

* changed CI, runs pytest independently

* exclude test_analysisExplorer from macos in CI

* moved some tests from test_init_summary to test_advanced_init_summary and mark them as long

---------

Co-authored-by: Inga Ulusoy <inga.ulusoy@uni-heidelberg.de>
2023-06-27 09:19:01 +02:00

108 строки
2.8 KiB
Python

import json
import ammico.display as ammico_display
import pytest
import sys
def test_explore_analysis_faces(get_path):
mydict = {"IMG_2746": {"filename": get_path + "IMG_2746.png"}}
with open(get_path + "example_faces.json", "r") as file:
outs = json.load(file)
mydict["IMG_2746"].pop("filename", None)
for im_key in mydict.keys():
sub_dict = mydict[im_key]
for key in sub_dict.keys():
assert sub_dict[key] == outs[key]
def test_explore_analysis_objects(get_path):
mydict = {"IMG_2809": {"filename": get_path + "IMG_2809.png"}}
with open(get_path + "example_analysis_objects.json", "r") as file:
outs = json.load(file)
mydict["IMG_2809"].pop("filename", None)
for im_key in mydict.keys():
sub_dict = mydict[im_key]
for key in sub_dict.keys():
assert sub_dict[key] == outs[key]
@pytest.mark.skipif(sys.platform == "darwin", reason="segmentation fault on mac")
def test_AnalysisExplorer(get_path):
path_img_1 = get_path + "IMG_2809.png"
path_img_2 = get_path + "IMG_2746.png"
mydict = {
"IMG_2809": {"filename": path_img_1},
"IMG_2746": {"filename": path_img_2},
}
all_options_dict = {
path_img_1: "IMG_2809",
path_img_2: "IMG_2746",
}
analysis_explorer = ammico_display.AnalysisExplorer(mydict)
analysis_explorer.update_picture(path_img_1)
assert analysis_explorer.update_picture(None) is None
analysis_explorer._right_output_analysis(
2,
all_options_dict,
path_img_1,
"ObjectDetector",
True,
50,
50,
"CIE 1976",
"summary_and_questions",
"base",
"How many people are in the picture?",
)
analysis_explorer._right_output_analysis(
2,
all_options_dict,
path_img_1,
"EmotionDetector",
True,
50,
50,
"CIE 1976",
"summary_and_questions",
"base",
"How many people are in the picture?",
)
analysis_explorer._right_output_analysis(
2,
all_options_dict,
path_img_1,
"SummaryDetector",
True,
50,
50,
"CIE 1976",
"summary_and_questions",
"base",
"How many people are in the picture?",
)
analysis_explorer._right_output_analysis(
2,
all_options_dict,
path_img_1,
"ColorDetector",
True,
50,
50,
"CIE 1976",
"summary_and_questions",
"base",
"How many people are in the picture?",
)
with pytest.raises(EnvironmentError):
analysis_explorer.run_server(port=8050)