Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIP-49 - separate Integration vs unit tests in test script #98

Merged
merged 8 commits into from
Jun 11, 2024

Conversation

briehl
Copy link
Collaborator

@briehl briehl commented Jun 11, 2024

The test/run_tests.sh script now knows the difference between integration and unit tests.

If run just plain as sh test/run_tests.sh, it just runs the unit tests.
If run as sh test/run_tests.sh integration in includes integration tests.
It also includes integration tests if the SDK_CALLBACK_URL environment variable is present, which primarily gets set during a kb-sdk test run. So those should always run the whole suite... which is the point, there.

This also moves the remaining test files to the integration directory. They're unchanged, except for relative imports in two cases, and the file names were changed.

@briehl
Copy link
Collaborator Author

briehl commented Jun 11, 2024

Sigh, GitHub didn't update the PR target after merging the previous PR. So the appinfo changes are back again! The actual unreviewed changes are in the latest 3 commits.

@@ -13,7 +13,8 @@
from lib.installed_clients.FakeObjectsForTestsClient import FakeObjectsForTests
from lib.installed_clients.WorkspaceClient import Workspace

@pytest.fixture(scope="session")

@pytest.fixture(scope="module")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scope this to the module, in case any tests make changes to the config (like the sharemanager tests...)

@@ -2,11 +2,26 @@
current_dir=$(dirname "$(readlink -f "$0")")
script_dir=$(dirname "$(readlink -f "$0")")
export KB_DEPLOYMENT_CONFIG="$current_dir"/deploy.cfg
export KB_AUTH_TOKEN=`cat /kb/module/work/token`
if [ -f /kb/module/work/token ]; then
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was failing in local unit tests, so I put in a test for that file and a little log message about using it.

@@ -46,23 +47,26 @@ def test_invalid_share_level(config: dict[str, str]):
@mock.patch("NarrativeService.sharing.sharemanager.feeds")
@mock.patch("NarrativeService.sharing.sharemanager.ws.get_ws_admins", return_value=FAKE_ADMINS)
def test_make_notification_ok(mock_ws, mock_post, config: dict[str, str]): # noqa: ARG001
config["service-token"] = "fake-service-token"
config["ws-admin-token"] = "fake-admin-token"
for key in REQUIRED_TOKEN_KEYS:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure the keys are set as expected for each test. These modify the config dictionary, which persists throughout the module.

@briehl briehl merged commit 80542d5 into main Jun 11, 2024
1 of 2 checks passed
@briehl briehl deleted the integration-vs-unit branch June 11, 2024 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants