Skip to content

Commit

Permalink
Fix Installation Check to catch uninstalled module errors (#715)
Browse files Browse the repository at this point in the history
* Update ci_nox.py

* update the check_install command to use a virtual env for fidesctl

* fix the API_PREFIX references

* set the API util to reuse the API_PREFIX from the core utils

* fix isort

* update the changelog
  • Loading branch information
ThomasLaPiana authored May 31, 2022
1 parent 9424178 commit d364762
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ The types of changes are:
* Updated the webserver so that it won't fail if the database is inaccessible [#649](https://github.com/ethyca/fides/pull/649)
* Handle complex characters in external tests [#661](https://github.com/ethyca/fides/pull/661)
* Evaluations now properly merge the default taxonomy into the user-defined taxonomy [#684](https://github.com/ethyca/fides/pull/684)
* The CLI can be run without installing the webserver components [#715](https://github.com/ethyca/fides/pull/715)

## [1.6.0](https://github.com/ethyca/fides/compare/1.5.3...1.6.0) - 2022-05-02

Expand Down
8 changes: 3 additions & 5 deletions noxfiles/ci_nox.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,9 @@ def xenon(session: nox.Session) -> None:
@nox.session()
def check_install(session: nox.Session) -> None:
"""Check that fidesctl is installed."""
if session.posargs == ["docker"]:
run_command = (*RUN_STATIC_ANALYSIS, "check_install")
else:
run_command = ("fidesctl", *(WITH_TEST_CONFIG), "--version")
session.run(*run_command, external=True)
session.install(".")
run_command = ("fidesctl", *(WITH_TEST_CONFIG), "--version")
session.run(*run_command)


@nox.session()
Expand Down
4 changes: 3 additions & 1 deletion src/fidesapi/routes/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

from fastapi import APIRouter

API_PREFIX = "/api/v1"
from fidesctl.core.utils import API_PREFIX as _API_PREFIX

API_PREFIX = _API_PREFIX
WEBAPP_DIRECTORY = Path("src/fidesapi/build/static")
WEBAPP_INDEX = WEBAPP_DIRECTORY / "index.html"

Expand Down
3 changes: 1 addition & 2 deletions src/fidesctl/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
)

import fidesctl
from fidesapi.routes.util import API_PREFIX
from fidesctl.core import api as _api
from fidesctl.core.config import FidesctlConfig
from fidesctl.core.config.credentials_settings import (
Expand All @@ -31,7 +30,7 @@
get_config_okta_credentials,
)
from fidesctl.core.config.utils import get_config_from_file, update_config_file
from fidesctl.core.utils import check_response, echo_green, echo_red
from fidesctl.core.utils import API_PREFIX, check_response, echo_green, echo_red


def check_server(cli_version: str, server_url: str, quiet: bool = False) -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/fidesctl/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import requests

from fidesapi.routes.util import API_PREFIX
from fidesctl.core.utils import API_PREFIX


def generate_resource_url(
Expand Down
4 changes: 4 additions & 0 deletions src/fidesctl/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
echo_red = partial(click.secho, fg="red", bold=True)
echo_green = partial(click.secho, fg="green", bold=True)

# This duplicates a constant in `fidesapi/routes/utils.py`
# To avoid import errors
API_PREFIX = "/api/v1"


def check_response(response: requests.Response) -> requests.Response:
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/test_cli_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from requests_mock import Mocker

import fidesctl.cli.utils as utils
from fidesapi.routes.util import API_PREFIX
from fidesctl.core.config import FidesctlConfig
from fidesctl.core.utils import API_PREFIX


@pytest.mark.unit
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from starlette.testclient import TestClient

from fidesapi import main
from fidesapi.routes.util import API_PREFIX
from fidesctl.core import api as _api
from fidesctl.core.config import FidesctlConfig
from fidesctl.core.utils import API_PREFIX


@pytest.fixture()
Expand Down

0 comments on commit d364762

Please sign in to comment.