Buckets:
AnonymousSpottedToad/human_verified_bucket / codebase /python /Clinical-Genomics_statina /tests /conftest.py
| from pathlib import Path | |
| import pytest | |
| from fastapi.testclient import TestClient | |
| from mongomock import MongoClient | |
| from statina.adapter.plugin import StatinaAdapter | |
| from statina.config import get_nipt_adapter | |
| from statina.main import external_app as app | |
| from statina.models.server.load import BatchRequestBody, UserRequestBody | |
| from .small_helpers import SmallHelpers | |
| DATABASE = "testdb" | |
| def override_nipt_adapter(): | |
| """Function for overriding the statina adapter dependency""" | |
| mongo_client = MongoClient() | |
| database = mongo_client[DATABASE] | |
| return StatinaAdapter(database.client, db_name=DATABASE) | |
| def fast_app_client(): | |
| """Return a mock fastapi app""" | |
| client = TestClient(app) | |
| app.dependency_overrides[get_nipt_adapter] = override_nipt_adapter | |
| return client | |
| ##################### | |
| def pymongo_client(request): | |
| """Get a client to the mongo database""" | |
| mock_client = MongoClient() | |
| def teardown(): | |
| mock_client.drop_database(DATABASE) | |
| request.addfinalizer(teardown) | |
| return mock_client | |
| def database(request, pymongo_client): | |
| """Get an adapter connected to mongo database""" | |
| mongo_client = pymongo_client | |
| database = mongo_client[DATABASE] | |
| return database | |
| def valid_load_user(): | |
| return UserRequestBody( | |
| email="maya.papaya@something.se", | |
| username="Maya Papaya", | |
| role="RW", | |
| password="123", | |
| ) | |
| def valid_load_batch(multiqc_report, segmental_calls, valid_csv): | |
| batch_files = BatchRequestBody( | |
| data_set="data_set", | |
| multiqc_report=multiqc_report, | |
| segmental_calls=segmental_calls, | |
| result_file=valid_csv, | |
| ) | |
| return batch_files | |
| def fixture_small_helpers(): | |
| """Return a class with small helper functions""" | |
| return SmallHelpers() | |
| ########################################## | |
| ###### fixture files for input csv ###### | |
| ########################################## | |
| def valid_csv() -> Path: | |
| """Get file path to valid csv""" | |
| return "tests/fixtures/fluffy_result_files/valid_fluffy.csv" | |
| def csv_with_missing_sample_id(): | |
| """Get file path to invalid csv""" | |
| return "tests/fixtures/fluffy_result_files/fluffy_file_with_missing_sample_id.csv" | |
| def csv_with_missing_sample_project(): | |
| """Get file path to invalid csv""" | |
| return "tests/fixtures/fluffy_result_files/fluffy_file_with_missing_sample_project.csv" | |
| def multiqc_report(): | |
| """Get file path to multiqc_report""" | |
| return "tests/fixtures/fluffy_result_files/multiqc_report.html" | |
| def segmental_calls(): | |
| """Get file path to segmental_calls""" | |
| return "tests/fixtures/fluffy_result_files" | |
Xet Storage Details
- Size:
- 2.92 kB
- Xet hash:
- 5e65f1815df946d9e941eb4149230f2f0f16afaf473b73a675869a2ce5f88840
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.