Unverified Commit a6cdad23 authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

add tests for access_status



Signed-off-by: Sebastian Schüpbach's avatarSebastian Schüpbach <sebastian.schuepbach@unibas.ch>
parent c8b34ab9
Pipeline #16764 passed with stages
in 4 minutes and 39 seconds
......@@ -214,7 +214,7 @@ def _get_access_status(graph):
if 'type' in resource and resource['type'] == 'access' and \
'regulates' in resource and \
resource['regulates'].startswith('https://memobase.ch/digital/') and \
'name' in 'resource':
'name' in resource:
if resource['name'] == 'public':
return 'public'
elif resource['name'] == 'private':
......
from unittest import TestCase
from mediametadatatodb_app.resources import MediametadataToDB
import json
import os
from pathlib import Path
from unittest import TestCase
from mediametadatatodb_app.resources import MediametadataToDB
class Test(TestCase):
......@@ -36,6 +36,16 @@ class Test(TestCase):
def setUp(self) -> None:
os.environ['URI_BASE'] = 'awefwef'
def test__get_access_status_if_resource_is_private(self):
access_status = MediametadataToDB._get_access_status(
Test._load_file_and_get_res('BAB-PA_43-BAB_MC169A.json', lambda x: x))
self.assertEqual(access_status, 'closed')
def test__get_access_status_if_resource_is_public(self):
access_status = MediametadataToDB._get_access_status(
Test._load_file_and_get_res('mfk-FLM-167202.json', lambda x: x))
self.assertEqual(access_status, 'public')
def test__get_values_from_inaccessible_digital_object(self):
res = {
'sig': 'BAB-PA_43-BAB_MC169A-1',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment