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

DPL-1100: Upgrading dependencies and doing relevant code updates for dependency updates #917

Merged
merged 73 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
4177022
Bump werkzeug from 2.3.6 to 3.0.1
dependabot[bot] Oct 25, 2023
4366a88
Merge pull request #861 from sanger/dependabot/pip/werkzeug-3.0.1
yoldas Dec 8, 2023
250fa2f
Bump aiohttp from 3.9.0b0 to 3.9.0
dependabot[bot] Dec 8, 2023
aa0ae39
Merge pull request #863 from sanger/dependabot/pip/aiohttp-3.9.0
yoldas Dec 8, 2023
d982d0d
Bump cryptography from 41.0.5 to 41.0.6
dependabot[bot] Dec 8, 2023
ac2442f
Merge pull request #862 from sanger/dependabot/pip/cryptography-41.0.6
yoldas Dec 8, 2023
90584ca
Bump pytest from 7.4.0 to 7.4.3
dependabot[bot] Dec 8, 2023
f8a41c3
Merge pull request #860 from sanger/dependabot/pip/pytest-7.4.3
yoldas Dec 8, 2023
da3df1e
Bump pymongo from 4.4.1 to 4.6.1
dependabot[bot] Dec 11, 2023
bddd85b
Merge pull request #869 from sanger/dependabot/pip/pymongo-4.6.1
yoldas Dec 11, 2023
8e69b30
Bump flask-apscheduler from 1.12.4 to 1.13.1
dependabot[bot] Dec 11, 2023
843edb1
Bump tj-actions/changed-files from 23 to 41 in /.github/workflows
dependabot[bot] Jan 2, 2024
9a6eaa2
Merge pull request #879 from sanger/dependabot/github_actions/dot-git…
yoldas Jan 3, 2024
757fddc
Bump more-itertools from 10.0.0 to 10.2.0
dependabot[bot] Jan 9, 2024
4842d0f
Merge pull request #881 from sanger/dependabot/pip/more-itertools-10.2.0
yoldas Jan 10, 2024
e524d29
Bump sqlalchemy from 2.0.19 to 2.0.25
dependabot[bot] Jan 10, 2024
ae3d09b
Merge pull request #880 from sanger/dependabot/pip/sqlalchemy-2.0.25
yoldas Jan 10, 2024
0ca689b
Bump coverage from 7.2.7 to 7.4.0
dependabot[bot] Jan 10, 2024
7b31e00
Merge pull request #877 from sanger/dependabot/pip/coverage-7.4.0
yoldas Jan 10, 2024
a607124
Bump black from 23.7.0 to 23.12.1
dependabot[bot] Jan 10, 2024
22b31ec
Merge pull request #876 from sanger/dependabot/pip/black-23.12.1
yoldas Jan 10, 2024
b807141
Bump mypy from 1.4.1 to 1.8.0
dependabot[bot] Jan 10, 2024
5a09c41
Merge pull request #875 from sanger/dependabot/pip/mypy-1.8.0
yoldas Jan 10, 2024
63b02ee
Bump paramiko from 3.3.1 to 3.4.0
dependabot[bot] Jan 10, 2024
ff3dda4
Merge pull request #873 from sanger/dependabot/pip/paramiko-3.4.0
yoldas Jan 10, 2024
15fb93e
Bump pyodbc from 4.0.39 to 5.0.1
dependabot[bot] Jan 10, 2024
7f0fbed
Merge pull request #870 from sanger/dependabot/pip/pyodbc-5.0.1
yoldas Jan 10, 2024
4d3d16c
Bump types-python-dateutil from 2.8.19.14 to 2.8.19.20240106
dependabot[bot] Jan 11, 2024
ccf5beb
Merge pull request #887 from sanger/dependabot/pip/types-python-dateu…
yoldas Jan 11, 2024
74ed897
Bump colorlog from 6.7.0 to 6.8.0
dependabot[bot] Jan 11, 2024
d2dc447
Merge pull request #886 from sanger/dependabot/pip/colorlog-6.8.0
yoldas Jan 11, 2024
a191ec8
Bump flake8-bugbear from 23.7.10 to 24.1.17
dependabot[bot] Jan 18, 2024
bf57827
Merge pull request #892 from sanger/dependabot/pip/flake8-bugbear-24.…
yoldas Jan 18, 2024
12727f7
Bump jinja2 from 3.1.2 to 3.1.3
dependabot[bot] Jan 18, 2024
bbe612a
Merge pull request #888 from sanger/dependabot/pip/jinja2-3.1.3
yoldas Jan 18, 2024
874b9b1
Bump aiohttp from 3.9.0 to 3.9.2
dependabot[bot] Jan 30, 2024
6ec4a6f
Merge pull request #900 from sanger/dependabot/pip/aiohttp-3.9.2
yoldas Feb 5, 2024
a4cb01e
Merge branch 'develop' into dependabot/pip/flask-apscheduler-1.13.1
stevieing Feb 7, 2024
6590b27
Merge pull request #864 from sanger/dependabot/pip/flask-apscheduler-…
stevieing Feb 7, 2024
ecbbd97
Bump responses from 0.23.3 to 0.24.1
dependabot[bot] Feb 7, 2024
e4cc556
Merge pull request #884 from sanger/dependabot/pip/responses-0.24.1
stevieing Feb 7, 2024
419ad11
Bump flake8-bugbear from 24.1.17 to 24.2.6
dependabot[bot] Feb 8, 2024
0a2ab69
Merge pull request #904 from sanger/dependabot/pip/flake8-bugbear-24.2.6
yoldas Feb 12, 2024
e3fc104
Bump python-dotenv from 1.0.0 to 1.0.1
dependabot[bot] Feb 12, 2024
70daa6d
Merge pull request #894 from sanger/dependabot/pip/python-dotenv-1.0.1
yoldas Feb 12, 2024
585205a
Bump coverage from 7.4.0 to 7.4.1
dependabot[bot] Feb 12, 2024
056e12b
Merge pull request #896 from sanger/dependabot/pip/coverage-7.4.1
yoldas Feb 12, 2024
c925c1a
Bump pyodbc from 5.0.1 to 5.1.0
dependabot[bot] Feb 12, 2024
a8207fd
Merge pull request #903 from sanger/dependabot/pip/pyodbc-5.1.0
yoldas Feb 12, 2024
c41ac53
Bump colorlog from 6.8.0 to 6.8.2
dependabot[bot] Feb 12, 2024
74e6b96
Merge pull request #897 from sanger/dependabot/pip/colorlog-6.8.2
dasunpubudumal Feb 19, 2024
a28b120
Bump pytest from 7.4.3 to 8.0.1
dependabot[bot] Feb 19, 2024
5734768
Merge pull request #911 from sanger/dependabot/pip/pytest-8.0.1
dasunpubudumal Feb 19, 2024
4d3f34b
Bump flask from 2.3.2 to 3.0.2
dependabot[bot] Feb 19, 2024
385b7aa
Merge pull request #901 from sanger/dependabot/pip/flask-3.0.2
dasunpubudumal Feb 19, 2024
7695904
Bump cryptography from 41.0.7 to 42.0.2
dependabot[bot] Feb 19, 2024
9ae3f47
Merge pull request #910 from sanger/dependabot/pip/cryptography-42.0.2
dasunpubudumal Feb 19, 2024
5895b28
Bump black from 23.12.1 to 24.2.0
dependabot[bot] Feb 19, 2024
01b89cc
Updated black refactoring files
dasunpubudumal Feb 19, 2024
346f84e
Merge pull request #906 from sanger/dependabot/pip/black-24.2.0
dasunpubudumal Feb 19, 2024
7008498
Bump responses from 0.24.1 to 0.25.0
dependabot[bot] Feb 19, 2024
c157d14
Merge pull request #907 from sanger/dependabot/pip/responses-0.25.0
dasunpubudumal Feb 19, 2024
c71109a
Bump sqlalchemy from 2.0.25 to 2.0.27
dependabot[bot] Feb 19, 2024
7090be3
Merge pull request #908 from sanger/dependabot/pip/sqlalchemy-2.0.27
dasunpubudumal Feb 19, 2024
410edfb
Bump mysql-connector-python from 8.1.0 to 8.3.0
dependabot[bot] Feb 20, 2024
8287dcc
Testing out implementing mock methods using MagicMock
dasunpubudumal Feb 20, 2024
4a7d941
Fixing issues with black and mypy
dasunpubudumal Feb 20, 2024
acc8a66
Fixing issues with black and mypy
dasunpubudumal Feb 21, 2024
eae5839
Refactoring minor updates
dasunpubudumal Feb 21, 2024
27f8796
Merge pull request #890 from sanger/dependabot/pip/mysql-connector-py…
dasunpubudumal Feb 21, 2024
0af4a2a
Update .release-version
dasunpubudumal Feb 22, 2024
c45e067
Merge pull request #916 from sanger/version-upgrade
dasunpubudumal Feb 22, 2024
78404d2
Merge branch 'master' into develop
dasunpubudumal Feb 22, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/check_release_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

- name: Get specific changed files
id: changed-files-specific
uses: tj-actions/changed-files@v23
uses: tj-actions/changed-files@v41
with:
files: |
.release-version
Expand Down
2 changes: 1 addition & 1 deletion .release-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.12.0
2.13.0
14 changes: 7 additions & 7 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ types-python-dateutil = "*"
responses = "*"

[packages]
colorlog = "~=6.7"
flask = "~=2.3"
flask-apscheduler = "~=1.12"
colorlog = "~=6.8"
flask = "~=3.0"
flask-apscheduler = "~=1.13"
gunicorn = "~=21.2"
more-itertools = "~=10.0"
mysql-connector-python = "~=8.1"
more-itertools = "~=10.2"
mysql-connector-python = "~=8.3"
pandas = "~=2.0"
pika = "~=1.3"
pymongo = "~=4.4"
pymongo = "~=4.6"
pymysql = "~=1.1"
pyodbc = "~=4.0"
pyodbc = "~=5.1"
pysftp = "~=0.2"
python-dotenv = "~=1.0"
requests = "~=2.31"
Expand Down
2,228 changes: 1,169 additions & 1,059 deletions Pipfile.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions crawler/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@
TEST_DATA_ERROR_WRONG_STATE: Final[str] = "Run doesn't have status"
TEST_DATA_ERROR_INVALID_PLATE_SPECS: Final[str] = "There is a problem with the plate specs for the run."
TEST_DATA_ERROR_NUMBER_OF_PLATES: Final[str] = "Number of plates to generate must be between 1 and {0}."
TEST_DATA_ERROR_NUMBER_OF_POS_SAMPLES: Final[
str
] = "One or more plates expected fewer than 0 or more than 96 positive samples."
TEST_DATA_ERROR_PLATE_CREATION_FAILED: Final[
str
] = "One or more plates failed to generate data correctly. Please try again."
TEST_DATA_ERROR_NUMBER_OF_POS_SAMPLES: Final[str] = (
"One or more plates expected fewer than 0 or more than 96 positive samples."
)
TEST_DATA_ERROR_PLATE_CREATION_FAILED: Final[str] = (
"One or more plates failed to generate data correctly. Please try again."
)


###
Expand Down
9 changes: 6 additions & 3 deletions crawler/db/mysql.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import logging
from datetime import datetime
from itertools import islice
from typing import Any, Dict, Generator, Iterable, List, cast
from typing import Any, Dict, Generator, Iterable, List, cast, Sequence

import mysql.connector as mysql
import sqlalchemy
from mysql.connector.types import MySQLConvertibleType
from mysql.connector.connection_cext import MySQLConnectionAbstract
from mysql.connector.cursor_cext import MySQLCursorAbstract
from sqlalchemy.engine.base import Engine
Expand Down Expand Up @@ -65,7 +66,7 @@ def create_mysql_connection(config: Config, readonly: bool = True) -> MySQLConne


def run_mysql_executemany_query(
mysql_conn: MySQLConnectionAbstract, sql_query: str, values: List[Dict[str, str]]
mysql_conn: MySQLConnectionAbstract, sql_query: str, values: Sequence[Dict[str, MySQLConvertibleType]]
) -> None:
"""Writes the sample testing information into the MLWH.

Expand Down Expand Up @@ -223,7 +224,9 @@ def partition(iterable: Iterable, partition_size: int) -> Generator[List[Any], N
yield part


def reset_is_current_flags(cursor: MySQLCursorAbstract, rna_ids: List[str], chunk_size: int = 1000) -> None:
def reset_is_current_flags(
cursor: MySQLCursorAbstract, rna_ids: List[MySQLConvertibleType], chunk_size: int = 1000
) -> None:
"""Receives a cursor with an active connection and a list of rna_ids and
runs an update resetting any is_current flags to false for all the specified
rna ids in groups of chunk_size.
Expand Down
5 changes: 3 additions & 2 deletions crawler/helpers/general_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from datetime import datetime
from decimal import Decimal
from http import HTTPStatus
from typing import Any, Dict, Iterable, List, Optional
from typing import Any, Dict, Iterable, List, Optional, Sequence
from mysql.connector.types import MySQLConvertibleType

import pysftp
import requests
Expand Down Expand Up @@ -268,7 +269,7 @@ def map_mongo_sample_to_mysql(doc: SampleDoc, copy_date: bool = False) -> Dict[s
return value


def set_is_current_on_mysql_samples(samples: Iterable[Dict[str, str]]) -> List[Dict[str, str]]:
def set_is_current_on_mysql_samples(samples: Iterable[Dict[str, str]]) -> Sequence[Dict[str, MySQLConvertibleType]]:
"""Creates a copy of the samples passed in, adding is_current values to each sample.
is_current will be True for all samples unless there is a repeated RNA ID, in which case
only the last one is set to True.
Expand Down
5 changes: 3 additions & 2 deletions migrations/back_populate_source_plate_and_sample_uuids.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import Dict, List, Optional, cast
from uuid import uuid4

from mysql.connector.types import MySQLConvertibleType, RowType
from mysql.connector.connection_cext import MySQLConnectionAbstract
from pymongo.collection import Collection
from pymongo.database import Database
Expand Down Expand Up @@ -366,7 +367,7 @@ def prepare_mlwh_row(sample_doc):
existing_samples = mysql_generator_from_connection(mysql_conn, query)
log_mlwh_sample_fields("Before update", existing_samples)

row_data = [cast(Dict[str, str], row) for row in update_rows]
row_data = [cast(Dict[str, MySQLConvertibleType], row) for row in update_rows]
run_mysql_executemany_query(mysql_conn, SQL_MLWH_UPDATE_SAMPLE_UUID_PLATE_UUID, row_data)

# Log the new fields on the MLWH samples
Expand Down Expand Up @@ -394,7 +395,7 @@ def mlwh_count_samples_from_mongo_ids(mysql_conn: MySQLConnectionAbstract, mongo
if result is None:
raise Exception("Query result was not valid")

return cast(int, result[0])
return cast(int, cast(RowType, result)[0])
else:
raise Exception("Cannot connect mysql")

Expand Down
9 changes: 6 additions & 3 deletions migrations/helpers/shared_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
from contextlib import closing
from csv import DictReader
from datetime import datetime
from typing import Any, Dict, Iterator, List, Optional
from typing import Any, Dict, Iterator, List, Optional, cast

from mysql.connector.connection_cext import MySQLConnectionAbstract
from mysql.connector.types import RowItemType
from pymongo.collection import Collection

from crawler.constants import (
Expand Down Expand Up @@ -117,11 +118,13 @@ def valid_filepath(s_filepath: str) -> bool:
return False


def mysql_generator_from_connection(connection: MySQLConnectionAbstract, query: str) -> Iterator[Dict[str, Any]]:
def mysql_generator_from_connection(
connection: MySQLConnectionAbstract, query: str
) -> Iterator[Dict[str, RowItemType]]:
with closing(connection.cursor(dictionary=True, buffered=False)) as cursor:
cursor.execute(query)
for row in cursor.fetchall():
yield row
yield cast(Dict[str, RowItemType], row)


def mysql_generator_from_config(config: Config, query: str) -> Iterator[Dict[str, Any]]:
Expand Down
19 changes: 19 additions & 0 deletions tests/db/test_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,29 @@ class MockMySQLConnection(MySQLConnectionAbstract):
_execute_query = MagicMock()
_open_connection = MagicMock()
close = MagicMock()
cmd_change_user = MagicMock()
cmd_debug = MagicMock()
cmd_init_db = MagicMock()
cmd_ping = MagicMock()
cmd_process_kill = MagicMock()
cmd_query = MagicMock()
cmd_query_iter = MagicMock()
cmd_quit = MagicMock()
cmd_refresh = MagicMock()
cmd_reset_connection = MagicMock()
cmd_shutdown = MagicMock()
cmd_statistics = MagicMock()
cmd_stmt_close = MagicMock()
cmd_stmt_execute = MagicMock()
cmd_stmt_prepare = MagicMock()
cmd_stmt_reset = MagicMock()
cmd_stmt_send_long_data = MagicMock()
commit = MagicMock()
connection_id = MagicMock()
cursor = MagicMock()
database = MagicMock()
disconnect = MagicMock()
get_row = MagicMock()
get_rows = MagicMock()
in_transaction = MagicMock()
info_query = MagicMock()
Expand Down
126 changes: 65 additions & 61 deletions tests/file_processing/test_file_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
from datetime import datetime
from decimal import Decimal
from io import StringIO
from typing import List
from typing import List, cast, Dict
from unittest.mock import MagicMock, patch

import pytest
from bson.decimal128 import Decimal128
from bson.objectid import ObjectId
from mysql.connector.connection_cext import MySQLConnectionAbstract
from mysql.connector.types import RowItemType

from crawler.constants import (
CENTRE_KEY_BACKUPS_FOLDER,
Expand Down Expand Up @@ -1548,65 +1549,68 @@ def test_insert_samples_from_docs_into_mlwh(
rows = cursor.fetchall()
cursor.close()

assert rows[0][MLWH_MONGODB_ID] == "5f562d9931d9959b92544728"
assert rows[0][MLWH_ROOT_SAMPLE_ID] == "ABC00000004"
assert rows[0][MLWH_COG_UK_ID] == "TEST-123ABC"
assert rows[0][MLWH_RNA_ID] == "TC-rna-00000029_H11"
assert rows[0][MLWH_PLATE_BARCODE] == "TC-rna-00000029"
assert rows[0][MLWH_COORDINATE] == "H11"
assert rows[0][MLWH_RESULT] == "Negative"
assert rows[0][MLWH_DATE_TESTED] == date_tested_1
assert rows[0][MLWH_SOURCE] == "Test Centre"
assert rows[0][MLWH_LAB_ID] == "TC"
assert rows[0][MLWH_CH1_TARGET] is None
assert rows[0][MLWH_CH1_RESULT] is None
assert rows[0][MLWH_CH1_CQ] is None
assert rows[0][MLWH_CH2_TARGET] is None
assert rows[0][MLWH_CH2_RESULT] is None
assert rows[0][MLWH_CH2_CQ] is None
assert rows[0][MLWH_CH3_TARGET] is None
assert rows[0][MLWH_CH3_RESULT] is None
assert rows[0][MLWH_CH3_CQ] is None
assert rows[0][MLWH_CH4_TARGET] is None
assert rows[0][MLWH_CH4_RESULT] is None
assert rows[0][MLWH_CH4_CQ] is None
assert rows[0][MLWH_FILTERED_POSITIVE] is None
assert rows[0][MLWH_FILTERED_POSITIVE_VERSION] is None
assert rows[0][MLWH_FILTERED_POSITIVE_TIMESTAMP] is None
assert rows[0][MLWH_CREATED_AT] is not None
assert rows[0][MLWH_UPDATED_AT] is not None
assert rows[0][MLWH_MUST_SEQUENCE] == 0
assert rows[0][MLWH_PREFERENTIALLY_SEQUENCE] == 1

assert rows[1][MLWH_MONGODB_ID] == "5f562d9931d9959b92544729"
assert rows[1][MLWH_ROOT_SAMPLE_ID] == "ABC00000005"
assert rows[1][MLWH_COG_UK_ID] == "TEST-123ABD"
assert rows[1][MLWH_RNA_ID] == "TC-rna-00000029_H12"
assert rows[1][MLWH_PLATE_BARCODE] == "TC-rna-00000029"
assert rows[1][MLWH_COORDINATE] == "H12"
assert rows[1][MLWH_RESULT] == RESULT_VALUE_POSITIVE
assert rows[1][MLWH_DATE_TESTED] == date_tested_2
assert rows[1][MLWH_SOURCE] == "Test Centre"
assert rows[1][MLWH_LAB_ID] == "TC"
assert rows[1][MLWH_CH1_TARGET] == "ORF1ab"
assert rows[1][MLWH_CH1_RESULT] == RESULT_VALUE_POSITIVE
assert rows[1][MLWH_CH1_CQ] == Decimal("21.28726211")
assert rows[1][MLWH_CH2_TARGET] == "N gene"
assert rows[1][MLWH_CH2_RESULT] == RESULT_VALUE_POSITIVE
assert rows[1][MLWH_CH2_CQ] == Decimal("18.12736661")
assert rows[1][MLWH_CH3_TARGET] == "S gene"
assert rows[1][MLWH_CH3_RESULT] == RESULT_VALUE_POSITIVE
assert rows[1][MLWH_CH3_CQ] == Decimal("22.63616273")
assert rows[1][MLWH_CH4_TARGET] == "MS2"
assert rows[1][MLWH_CH4_RESULT] == RESULT_VALUE_POSITIVE
assert rows[1][MLWH_CH4_CQ] == Decimal("26.25125612")
assert rows[1][MLWH_FILTERED_POSITIVE] == 1
assert rows[1][MLWH_FILTERED_POSITIVE_VERSION] == "v2.3"
assert rows[1][MLWH_FILTERED_POSITIVE_TIMESTAMP] == filtered_positive_timestamp
assert rows[1][MLWH_CREATED_AT] is not None
assert rows[1][MLWH_UPDATED_AT] is not None
assert rows[1][MLWH_MUST_SEQUENCE] == 1
assert rows[1][MLWH_PREFERENTIALLY_SEQUENCE] == 0
first_row = cast(Dict[str, RowItemType], rows[0])
second_row = cast(Dict[str, RowItemType], rows[1])

assert first_row[MLWH_MONGODB_ID] == "5f562d9931d9959b92544728"
assert first_row[MLWH_ROOT_SAMPLE_ID] == "ABC00000004"
assert first_row[MLWH_COG_UK_ID] == "TEST-123ABC"
assert first_row[MLWH_RNA_ID] == "TC-rna-00000029_H11"
assert first_row[MLWH_PLATE_BARCODE] == "TC-rna-00000029"
assert first_row[MLWH_COORDINATE] == "H11"
assert first_row[MLWH_RESULT] == "Negative"
assert first_row[MLWH_DATE_TESTED] == date_tested_1
assert first_row[MLWH_SOURCE] == "Test Centre"
assert first_row[MLWH_LAB_ID] == "TC"
assert first_row[MLWH_CH1_TARGET] is None
assert first_row[MLWH_CH1_RESULT] is None
assert first_row[MLWH_CH1_CQ] is None
assert first_row[MLWH_CH2_TARGET] is None
assert first_row[MLWH_CH2_RESULT] is None
assert first_row[MLWH_CH2_CQ] is None
assert first_row[MLWH_CH3_TARGET] is None
assert first_row[MLWH_CH3_RESULT] is None
assert first_row[MLWH_CH3_CQ] is None
assert first_row[MLWH_CH4_TARGET] is None
assert first_row[MLWH_CH4_RESULT] is None
assert first_row[MLWH_CH4_CQ] is None
assert first_row[MLWH_FILTERED_POSITIVE] is None
assert first_row[MLWH_FILTERED_POSITIVE_VERSION] is None
assert first_row[MLWH_FILTERED_POSITIVE_TIMESTAMP] is None
assert first_row[MLWH_CREATED_AT] is not None
assert first_row[MLWH_UPDATED_AT] is not None
assert first_row[MLWH_MUST_SEQUENCE] == 0
assert first_row[MLWH_PREFERENTIALLY_SEQUENCE] == 1

assert second_row[MLWH_MONGODB_ID] == "5f562d9931d9959b92544729"
assert second_row[MLWH_ROOT_SAMPLE_ID] == "ABC00000005"
assert second_row[MLWH_COG_UK_ID] == "TEST-123ABD"
assert second_row[MLWH_RNA_ID] == "TC-rna-00000029_H12"
assert second_row[MLWH_PLATE_BARCODE] == "TC-rna-00000029"
assert second_row[MLWH_COORDINATE] == "H12"
assert second_row[MLWH_RESULT] == RESULT_VALUE_POSITIVE
assert second_row[MLWH_DATE_TESTED] == date_tested_2
assert second_row[MLWH_SOURCE] == "Test Centre"
assert second_row[MLWH_LAB_ID] == "TC"
assert second_row[MLWH_CH1_TARGET] == "ORF1ab"
assert second_row[MLWH_CH1_RESULT] == RESULT_VALUE_POSITIVE
assert second_row[MLWH_CH1_CQ] == Decimal("21.28726211")
assert second_row[MLWH_CH2_TARGET] == "N gene"
assert second_row[MLWH_CH2_RESULT] == RESULT_VALUE_POSITIVE
assert second_row[MLWH_CH2_CQ] == Decimal("18.12736661")
assert second_row[MLWH_CH3_TARGET] == "S gene"
assert second_row[MLWH_CH3_RESULT] == RESULT_VALUE_POSITIVE
assert second_row[MLWH_CH3_CQ] == Decimal("22.63616273")
assert second_row[MLWH_CH4_TARGET] == "MS2"
assert second_row[MLWH_CH4_RESULT] == RESULT_VALUE_POSITIVE
assert second_row[MLWH_CH4_CQ] == Decimal("26.25125612")
assert second_row[MLWH_FILTERED_POSITIVE] == 1
assert second_row[MLWH_FILTERED_POSITIVE_VERSION] == "v2.3"
assert second_row[MLWH_FILTERED_POSITIVE_TIMESTAMP] == filtered_positive_timestamp
assert second_row[MLWH_CREATED_AT] is not None
assert second_row[MLWH_UPDATED_AT] is not None
assert second_row[MLWH_MUST_SEQUENCE] == 1
assert second_row[MLWH_PREFERENTIALLY_SEQUENCE] == 0


def test_insert_samples_from_docs_into_mlwh_date_tested_missing(config, mlwh_connection):
Expand Down Expand Up @@ -1676,7 +1680,7 @@ def test_insert_samples_from_docs_into_mlwh_date_tested_none(
rows = cursor.fetchall()
cursor.close()

assert rows[0][MLWH_DATE_TESTED] is None
assert cast(Dict[str, RowItemType], rows[0])[MLWH_DATE_TESTED] is None


def test_insert_samples_from_docs_into_mlwh_returns_false_none_connection(config, mlwh_connection):
Expand Down
1 change: 1 addition & 0 deletions tests/file_processing/test_file_processing_1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Split test_file_processing.py into numerous files until a larger refactor can test classes more succinctly.
"""

from datetime import datetime, timezone

from crawler.constants import FIELD_DATE_TESTED
Expand Down
Loading