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

Remove Identity Tests for Default Testing #131

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/issue_template/release-tracking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: New Release
about: Tracking a new, published release
title: 'New Release: <version>'
labels: ''
assignees: 'jeremytwfortune'

---

## Description

_Include a brief description of the release, including any new features, bug fixes, or breaking changes._

## Checklist

- [ ] Ensure E2E tests pass by manually running the testing workflow with `e2e` against the `main` branch.
- [ ] Compile relevant changes and make it part of the description above.
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ jobs:
test:
name: Test
uses: ./.github/workflows/test.yml
with:
suite: e2e
secrets:
ORCHESTRATE_API_KEY: ${{ secrets.ORCHESTRATE_API_KEY }}
ORCHESTRATE_IDENTITY_API_KEY: ${{ secrets.ORCHESTRATE_IDENTITY_API_KEY }}
Expand Down
32 changes: 28 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,20 @@ on:
branches:
- main
pull_request:
workflow_dispatch:
inputs:
suite:
required: true
description: "The test suite name: e2e, default"
default: "default"
type: string
workflow_call:
inputs:
suite:
required: true
description: "The test suite name: e2e, default"
default: "default"
type: string
secrets:
ORCHESTRATE_API_KEY:
required: true
Expand All @@ -22,7 +35,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: true
max-parallel: 1
max-parallel: ${{ inputs.suite == 'e2e' && 1 || 4 }}
matrix:
node-version: ["18", "20"]
steps:
Expand All @@ -46,10 +59,21 @@ jobs:
run: npm ci
- name: Run Local Hashing
run: docker run -d -p 7002:7002 -e HASH__KEY=${{ secrets.TESTING_HASH_KEY }} --cap-drop ALL careevolution/bmpi-hashing-service:latest
- name: Run tests
- name: Run Default Tests
if: ${{ inputs.suite }}
working-directory: typescript
shell: pwsh
run: npm run test
- name: Default Tests
if: ${{ inputs.suite == 'default' }}
working-directory: typescript
shell: pwsh
run: npm run test
- name: E2E Tests
if: ${{ inputs.suite == 'e2e' }}
working-directory: typescript
shell: pwsh
run: npm run test:e2e

python:
name: Python
Expand All @@ -58,7 +82,7 @@ jobs:
- typescript
strategy:
fail-fast: true
max-parallel: 1
max-parallel: ${{ inputs.suite == 'e2e' && 1 || 4 }}
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
Expand Down Expand Up @@ -100,4 +124,4 @@ jobs:
run: docker run -d -p 7002:7002 -e HASH__KEY=${{ secrets.TESTING_HASH_KEY }} --cap-drop ALL careevolution/bmpi-hashing-service:latest
- name: Test
working-directory: python
run: poetry run pytest
run: poetry run pytest -m "${{ inputs.suite }}"
2 changes: 2 additions & 0 deletions python/tests/identity/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
HashDemographicResponse,
)

pytestmark = pytest.mark.e2e

load_dotenv(override=True)

_TEST_API = IdentityApi()
Expand Down
3 changes: 3 additions & 0 deletions python/tests/identity/test_demographic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
demographic_from_dict,
Demographic,
)
import pytest

pytestmark = pytest.mark.e2e


def test_demographic_to_dict_should_camel_case():
Expand Down
5 changes: 5 additions & 0 deletions python/tests/identity/test_local_hashing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
from orchestrate._internal.identity.local_hashing import LocalHashingApi
from dotenv import load_dotenv

import pytest

pytestmark = pytest.mark.e2e


load_dotenv(Path(__file__).parent.parent.parent.parent / ".env", override=True)
_TEST_API = LocalHashingApi()

Expand Down
9 changes: 3 additions & 6 deletions python/tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
from io import BytesIO
import json
import os
from pathlib import Path
from zipfile import ZipFile

import pytest
from dotenv import load_dotenv
from orchestrate import OrchestrateApi
from requests import HTTPError

from orchestrate._internal.exceptions import (
OrchestrateClientError,
OrchestrateHttpError,
)
from orchestrate._internal.exceptions import OrchestrateHttpError
from .data import (
CDA,
DSTU2_BUNDLE,
Expand All @@ -30,6 +25,8 @@
StandardizeRequest,
)

pytestmark = [pytest.mark.e2e, pytest.mark.default]


def setup_test_api():
load_dotenv(Path(__file__).parent.parent.parent / ".env", override=True)
Expand Down
2 changes: 2 additions & 0 deletions python/tests/test_http_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from orchestrate._internal.http_handler import HttpHandler, create_http_handler
from dotenv import dotenv_values

pytestmark = [pytest.mark.e2e, pytest.mark.default]


def test_api_base_url_in_environment_should_use_environment(monkeypatch):
mock_http_handler = Mock(HttpHandler)
Expand Down
3 changes: 2 additions & 1 deletion typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"test": "vitest run",
"test:watch": "vitest",
"fmt": "prettier --check .",
"fmt:fix": "prettier --write ."
"fmt:fix": "prettier --write .",
"test:e2e": "vitest -c vitest.config.e2e.js"
},
"author": "CareEvolution",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion typescript/tests/httpHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class OutcomeTestCase {
id: string;
}

describe("httpHandler outcomes", () => {
describe.concurrent("httpHandler outcomes", () => {
const testCases: OutcomeTestCase[] = [
{
contentType: "application/json",
Expand Down
40 changes: 12 additions & 28 deletions typescript/tests/identity/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ async function createRandomRecord(): Promise<{ person: Person; identifier: strin
return { person, identifier };
}

describe("Identity API addOrUpdateRecord", () => {
it("should add a new record", async () => {
describe("Identity API", () => {
it("addOrUpdateRecord should add a new record", async () => {
const addResponse = await identityApi.addOrUpdateRecord({
source: defaultSource,
identifier: Math.random().toString(36).substring(7),
Expand All @@ -82,7 +82,7 @@ describe("Identity API addOrUpdateRecord", () => {
expect(addResponse.matchedPerson.id).toBeDefined();
});

it("with url unsafe identifier should add record", async () => {
it("addOrUpdateRecord with url unsafe identifier should add record", async () => {
const addResponse = await identityApi.addOrUpdateRecord({
source: defaultSource,
identifier: Math.random().toString(36).substring(7) + "+/=",
Expand All @@ -92,10 +92,8 @@ describe("Identity API addOrUpdateRecord", () => {
expect(addResponse.matchedPerson).toBeDefined();
expect(addResponse.matchedPerson.id).toBeDefined();
});
});

describe("Identity API addOrUpdateBlindedRecord", () => {
it("should add a new record", async () => {
it("addOrUpdateBlindedRecord should add a new record", async () => {
const addResponse = await identityApi.addOrUpdateBlindedRecord({
source: defaultSource,
identifier: Math.random().toString(36).substring(7),
Expand All @@ -106,7 +104,7 @@ describe("Identity API addOrUpdateBlindedRecord", () => {
expect(addResponse.matchedPerson.id).toBeDefined();
});

it("with url unsafe identifier should add record", async () => {
it("addOrUpdateBlindedRecord with url unsafe identifier should add record", async () => {
const addResponse = await identityApi.addOrUpdateBlindedRecord({
source: defaultSource,
identifier: Math.random().toString(36).substring(7),
Expand All @@ -116,10 +114,8 @@ describe("Identity API addOrUpdateBlindedRecord", () => {
expect(addResponse.matchedPerson).toBeDefined();
expect(addResponse.matchedPerson.id).toBeDefined();
});
});

describe("Identity API getPersonByRecord", () => {
it("should get a person by record", async () => {
it("getPersonByRecord should get a person by record", async () => {
const { person, identifier } = await createRandomRecord();

const getResponse = await identityApi.getPersonByRecord({
Expand All @@ -129,10 +125,8 @@ describe("Identity API getPersonByRecord", () => {

expect(getResponse).toEqual(person);
});
});

describe("Identity API getPersonByID", () => {
it("should get a person by ID", async () => {
it("getPersonByID should get a person by ID", async () => {
const { person } = await createRandomRecord();

const getResponse = await identityApi.getPersonByID({
Expand All @@ -141,26 +135,20 @@ describe("Identity API getPersonByID", () => {

expect(getResponse.id).toEqual(person.id);
});
});

describe("Identity API matchDemographics", () => {
it("should match demographics", async () => {
it("matchDemographics should match demographics", async () => {
const matchResponse = await identityApi.matchDemographics(demographic);

expect(matchResponse).toBeDefined();
});
});

describe("Identity API matchBlindedDemographics", () => {
it("should match blinded demographics", async () => {
it("matchBlindedDemographics should match blinded demographics", async () => {
const matchResponse = await identityApi.matchBlindedDemographics(blindedDemographic);

expect(matchResponse).toBeDefined();
});
});

describe("Identity API deleteRecord", () => {
it("should delete a record", async () => {
it("deleteRecord should delete a record", async () => {
const { person, identifier } = await createRandomRecord();

const deleteResponse = await identityApi.deleteRecord({
Expand All @@ -170,10 +158,8 @@ describe("Identity API deleteRecord", () => {

expect(deleteResponse.changedPersons.map(changedPerson => changedPerson.id)).toContain(person.id);
});
});

describe("Identity API addMatchGuidance", () => {
it("should add match guidance", async () => {
it("addMatchGuidance should add match guidance", async () => {
const { person: firstPerson, identifier: firstIdentifier } = await createRandomRecord();
const { person: secondPerson, identifier: secondIdentifier } = await createRandomRecord();

Expand All @@ -187,10 +173,8 @@ describe("Identity API addMatchGuidance", () => {
expect(addMatchGuidanceResponse.changedPersons.map(changedPerson => changedPerson.id)).toContain(firstPerson.id);
expect(addMatchGuidanceResponse.changedPersons.map(changedPerson => changedPerson.id)).toContain(secondPerson.id);
});
});

describe("Identity API removeMatchGuidance", () => {
it("should remove match guidance", async () => {
it("removeMatchGuidance should remove match guidance", async () => {
const { person: firstPerson, identifier: firstIdentifier } = await createRandomRecord();
const { person: secondPerson, identifier: secondIdentifier } = await createRandomRecord();
const recordOne = { source: defaultSource, identifier: firstIdentifier };
Expand Down
4 changes: 1 addition & 3 deletions typescript/tests/identity/localHashing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const demographic: Demographic = {
gender: "male",
};

describe("LocalHashingApi hash", () => {
describe.concurrent("LocalHashingApi", () => {
it("should hash by demographic", async () => {
const result = await localHashingApi.hash(demographic);

Expand All @@ -30,9 +30,7 @@ describe("LocalHashingApi hash", () => {
expect(result.version).greaterThan(0);
expect(result.advisories.invalidDemographicFields).toEqual(["dob"]);
});
});

describe("LocalHashingApi constructor", () => {
it("should build from passed url", () => {
const localHashingApi = new LocalHashingApi({ url: "http://localhost:8080" });

Expand Down
8 changes: 8 additions & 0 deletions typescript/vitest.config.e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
testTimeout: 300000,
hookTimeout: 300000,
},
});
1 change: 1 addition & 0 deletions typescript/vitest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ export default defineConfig({
test: {
testTimeout: 300000,
hookTimeout: 300000,
Copy link
Contributor

Choose a reason for hiding this comment

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

do you need these long timeouts on unit tests?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Probably not. They could be reduced a bit.

exclude: ["tests/identity/*.test.ts", "node_modules/**/*"]
},
});
Loading