diff --git a/Makefile b/Makefile index 3cec53b0d..6378f5451 100644 --- a/Makefile +++ b/Makefile @@ -31,3 +31,11 @@ test-onprem: build -e LABELBOX_TEST_API_KEY_ONPREM=${LABELBOX_TEST_API_KEY_ONPREM} \ -e LABELBOX_TEST_ONPREM_HOSTNAME=${LABELBOX_TEST_ONPREM_HOSTNAME} \ local/labelbox-python:test pytest $(PATH_TO_TEST) + +test-custom: build + docker run -it -v ${PWD}:/usr/src -w /usr/src \ + -e LABELBOX_TEST_ENVIRON="custom" \ + -e DA_GCP_LABELBOX_API_KEY=${DA_GCP_LABELBOX_API_KEY} \ + -e LABELBOX_TEST_API_KEY_CUSTOM=${LABELBOX_TEST_API_KEY_CUSTOM} \ + -e LABELBOX_TEST_GRAPHQL_API_ENDPOINT=${LABELBOX_TEST_GRAPHQL_API_ENDPOINT} \ + local/labelbox-python:test pytest $(PATH_TO_TEST) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 72856ddc7..85e8dd1b6 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -25,6 +25,7 @@ class Environ(Enum): PROD = 'prod' STAGING = 'staging' ONPREM = 'onprem' + CUSTOM = 'custom' @pytest.fixture(scope="session") @@ -52,6 +53,12 @@ def graphql_url(environ: str) -> str: if hostname is None: raise Exception(f"Missing LABELBOX_TEST_ONPREM_INSTANCE") return f"{hostname}/api/_gql" + elif environ == Environ.CUSTOM: + graphql_api_endpoint = os.environ.get( + 'LABELBOX_TEST_GRAPHQL_API_ENDPOINT') + if graphql_api_endpoint is None: + raise Exception(f"Missing LABELBOX_TEST_GRAPHQL_API_ENDPOINT") + return graphql_api_endpoint return 'http://host.docker.internal:8080/graphql' @@ -62,6 +69,8 @@ def testing_api_key(environ: str) -> str: return os.environ["LABELBOX_TEST_API_KEY_STAGING"] elif environ == Environ.ONPREM: return os.environ["LABELBOX_TEST_API_KEY_ONPREM"] + elif environ == Environ.CUSTOM: + return os.environ["LABELBOX_TEST_API_KEY_CUSTOM"] return os.environ["LABELBOX_TEST_API_KEY_LOCAL"] diff --git a/tox.ini b/tox.ini index 46c63ce1d..851fe652b 100644 --- a/tox.ini +++ b/tox.ini @@ -9,5 +9,14 @@ deps = pytest < 7.0.0 pytest-cases pytest-rerunfailures -passenv = LABELBOX_TEST_API_KEY_PROD LABELBOX_TEST_API_KEY_STAGING LABELBOX_TEST_ENVIRON DA_GCP_LABELBOX_API_KEY +passenv = + LABELBOX_TEST_ENVIRON + LABELBOX_TEST_API_KEY_PROD + LABELBOX_TEST_API_KEY_STAGING + LABELBOX_TEST_API_KEY_LOCAL + LABELBOX_TEST_API_KEY_ONPREM + LABELBOX_TEST_API_KEY_CUSTOM + LABELBOX_TEST_GRAPHQL_API_ENDPOINT + DA_GCP_LABELBOX_API_KEY + commands = pytest {posargs}