diff options
author | Frederick Muriuki Muriithi | 2022-02-21 16:23:06 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-02-21 16:23:06 +0300 |
commit | a35fce27875d9db80dce1976b6f8ee8c00ecfe0a (patch) | |
tree | 8e8f815a6e3d37348bdb8f253f5ec53f72dc2dbc /tests/unit/db | |
parent | c84b07b8c5ac0a42c0fab929c75823b30b548191 (diff) | |
download | genenetwork3-a35fce27875d9db80dce1976b6f8ee8c00ecfe0a.tar.gz |
Fix a myriad of linter issues
* Use `with` in place of plain `open`
* Use f-strings in place of `str.format()`
* Remove string interpolation from queries - provide data as query parameters
* other minor fixes
Diffstat (limited to 'tests/unit/db')
-rw-r--r-- | tests/unit/db/test_datasets.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/tests/unit/db/test_datasets.py b/tests/unit/db/test_datasets.py index 0b24489..e4abd2f 100644 --- a/tests/unit/db/test_datasets.py +++ b/tests/unit/db/test_datasets.py @@ -15,14 +15,14 @@ class TestDatasetsDBFunctions(TestCase): @pytest.mark.unit_test def test_retrieve_dataset_name(self): """Test that the function is called correctly.""" - for trait_type, thresh, trait_name, dataset_name, columns, table, expected in [ - ["ProbeSet", 9, "probesetTraitName", "probesetDatasetName", + for trait_type, thresh, dataset_name, columns, table, expected in [ + ["ProbeSet", 9, "probesetDatasetName", "Id, Name, FullName, ShortName, DataScale", "ProbeSetFreeze", {"dataset_id": None, "dataset_name": "probesetDatasetName", "dataset_fullname": "probesetDatasetName"}], - ["Geno", 3, "genoTraitName", "genoDatasetName", + ["Geno", 3, "genoDatasetName", "Id, Name, FullName, ShortName", "GenoFreeze", {}], - ["Publish", 6, "publishTraitName", "publishDatasetName", + ["Publish", 6, "publishDatasetName", "Id, Name, FullName, ShortName", "PublishFreeze", {}]]: db_mock = mock.MagicMock() with self.subTest(trait_type=trait_type): @@ -30,16 +30,15 @@ class TestDatasetsDBFunctions(TestCase): cursor.fetchone.return_value = {} self.assertEqual( retrieve_dataset_name( - trait_type, thresh, trait_name, dataset_name, db_mock), + trait_type, thresh, dataset_name, db_mock), expected) cursor.execute.assert_called_once_with( - "SELECT {cols} " - "FROM {table} " + f"SELECT {columns} " + f"FROM {table} " "WHERE public > %(threshold)s AND " "(Name = %(name)s " "OR FullName = %(name)s " - "OR ShortName = %(name)s)".format( - table=table, cols=columns), + "OR ShortName = %(name)s)", {"threshold": thresh, "name": dataset_name}) @pytest.mark.unit_test |