Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions modules/weko-items-ui/run_tests1028.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

# 各コマンドを8時間(28800秒)のタイムアウトを設定して順番に実行する
timeout 28800 .tox/c1/bin/pytest --cov=weko_items_ui tests/test_api.py -v -vv -s --cov-append --cov-branch --cov-report=term --cov-report=html --basetemp=/code/modules/weko-items-ui/.tox/c1/tmp --full-trace >> test_api-10-28-v2sh.log
timeout 28800 .tox/c1/bin/pytest --cov=weko_items_ui tests/test_permissions.py -v -vv -s --cov-append --cov-branch --cov-report=term --cov-report=html --basetemp=/code/modules/weko-items-ui/.tox/c1/tmp --full-trace >> test_permissins-10-28-v2sh.log
timeout 28800 .tox/c1/bin/pytest --cov=weko_items_ui tests/test_rest.py -v -vv -s --cov-append --cov-branch --cov-report=term --cov-report=html --basetemp=/code/modules/weko-items-ui/.tox/c1/tmp --full-trace >> test_rest-10-28-v2sh.log
timeout 28800 .tox/c1/bin/pytest --cov=weko_items_ui tests/test_utils.py -v -vv -s --cov-append --cov-branch --cov-report=term --cov-report=html --basetemp=/code/modules/weko-items-ui/.tox/c1/tmp --full-trace >> test_utils-10-28-v2sh.log
timeout 28800 .tox/c1/bin/pytest --cov=weko_items_ui tests/test_views.py -v -vv -s --cov-append --cov-branch --cov-report=term --cov-report=html --basetemp=/code/modules/weko-items-ui/.tox/c1/tmp --full-trace >> test_views-10-28-v2sh.log
timeout 28800 .tox/c1/bin/pytest --cov=weko_items_ui tests/test_weko_items_ui.py -v -vv -s --cov-append --cov-branch --cov-report=term --cov-report=html --basetemp=/code/modules/weko-items-ui/.tox/c1/tmp --full-trace >> test_weko_items_ui-10-28-v2sh.log
99 changes: 45 additions & 54 deletions modules/weko-items-ui/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,11 @@
from invenio_accounts import InvenioAccounts
from invenio_accounts.models import Role, User
from invenio_accounts.testutils import create_test_user, login_user_via_session
# from invenio_accounts.views.settings import blueprint as invenio_accounts_blueprint
from invenio_admin import InvenioAdmin
from invenio_admin.views import blueprint as invenio_admin_blueprint
from invenio_assets import InvenioAssets
# from invenio_assets.cli import collect, npm
from invenio_cache import InvenioCache
from invenio_communities import InvenioCommunities
#from invenio_communities.views.ui import blueprint as invenio_communities_blueprint
from invenio_db import InvenioDB
from invenio_db import db as db_
from invenio_deposit import InvenioDeposit
Expand All @@ -77,8 +74,8 @@
from invenio_pidrelations.models import PIDRelation
from invenio_pidstore import InvenioPIDStore
from invenio_pidstore.models import PersistentIdentifier, PIDStatus, Redirect
from invenio_pidrelations.contrib.versioning import PIDNodeVersioning
from invenio_pidrelations.contrib.draft import PIDNodeDraft
from invenio_pidrelations.contrib.versioning import PIDNodeVersioning
from invenio_records import InvenioRecords
from invenio_records_rest import InvenioRecordsREST
from weko_redis.redis import RedisConnection
Expand Down Expand Up @@ -152,7 +149,7 @@ def receive_after_begin(session, transaction, connection):
connection.execute("PRAGMA foreign_keys=OFF;")


@pytest.yield_fixture()
@pytest.fixture()
def instance_path():
"""Temporary instance path."""
path = tempfile.mkdtemp()
Expand All @@ -175,7 +172,6 @@ def base_app(instance_path):
SQLALCHEMY_DATABASE_URI=os.environ.get(
"SQLALCHEMY_DATABASE_URI", "sqlite:///test.db"
),
#SQLALCHEMY_DATABASE_URI='postgresql+psycopg2://invenio:dbpass123@postgresql:5432/wekotest',
SQLALCHEMY_TRACK_MODIFICATIONS=True,
ACCOUNTS_USERINFO_HEADERS=True,
WEKO_PERMISSION_SUPER_ROLE_USER=[
Expand Down Expand Up @@ -207,8 +203,6 @@ def base_app(instance_path):
WEKO_SCHEMA_UI_LIST_SCHEME_AFFILIATION = [
'ISNI', 'kakenhi', 'Ringgold', 'GRID','ROR'
],
# WEKO_ITEMS_UI_BASE_TEMPLATE = 'weko_items_ui/base.html',
# WEKO_ITEMS_UI_INDEX_TEMPLATE= 'weko_items_ui/item_index.html',
CACHE_TYPE="redis",
ACCOUNTS_SESSION_REDIS_DB_NO=1,
CACHE_REDIS_HOST="redis",
Expand Down Expand Up @@ -256,8 +250,6 @@ def base_app(instance_path):
WEKO_USERPROFILES_GENERAL_ROLE=WEKO_USERPROFILES_GENERAL_ROLE,
CACHE_REDIS_DB = 2,
WEKO_DEPOSIT_ITEMS_CACHE_PREFIX=WEKO_DEPOSIT_ITEMS_CACHE_PREFIX,
# INDEXER_DEFAULT_DOCTYPE="item-v1.0.0",
# INDEXER_FILE_DOC_TYPE="item-v1.0.0",
WEKO_INDEX_TREE_DEFAULT_DISPLAY_NUMBER=WEKO_INDEX_TREE_DEFAULT_DISPLAY_NUMBER,
DEPOSIT_DEFAULT_JSONSCHEMA=DEPOSIT_DEFAULT_JSONSCHEMA,
DEPOSIT_JSONSCHEMAS_PREFIX=DEPOSIT_JSONSCHEMAS_PREFIX,
Expand All @@ -282,56 +274,26 @@ def base_app(instance_path):
InvenioAccounts(app_)
InvenioAccess(app_)
InvenioCache(app_)
# InvenioTheme(app_)
# InvenioREST(app_)

# InvenioCache(app_)

# InvenioDeposit(app_)
InvenioPIDStore(app_)
# InvenioPIDRelations(app_)
InvenioRecords(app_)
# InvenioRecordsREST(app_)
InvenioFilesREST(app_)
InvenioJSONSchemas(app_)
# InvenioOAIServer(app_)

InvenioSearch(app_)

# WekoSchemaUI(app_)
InvenioStats(app_)

# InvenioAdmin(app_)
Menu(app_)
WekoRecords(app_)
WekoDeposit(app_)
WekoWorkflow(app_)
WekoGroups(app_)
# WekoAdmin(app_)
# WekoTheme(app_)
# WekoRecordsUI(app_)
# InvenioCommunities(app_)

InvenioIndexer(app_)
# WekoSearchREST(app_)
# WekoIndexTree(app_)
# WekoIndexTreeREST(app_)
WekoRecords(app_)
WekoSearchUI(app_)
# ext.init_config(app_)
WekoItemsUI(app_)
WekoItemsREST(app_)
# app_.register_blueprint(invenio_accounts_blueprint)
# app_.register_blueprint(weko_theme_blueprint)
# app_.register_blueprint(weko_items_ui_blueprint)
# app_.register_blueprint(invenio_communities_blueprint)
# app_.register_blueprint(weko_workflow_blueprint)

# runner = CliRunner()
# result = runner.invoke(collect, [],obj=weko_items_ui_blueprint)
# Run build
# result = runner.invoke(assets, ['build'],obj=weko_items_ui_blueprint)
# result = runner.invoke(npm,obj=weko_items_ui_blueprint)

current_assets = LocalProxy(lambda: app_.extensions["invenio-assets"])
current_assets.collect.collect()
Expand All @@ -340,22 +302,22 @@ def base_app(instance_path):



@pytest.yield_fixture()
@pytest.fixture()
def app(base_app):
"""Flask application fixture."""
with base_app.app_context():
yield base_app


@pytest.yield_fixture()
@pytest.fixture()
def client_api(app):
app.register_blueprint(weko_items_ui_blueprint_api, url_prefix="/api/items")
with app.test_client() as client:
yield client



@pytest.yield_fixture()
@pytest.fixture()
def client(app):
"""make a test client.

Expand Down Expand Up @@ -437,7 +399,6 @@ def esindex2(app):
@pytest.fixture()
def users(app, db):
"""Create users."""
db.create_all() # データベースの初期化

ds = app.extensions["invenio-accounts"].datastore
user_count = User.query.filter_by(email="user@test.org").count()
Expand Down Expand Up @@ -731,7 +692,7 @@ def db_itemtype4(app, db):

@pytest.fixture()
def db_itemtype5(app, db):
item_type_name = ItemTypeName(id=None,
item_type_name = ItemTypeName(id=5,
name="テストアイテムタイプ5", has_site_license=True, is_active=True
)
item_type_schema = dict()
Expand Down Expand Up @@ -771,6 +732,7 @@ def db_itemtype5(app, db):

return {"item_type_name": item_type_name, "item_type": item_type, "item_type_mapping":item_type_mapping}


@pytest.fixture()
def db_itemtype(app, db):
item_type_name = ItemTypeName(id=None,
Expand Down Expand Up @@ -976,17 +938,41 @@ def db_workflow(app, db, db_itemtype, users):
action_date=datetime.strptime("2018/07/28 0:00:00", "%Y/%m/%d %H:%M:%S"),
send_mail_setting={},
)
flow_action4 = FlowAction(
status="N",
id=31005,
flow_id=flow_id,
action_id=5,
action_version="1.0.0",
action_order=3,
action_condition="",
action_status="A",
action_date=datetime.strptime("2018/07/28 0:00:00", "%Y/%m/%d %H:%M:%S"),
send_mail_setting={},
)
flow_action5 = FlowAction(
status="N",
id=31006,
flow_id=flow_id,
action_id=5,
action_version="1.0.0",
action_order=3,
action_condition="",
action_status="A",
action_date=datetime.strptime("2018/07/28 0:00:00", "%Y/%m/%d %H:%M:%S"),
send_mail_setting={},
)
flow_action_role1 = FlowActionRole(
flow_action_id=1,
action_role=1,
flow_action_id=31005,
action_role='Community Administrator',
action_role_exclude=False,
action_user=1,
action_user_exclude=False,
specify_property='user_a'
)
flow_action_role2 = FlowActionRole(
flow_action_id=1,
action_role=1,
flow_action_id=31006,
action_role='Community Administrator',
action_role_exclude=False,
action_user=1,
action_user_exclude=False,
Expand Down Expand Up @@ -1038,6 +1024,8 @@ def db_workflow(app, db, db_itemtype, users):
db.session.add(flow_action1)
db.session.add(flow_action2)
db.session.add(flow_action3)
db.session.add(flow_action4)
db.session.add(flow_action5)
db.session.add(flow_action_role1)
db.session.add(flow_action_role2)
db.session.add(workflow1)
Expand All @@ -1051,6 +1039,8 @@ def db_workflow(app, db, db_itemtype, users):
"flow_action1": flow_action1,
"flow_action2": flow_action2,
"flow_action3": flow_action3,
"flow_action4": flow_action4,
"flow_action5": flow_action5,
}


Expand Down Expand Up @@ -23177,12 +23167,12 @@ def make_record(db, indexer, i, files, thumbnail=None):
status=PIDStatus.REGISTERED,
)

h1 = PIDNodeVersioning(parent=parent)
h1.insert_child(child=recid)
h1.insert_child(child=recid_v1)
RecordDraft.link(recid, depid)
RecordDraft.link(recid_v1, depid_v1)

h1 = PIDNodeVersioning(pid=parent)
h1.insert_child(child_pid=recid)
h1.insert_child(child_pid=recid_v1)
PIDNodeDraft(pid=recid).insert_child(depid)
PIDNodeDraft(pid=recid_v1).insert_child(depid_v1)
if i % 2 == 1:
doi = PersistentIdentifier.create(
"doi",
Expand Down Expand Up @@ -23258,3 +23248,4 @@ def make_record(db, indexer, i, files, thumbnail=None):
"deposit": deposit,
"files": files,
}

7,425 changes: 7,424 additions & 1 deletion modules/weko-items-ui/tests/data/itemtype_form.json

Large diffs are not rendered by default.

19,298 changes: 19,297 additions & 1 deletion modules/weko-items-ui/tests/data/itemtype_render.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions modules/weko-items-ui/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from weko_items_ui.api import item_login
from flask import session,jsonify


# def item_login(item_type_id: int = 0):
# .tox/c1/bin/pytest --cov=weko_items_ui tests/test_api.py::test_item_login -vv -s --cov-branch --cov-report=term --cov-report=xml --basetemp=/code/modules/weko-items-ui/.tox/c1/tmp
def test_item_login(app,client,db_itemtype,db_itemtype2,db_itemtype3,db_itemtype4,db_itemtype5,users):
Expand Down Expand Up @@ -137,3 +138,4 @@ def test_view2():
session['activity_info'] = None
res =client.get("/test_itemlogin/1")
assert res.status_code==200

1 change: 1 addition & 0 deletions modules/weko-items-ui/tests/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ def test_edit_permission_factory(db_records):
expect = page_permission_factory(record, flg='Edit').can()
ret = edit_permission_factory(record)
assert ret.can()==True

Loading