test: rest samples- lookup both .env file and actual env
This commit is contained in:
Родитель
6070b4d663
Коммит
51885bff2e
|
@ -2,6 +2,7 @@
|
|||
# Licensed under the MIT License.
|
||||
"""Tests for Auto Suggest REST samples."""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import dotenv
|
||||
|
@ -15,9 +16,10 @@ class AutoSuggestRESTSamplesTest(unittest.TestCase):
|
|||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.env = dotenv.dotenv_values()
|
||||
cls.subscription_key = cls.env.get(
|
||||
"BING_SEARCH_V7_AUTO_SUGGEST_SUBSCRIPTION_KEY"
|
||||
cls.dotenv = dotenv.dotenv_values()
|
||||
subscription_key_env_var_name = "BING_SEARCH_V7_AUTO_SUGGEST_SUBSCRIPTION_KEY"
|
||||
cls.subscription_key = cls.dotenv.get(
|
||||
subscription_key_env_var_name, os.environ.get(subscription_key_env_var_name)
|
||||
)
|
||||
|
||||
def test_auto_suggest_subscription_key_not_empty(self):
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# Licensed under the MIT License.
|
||||
"""Tests for Custom Search REST samples."""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import dotenv
|
||||
|
@ -15,11 +16,15 @@ class CustomSearchRESTSamplesTest(unittest.TestCase):
|
|||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.env = dotenv.dotenv_values()
|
||||
cls.subscription_key = cls.env.get(
|
||||
"BING_SEARCH_V7_CUSTOM_SEARCH_SUBSCRIPTION_KEY"
|
||||
cls.dotenv = dotenv.dotenv_values()
|
||||
subscription_key_env_var_name = "BING_SEARCH_V7_CUSTOM_SEARCH_SUBSCRIPTION_KEY"
|
||||
cls.subscription_key = cls.dotenv.get(
|
||||
subscription_key_env_var_name, os.environ.get(subscription_key_env_var_name)
|
||||
)
|
||||
config_id_env_var_name = "BING_CUSTOM_SEARCH_CONFIG"
|
||||
cls.config_id = cls.dotenv.get(
|
||||
config_id_env_var_name, os.environ.get(config_id_env_var_name)
|
||||
)
|
||||
cls.config_id = cls.env.get("BING_CUSTOM_SEARCH_CONFIG")
|
||||
|
||||
def test_custom_search_subscription_key_not_empty(self):
|
||||
"""Test that the subscription key is defined in the environment"""
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# Licensed under the MIT License.
|
||||
"""Tests for Entity Search REST samples."""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import dotenv
|
||||
|
@ -15,9 +16,10 @@ class EntitySearchRESTSamplesTest(unittest.TestCase):
|
|||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.env = dotenv.dotenv_values()
|
||||
cls.subscription_key = cls.env.get(
|
||||
"BING_SEARCH_V7_ENTITY_SEARCH_SUBSCRIPTION_KEY"
|
||||
cls.dotenv = dotenv.dotenv_values()
|
||||
subscription_key_env_var_name = "BING_SEARCH_V7_ENTITY_SEARCH_SUBSCRIPTION_KEY"
|
||||
cls.subscription_key = cls.dotenv.get(
|
||||
subscription_key_env_var_name, os.environ.get(subscription_key_env_var_name)
|
||||
)
|
||||
|
||||
def test_entity_search_subscription_key_not_empty(self):
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# Licensed under the MIT License.
|
||||
"""Tests for Image Search REST samples."""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import dotenv
|
||||
|
@ -15,9 +16,10 @@ class ImageSearchRESTSamplesTest(unittest.TestCase):
|
|||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.env = dotenv.dotenv_values()
|
||||
cls.subscription_key = cls.env.get(
|
||||
"BING_SEARCH_V7_IMAGE_SEARCH_SUBSCRIPTION_KEY"
|
||||
cls.dotenv = dotenv.dotenv_values()
|
||||
subscription_key_env_var_name = "BING_SEARCH_V7_IMAGE_SEARCH_SUBSCRIPTION_KEY"
|
||||
cls.subscription_key = cls.dotenv.get(
|
||||
subscription_key_env_var_name, os.environ.get(subscription_key_env_var_name)
|
||||
)
|
||||
|
||||
def test_image_search_subscription_key_not_empty(self):
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# Licensed under the MIT License.
|
||||
"""Tests for News Search REST samples."""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import dotenv
|
||||
|
@ -15,9 +16,10 @@ class NewsSearchRESTSamplesTest(unittest.TestCase):
|
|||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.env = dotenv.dotenv_values()
|
||||
cls.subscription_key = cls.env.get(
|
||||
"BING_SEARCH_V7_NEWS_SEARCH_SUBSCRIPTION_KEY"
|
||||
cls.dotenv = dotenv.dotenv_values()
|
||||
subscription_key_env_var_name = "BING_SEARCH_V7_NEWS_SEARCH_SUBSCRIPTION_KEY"
|
||||
cls.subscription_key = cls.dotenv.get(
|
||||
subscription_key_env_var_name, os.environ.get(subscription_key_env_var_name)
|
||||
)
|
||||
|
||||
def test_news_search_subscription_key_not_empty(self):
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# Licensed under the MIT License.
|
||||
"""Tests for Spell Check REST samples."""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import dotenv
|
||||
|
@ -15,9 +16,10 @@ class SpellCheckRESTSamplesTest(unittest.TestCase):
|
|||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.env = dotenv.dotenv_values()
|
||||
cls.subscription_key = cls.env.get(
|
||||
"BING_SEARCH_V7_SPELL_CHECK_SUBSCRIPTION_KEY"
|
||||
cls.dotenv = dotenv.dotenv_values()
|
||||
subscription_key_env_var_name = "BING_SEARCH_V7_SPELL_CHECK_SUBSCRIPTION_KEY"
|
||||
cls.subscription_key = cls.dotenv.get(
|
||||
subscription_key_env_var_name, os.environ.get(subscription_key_env_var_name)
|
||||
)
|
||||
|
||||
def test_spell_check_subscription_key_not_empty(self):
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# Licensed under the MIT License.
|
||||
"""Tests for Video Search REST samples."""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import dotenv
|
||||
|
@ -15,9 +16,10 @@ class VideoSearchRESTSamplesTest(unittest.TestCase):
|
|||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.env = dotenv.dotenv_values()
|
||||
cls.subscription_key = cls.env.get(
|
||||
"BING_SEARCH_V7_VIDEO_SEARCH_SUBSCRIPTION_KEY"
|
||||
cls.dotenv = dotenv.dotenv_values()
|
||||
subscription_key_env_var_name = "BING_SEARCH_V7_VIDEO_SEARCH_SUBSCRIPTION_KEY"
|
||||
cls.subscription_key = cls.dotenv.get(
|
||||
subscription_key_env_var_name, os.environ.get(subscription_key_env_var_name)
|
||||
)
|
||||
|
||||
def test_video_search_subscription_key_not_empty(self):
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# Licensed under the MIT License.
|
||||
"""Tests for Visual Search REST samples."""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import dotenv
|
||||
|
@ -15,9 +16,10 @@ class VisualSearchRESTSamplesTest(unittest.TestCase):
|
|||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.env = dotenv.dotenv_values()
|
||||
cls.subscription_key = cls.env.get(
|
||||
"BING_SEARCH_V7_VISUAL_SEARCH_SUBSCRIPTION_KEY"
|
||||
cls.dotenv = dotenv.dotenv_values()
|
||||
subscription_key_env_var_name = "BING_SEARCH_V7_VISUAL_SEARCH_SUBSCRIPTION_KEY"
|
||||
cls.subscription_key = cls.dotenv.get(
|
||||
subscription_key_env_var_name, os.environ.get(subscription_key_env_var_name)
|
||||
)
|
||||
|
||||
def test_visual_search_subscription_key_not_empty(self):
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# Licensed under the MIT License.
|
||||
"""Tests for Web Search REST samples."""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import dotenv
|
||||
|
@ -15,8 +16,11 @@ class WebSearchRESTSamplesTest(unittest.TestCase):
|
|||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.env = dotenv.dotenv_values()
|
||||
cls.subscription_key = cls.env.get("BING_SEARCH_V7_WEB_SEARCH_SUBSCRIPTION_KEY")
|
||||
cls.dotenv = dotenv.dotenv_values()
|
||||
subscription_key_env_var_name = "BING_SEARCH_V7_WEB_SEARCH_SUBSCRIPTION_KEY"
|
||||
cls.subscription_key = cls.dotenv.get(
|
||||
subscription_key_env_var_name, os.environ.get(subscription_key_env_var_name)
|
||||
)
|
||||
|
||||
def test_web_search_subscription_key_not_empty(self):
|
||||
"""Test that the subscription key is defined in the environment"""
|
||||
|
|
Загрузка…
Ссылка в новой задаче