aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/auth/fixtures/resource_fixtures.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-09-13 14:06:05 +0300
committerFrederick Muriuki Muriithi2023-09-26 03:44:30 +0300
commit345e33fc8e1b12dda6626307ebac7e1206200974 (patch)
tree2f5f2f4b4fbfc293522cdbd5a89725108a77e0f3 /tests/unit/auth/fixtures/resource_fixtures.py
parent37771b3be3142f705101beb4c5dc34c1000962f9 (diff)
downloadgn-auth-345e33fc8e1b12dda6626307ebac7e1206200974.tar.gz
Update tests & fixtures to conform to schema changes
Diffstat (limited to 'tests/unit/auth/fixtures/resource_fixtures.py')
-rw-r--r--tests/unit/auth/fixtures/resource_fixtures.py30
1 files changed, 25 insertions, 5 deletions
diff --git a/tests/unit/auth/fixtures/resource_fixtures.py b/tests/unit/auth/fixtures/resource_fixtures.py
index af22733..7f3c383 100644
--- a/tests/unit/auth/fixtures/resource_fixtures.py
+++ b/tests/unit/auth/fixtures/resource_fixtures.py
@@ -3,23 +3,43 @@ import pytest
from gn_auth.auth.db import sqlite3 as db
-from .group_fixtures import TEST_RESOURCES
+from .group_fixtures import (
+ TEST_RESOURCES,
+ TEST_GROUP_01,
+ TEST_GROUP_02,
+ TEST_RESOURCES_GROUP_01,
+ TEST_RESOURCES_GROUP_02)
@pytest.fixture(scope="function")
def fxtr_resources(fxtr_group):# pylint: disable=[redefined-outer-name]
"""fixture: setup test resources in the database"""
conn, _group = fxtr_group
+ ownership = tuple({
+ "group_id": str(TEST_GROUP_01.group_id),
+ "resource_id": str(res.resource_id)
+ } for res in TEST_RESOURCES_GROUP_01) + tuple({
+ "group_id": str(TEST_GROUP_02.group_id),
+ "resource_id": str(res.resource_id)
+ } for res in TEST_RESOURCES_GROUP_02)
+
with db.cursor(conn) as cursor:
cursor.executemany(
- "INSERT INTO resources VALUES (?,?,?,?,?)",
- ((str(res.group.group_id), str(res.resource_id), res.resource_name,
+ "INSERT INTO resources VALUES (?,?,?,?)",
+ ((str(res.resource_id), res.resource_name,
str(res.resource_category.resource_category_id),
1 if res.public else 0) for res in TEST_RESOURCES))
+ cursor.executemany(
+ "INSERT INTO resource_ownership(group_id, resource_id) "
+ "VALUES (:group_id, :resource_id)",
+ ownership)
yield (conn, TEST_RESOURCES)
with db.cursor(conn) as cursor:
cursor.executemany(
- "DELETE FROM resources WHERE group_id=? AND resource_id=?",
- ((str(res.group.group_id), str(res.resource_id),)
+ "DELETE FROM resource_ownership "
+ "WHERE group_id=:group_id AND resource_id=:resource_id",
+ ownership)
+ cursor.executemany("DELETE FROM resources WHERE resource_id=?",
+ ((str(res.resource_id),)
for res in TEST_RESOURCES))