From 60b8f60a24d7a4267f447cc047e101b68d80fcbd Mon Sep 17 00:00:00 2001 From: Daniel Chiquito Date: Wed, 9 Feb 2022 13:05:24 -0500 Subject: [PATCH] Update import tests --- miqa/core/tests/test_import.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/miqa/core/tests/test_import.py b/miqa/core/tests/test_import.py index 336df1bf..9098cc4b 100644 --- a/miqa/core/tests/test_import.py +++ b/miqa/core/tests/test_import.py @@ -6,6 +6,7 @@ import pytest from rest_framework.exceptions import APIException +from guardian.shortcuts import get_perms from miqa.core.tasks import import_data @@ -86,7 +87,7 @@ def test_import_csv(tmp_path, user, project_factory, sample_scans, user_api_clie user_api_client = user_api_client(project=project) resp = user_api_client.post(f'/api/v1/projects/{project.id}/import') - if user.is_superuser: + if get_perms(user, project): assert resp.status_code == 204 # The import should update the project, even though the names do not match project.refresh_from_db() @@ -115,7 +116,7 @@ def test_import_global_csv(tmp_path, user, project_factory, sample_scans, user_a user_api_client = user_api_client(project=project) resp = user_api_client.post(f'/api/v1/projects/{project.id}/import') - if user.is_superuser: + if get_perms(user, project): assert resp.status_code == 204 # The import should update the correctly named projects, but not the original import project project.refresh_from_db() @@ -147,7 +148,7 @@ def test_import_json( project = project_factory(import_path=json_file) resp = user_api_client(project=project).post(f'/api/v1/projects/{project.id}/import') - if user.is_superuser: + if get_perms(user, project): assert resp.status_code == 204 # The import should update the project, even though the names do not match project.refresh_from_db() @@ -181,7 +182,7 @@ def test_import_global_json( user_api_client = user_api_client(project=project) resp = user_api_client.post(f'/api/v1/projects/{project.id}/import') - if user.is_superuser: + if get_perms(user, project): assert resp.status_code == 204 # The import should update the correctly named projects, but not the original import project project.refresh_from_db()