about summary refs log tree commit diff
path: root/tests/unit/auth/test_migrations_indexes.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-11-15 06:27:33 +0300
committerFrederick Muriuki Muriithi2022-11-15 06:27:33 +0300
commitd043cd59127a1031de20b12562712b6e3c50feef (patch)
treebefe3233dc4136158e300e8ffeef6db41b11e2ac /tests/unit/auth/test_migrations_indexes.py
parent3dc9a8a4f413d142e84a81f9c1abafedb779d7dd (diff)
downloadgenenetwork3-d043cd59127a1031de20b12562712b6e3c50feef.tar.gz
pylint: Fix a myriad of linting errors
Diffstat (limited to 'tests/unit/auth/test_migrations_indexes.py')
-rw-r--r--tests/unit/auth/test_migrations_indexes.py25
1 files changed, 11 insertions, 14 deletions
diff --git a/tests/unit/auth/test_migrations_indexes.py b/tests/unit/auth/test_migrations_indexes.py
index dba0a98..a346164 100644
--- a/tests/unit/auth/test_migrations_indexes.py
+++ b/tests/unit/auth/test_migrations_indexes.py
@@ -1,15 +1,12 @@
 """Test that indexes are created and removed."""
-
-from contextlib import closing
-
 import pytest
-import sqlite3
 
+from gn3.auth import db
 from gn3.migrations import get_migration, apply_migrations, rollback_migrations
 from tests.unit.auth.conftest import (
     apply_single_migration, rollback_single_migration, migrations_up_to)
 
-query = """
+QUERY = """
 SELECT name FROM sqlite_master WHERE type='index' AND tbl_name = ?
 AND name= ?
 """
@@ -28,7 +25,7 @@ migrations_tables_and_indexes = (
 @pytest.mark.unit_test
 @pytest.mark.parametrize(
     "migration_file,the_table,the_index", migrations_tables_and_indexes)
-def test_index_created(
+def test_index_created(# pylint: disable=[too-many-arguments]
         auth_testdb_path, auth_migrations_dir, backend, migration_file,
         the_table, the_index):
     """
@@ -41,11 +38,11 @@ def test_index_created(
     the_migration = get_migration(migration_path)
     query_params = (the_table, the_index)
     apply_migrations(backend, older_migrations)
-    with closing(sqlite3.connect(auth_testdb_path)) as conn, closing(conn.cursor()) as cursor:
-        cursor.execute(query, query_params)
+    with db.connection(auth_testdb_path) as conn, db.cursor(conn) as cursor:
+        cursor.execute(QUERY, query_params)
         result_before_migration = cursor.fetchall()
         apply_single_migration(backend, the_migration)
-        cursor.execute(query, query_params)
+        cursor.execute(QUERY, query_params)
         result_after_migration = cursor.fetchall()
 
     rollback_migrations(backend, older_migrations + [the_migration])
@@ -59,7 +56,7 @@ def test_index_created(
 @pytest.mark.unit_test
 @pytest.mark.parametrize(
     "migration_file,the_table,the_index", migrations_tables_and_indexes)
-def test_index_dropped(
+def test_index_dropped(# pylint: disable=[too-many-arguments]
         auth_testdb_path, auth_migrations_dir, backend, migration_file,
         the_table, the_index):
     """
@@ -72,14 +69,14 @@ def test_index_dropped(
     the_migration = get_migration(migration_path)
     query_params = (the_table, the_index)
     apply_migrations(backend, older_migrations)
-    with closing(sqlite3.connect(auth_testdb_path)) as conn, closing(conn.cursor()) as cursor:
-        cursor.execute(query, query_params)
+    with db.connection(auth_testdb_path) as conn, db.cursor(conn) as cursor:
+        cursor.execute(QUERY, query_params)
         result_before_migration = cursor.fetchall()
         apply_single_migration(backend, the_migration)
-        cursor.execute(query, query_params)
+        cursor.execute(QUERY, query_params)
         result_after_migration = cursor.fetchall()
         rollback_single_migration(backend, the_migration)
-        cursor.execute(query, query_params)
+        cursor.execute(QUERY, query_params)
         result_after_rollback = cursor.fetchall()
 
     rollback_migrations(backend, older_migrations)