-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: tests not working since finalize_app
* the problem was that the mock fixtures were called after the app creation. this does not work because in the finalize_app they have to be ready already. therefore they are now called as a entry point before of the finalize_app
- Loading branch information
1 parent
b3105dc
commit ea1bb5c
Showing
3 changed files
with
42 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This file is part of Invenio. | ||
# Copyright (C) 2022 CERN. | ||
# Copyright (C) 2024 Graz University of Technology. | ||
# | ||
# Invenio is free software; you can redistribute it and/or modify it | ||
# under the terms of the MIT License; see LICENSE file for more details. | ||
|
||
"""Mock service ext.""" | ||
|
||
from invenio_records_resources.resources import RecordResource | ||
from invenio_records_resources.services import RecordService | ||
|
||
from .administration.mock import MockView | ||
from .config import ServiceConfig | ||
from .resource import MockResource | ||
|
||
|
||
class MockExtension: | ||
"""Mock extension.""" | ||
|
||
def __init__(self, app=None): | ||
"""Extension initialization.""" | ||
if app: | ||
self.init_app(app) | ||
|
||
def init_app(self, app): | ||
"""Init app.""" | ||
mock_service = RecordService(ServiceConfig) | ||
mock_resource = RecordResource(MockResource, mock_service) | ||
|
||
app.extensions["mock-module"] = self | ||
# Adds resource's config name as a class attribute. | ||
self.__dict__[MockView.resource_config] = mock_resource |