[docs]deftest_get_contextual_image_path_base(self,caplog):caplog.set_level(logging.INFO)# Setupset_config(self.CUSTOM_CONFIG_PATH)# Executeresult:str|None=get_contextual_image_path("painting","TEST")# Verifyassertresult==abspath(self.TEST_IMAGE_PATH)assert"TEST in data source painting"incaplog.text
[docs]deftest_get_contextual_image_path_invalid_config(self,caplog):caplog.set_level(logging.INFO)# Setupset_config("invalid_config")# Executeresult:str|None=get_contextual_image_path("painting","TEST")# VerifyassertresultisNoneassert"Config file is empty"incaplog.text
[docs]deftest_get_contextual_image_path_contextual(self,caplog):caplog.set_level(logging.INFO)# Setupset_config(self.CUSTOM_CONFIG_PATH)# Executeresult:str|None=get_contextual_image_path("painting","TEST2")# Verifyassertresult==abspath(self.TEST_IMAGE_PATH)assert"TEST2 in data source painting"incaplog.text
[docs]deftest_get_contextual_image_path_nonexistent(self,caplog):caplog.set_level(logging.INFO)# Setupset_config(self.CUSTOM_CONFIG_PATH)# Executeresult:str|None=get_contextual_image_path("painting","FAKE")# VerifyassertresultisNoneassert"FAKE in data source painting"incaplog.textassert"Could not find contextual image"incaplog.text
[docs]deftest_get_contextual_image_recipe_path_contextual(self,caplog):caplog.set_level(logging.INFO)# Executeresult:str|None=get_contextual_image_recipe_path("painting","TEST2")# Verifyassertresult==abspath(self.TEST_RECIPE_PATH)assert"TEST2 in data source painting"incaplog.text
[docs]deftest_get_contextual_image_recipe_path_nonexistent(self,caplog):caplog.set_level(logging.INFO)# Executeresult:str|None=get_contextual_image_recipe_path("painting","FAKE")# VerifyassertresultisNoneassert"FAKE in data source painting"incaplog.textassert"Could not find contextual image"incaplog.text
[docs]deftest_get_contextual_image_image(self):# Setupcorrect=PIL.Image.open(self.TEST_IMAGE_PATH)set_config(self.CUSTOM_CONFIG_PATH)# Executeresult:Image|None=get_contextual_image(self.TEST_IMAGE_PATH)# Verify# Compare the images.assertresultassertnp.sum(np.array(ImageChops.difference(correct,result).getdata()))==0
[docs]deftest_get_contextual_image_image_invalid(self,caplog):caplog.set_level(logging.INFO)# Executeresult:Image|None=get_contextual_image(self.INVALID_IMAGE_PATH)# VerifyassertresultisNoneassert"PIL could not open"incaplog.text