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

SFR-2481/save_test_data #543

Merged
merged 8 commits into from
Jan 29, 2025
Merged

Conversation

ayan1229
Copy link
Contributor

No description provided.

Comment on lines 74 to 81
def save_test_data_ids_to_file(self):
record = self.db_manager.session.query(Record).filter_by(source_id=self.test_data['source_id']).first()
if record:
with open('test_data_ids.json', 'w') as f:
json.dump({
'edition_id': str(record.edition_id),
'uuid': str(record.uuid)
}, f)
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this idea to share the test ids with the tests but I think we should use fixtures to seed the data instead of the process!

Comment on lines 7 to 10
@pytest.fixture(scope="module", autouse=True)
def seed_test_data():
process = SeedTestDataProcess()
process.runProcess()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can use seed the data directly from fixtures. Let's move this to conftest.py.

@pytest.mark.parametrize("endpoint, expected_status", [
("/editions/1982731", 200),
("/editions/{SEEDED_EDITION_ID}", 200),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to grab the edition from a fixture after it's been seeded and use it here in the parametrize annotation?

@@ -0,0 +1 @@
{"edition_id": "19855", "uuid": "3264ccb1-a870-43d7-9496-2153ca99acc6"}
Copy link
Contributor

Choose a reason for hiding this comment

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

let's get rid of this file!

@@ -16,3 +25,64 @@ def setup_env(pytestconfig, request):

if not running_unit_tests and environment in ['local', 'qa']:
load_env_file(environment, file_string=f'config/{environment}.yaml')

@pytest.fixture(scope='module')
Copy link
Contributor

Choose a reason for hiding this comment

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

question on the module scope. does this run during the unit tests?

we just want to run it during functional and integration tests

tests/conftest.py Outdated Show resolved Hide resolved
tests/conftest.py Outdated Show resolved Hide resolved
@@ -1,17 +1,19 @@
import pytest
import requests
import json
from .constants import API_URL
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok so the API_URL will have to change depending in the env. I think we can get this from the config file - DRB_API_HOST

}

@pytest.fixture(scope='module')
def seeded_edition_id(request, seed_test_data):
Copy link
Contributor

Choose a reason for hiding this comment

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

You may want to double check but I think because we have seed_test_data here it'll automatically make sure seed_test_data is resolved. Thus, checking the request may not make sense.

Copy link
Contributor

@kylevillegas93 kylevillegas93 left a comment

Choose a reason for hiding this comment

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

We may run into some issues on CI but let's see how we do!

@kylevillegas93
Copy link
Contributor

@ayan1229 let's get this out the door and make sure the tests are passing in CI. I'd get started on adding the other tests to CI as well.

@ayan1229 ayan1229 merged commit bff6d48 into main Jan 29, 2025
1 check passed
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