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

add more tests

parent 6d692ecb
Pipeline #16757 passed with stages
in 4 minutes and 9 seconds
import unittest
class MyTestCase(unittest.TestCase):
def test_something(self):
self.assertEqual(True, True)
if __name__ == '__main__':
unittest.main()
from unittest import TestCase
from mediametadatatodb_app.resources import MediametadataToDB
import json
import os
from pathlib import Path
class Test(TestCase):
@staticmethod
def _load_file_and_get_res(file_name, get_res):
path = Path(__file__).parent / f"../fixtures/{file_name}"
with path.open('r') as f:
json_msg = json.load(f)
return get_res(json_msg['@graph'])
@staticmethod
def _get_digital_object(json_obj):
for res in json_obj:
if 'type' in res and res['type'] == 'digitalObject':
return res
@staticmethod
def _get_record(json_obj):
for res in json_obj:
if '@type' in res and res['@type'] == \
'https://www.ica.org/standards/RiC/ontology#Record':
return res
@staticmethod
def _get_thumbnail(json_obj):
for res in json_obj:
if 'type' in res and res['type'] == 'thumbnail':
return res
def setUp(self) -> None:
os.environ['URI_BASE'] = 'awefwef'
def test__get_values_from_inaccessible_digital_object(self):
res = {
'sig': 'BAB-PA_43-BAB_MC169A-1',
'access': 'public',
'uri': 'rtmp://intstream.memobase.ch:1935/memobase/mp3:BAB_MC169A.mp3',
'type': 'audio'
}
digital_object = Test._load_file_and_get_res('BAB-PA_43-BAB_MC169A.json',
Test._get_digital_object)
dig_obj_val = MediametadataToDB._get_values_from_digital_object(digital_object, 'public')
self.assertDictEqual(dig_obj_val, res)
def test__get_values_from_accessible_digital_object(self):
res = {
'sig': 'mfk-FLM-167202-1',
'access': 'public',
'mimetype': 'video/mpeg',
'height': '384.0',
'width': '512.0',
'duration': '524.970667',
'uri': 'http://datenbanksammlungen.mfk.ch/eMP/' +
'eMuseumPlus?service=MultimediaAsset&objectId=144755&memobaseExt=mp4',
'type': 'video'
}
digital_object = Test._load_file_and_get_res('mfk-FLM-167202.json', Test._get_digital_object)
dig_obj_val = MediametadataToDB._get_values_from_digital_object(digital_object, 'public')
self.assertDictEqual(dig_obj_val, res)
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