mirror of
https://github.com/Cian-H/invenio-theme-iform.git
synced 2025-12-22 20:51:58 +00:00
test: adding tests
* test: removed no cover * tests: adding tests for functions. * test_make_dict_like * test_cast_to_dict
This commit is contained in:
22
tests/ui/conftest.py
Normal file
22
tests/ui/conftest.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2020 mojib wali.
|
||||
#
|
||||
# invenio-theme-tugraz is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the MIT License; see LICENSE file for more
|
||||
# details.
|
||||
|
||||
"""Pytest configuration.
|
||||
|
||||
See https://pytest-invenio.readthedocs.io/ for documentation on which test
|
||||
fixtures are available.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from invenio_app.factory import create_ui
|
||||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def create_app(instance_path):
|
||||
"""Application factory fixture."""
|
||||
return create_ui
|
||||
33
tests/ui/test_views.py
Normal file
33
tests/ui/test_views.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2020 mojib wali.
|
||||
#
|
||||
# invenio-theme-tugraz is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the MIT License; see LICENSE file for more
|
||||
# details.
|
||||
|
||||
"""Test views."""
|
||||
|
||||
from elasticsearch_dsl.utils import AttrDict
|
||||
|
||||
from invenio_theme_tugraz.views import cast_to_dict, make_dict_like
|
||||
|
||||
|
||||
def test_make_dict_like():
|
||||
"""Test make_dict_like."""
|
||||
access = {
|
||||
"access_right" : "open"
|
||||
}
|
||||
dicts = make_dict_like("open", "access_right")
|
||||
assert access == dicts
|
||||
|
||||
|
||||
def test_cast_to_dict():
|
||||
"""Test cast_to_dict."""
|
||||
resource_type = {
|
||||
"subtype" : "publication-datamanagementplan",
|
||||
"type" : "publication"
|
||||
}
|
||||
expected = {'subtype': 'publication-datamanagementplan', 'type': 'publication'}
|
||||
attr = cast_to_dict(AttrDict(resource_type))
|
||||
assert expected == attr
|
||||
Reference in New Issue
Block a user