Skip to content

Commit 667a6dc

Browse files
committed
global: fix invenio.base mentions
* FIX Amends legacy imports and mentions of `invenio.base` module. Signed-off-by: Jiri Kuncar <jiri.kuncar@cern.ch>
1 parent 31ddeec commit 667a6dc

File tree

6 files changed

+33
-49
lines changed

6 files changed

+33
-49
lines changed

invenio_base/__init__.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
2+
#
23
# This file is part of Invenio.
3-
# Copyright (C) 2012, 2013, 2014 CERN.
4+
# Copyright (C) 2012, 2013, 2014, 2015 CERN.
45
#
56
# Invenio is free software; you can redistribute it and/or
67
# modify it under the terms of the GNU General Public License as
@@ -16,9 +17,4 @@
1617
# along with Invenio; if not, write to the Free Software Foundation, Inc.,
1718
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.A
1819

19-
"""
20-
invenio.base
21-
------------
22-
23-
Builds the Invenio application.
24-
"""
20+
"""Build the Invenio application."""
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
2+
#
23
# This file is part of Invenio.
3-
# Copyright (C) 2012, 2013 CERN.
4+
# Copyright (C) 2012, 2013, 2015 CERN.
45
#
56
# Invenio is free software; you can redistribute it and/or
67
# modify it under the terms of the GNU General Public License as
@@ -15,15 +16,13 @@
1516
# You should have received a copy of the GNU General Public License
1617
# along with Invenio; if not, write to the Free Software Foundation, Inc.,
1718
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18-
"""
19-
invenio.base.before_request_functions
20-
-------------------------------------
2119

22-
Implements functions to configure necessary the "before request" functions
23-
one wants to attach to the application at the global level.
20+
"""Implement functions to configure necessary the "before request" functions.
21+
22+
These functions will be attached to the application at the global level.
2423
"""
2524

2625

2726
def setup_app(app):
28-
"""Attaches functions to before request handler."""
27+
"""Attache functions to before request handler."""
2928
pass

invenio_base/factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def create_app(instance_path=None, static_folder=None, **kwargs_config):
232232
#
233233

234234
# Load default configuration
235-
app.config.from_object('invenio.base.config')
235+
app.config.from_object('invenio_base.config')
236236

237237
# Load site specific default configuration from entry points
238238
load_site_config(app)

invenio_base/helpers.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
2+
#
23
# This file is part of Invenio.
3-
# Copyright (C) 2012, 2013 CERN.
4+
# Copyright (C) 2012, 2013, 2015 CERN.
45
#
56
# Invenio is free software; you can redistribute it and/or
67
# modify it under the terms of the GNU General Public License as
@@ -15,23 +16,20 @@
1516
# You should have received a copy of the GNU General Public License
1617
# along with Invenio; if not, write to the Free Software Foundation, Inc.,
1718
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18-
"""
19-
invenio.base.helpers
20-
--------------------
2119

22-
Implements various helpers.
23-
"""
20+
"""Implement various helpers."""
2421

2522
from functools import wraps
23+
2624
from flask import Flask, current_app, has_app_context
27-
from six import iteritems, text_type, string_types
2825

26+
from six import iteritems, string_types, text_type
2927

30-
def with_app_context(app=None, new_context=False, **kwargs_config):
31-
"""Run function within the application context"""
3228

29+
def with_app_context(app=None, new_context=False, **kwargs_config):
30+
"""Run function within the application context."""
3331
def get_application():
34-
"""Returns an application instance."""
32+
"""Return an application instance."""
3533
if app is not None and not isinstance(app, Flask) and callable(app):
3634
return app(**kwargs_config)
3735
else:
@@ -41,8 +39,7 @@ def get_application():
4139
def decorator(f):
4240
@wraps(f)
4341
def decorated_func(*args, **kwargs):
44-
"""This function has to run within the application context."""
45-
42+
"""Force this function to run within the application context."""
4643
if not has_app_context() or new_context:
4744
with get_application().test_request_context('/'):
4845
# FIXME we should use maybe app_context()
@@ -56,9 +53,9 @@ def decorated_func(*args, **kwargs):
5653

5754

5855
def unicodifier(obj):
59-
"""
60-
Tries to (recursively) convert the given object into Unicode, assuming
61-
a UTF-8 encoding)
56+
"""Try to (recursively) convert the given object into Unicode.
57+
58+
It assumes a UTF-8 encoding.
6259
6360
:param obj: the object to convert
6461
(can be e.g. unicode, str, list, tuple, dict)
@@ -77,8 +74,7 @@ def unicodifier(obj):
7774

7875

7976
def utf8ifier(obj):
80-
"""
81-
Tries to (recursively) convert the given object into utf8.
77+
"""Try to (recursively) convert the given object into utf8.
8278
8379
:param obj: the object to convert
8480
(can be e.g. unicode, str, list, tuple, dict)

tests/test_flash_security.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323

2424
from flask import escape, url_for
2525

26-
from invenio.testsuite import InvenioTestCase, make_test_suite, \
27-
run_test_suite
26+
from invenio.testsuite import InvenioTestCase
2827

2928

3029
class FlashMessageSecurityTest(InvenioTestCase):
@@ -36,7 +35,7 @@ def config(self):
3635
cfg = super(FlashMessageSecurityTest, self).config
3736
cfg['PACKAGES'] = [
3837
'test_apps.flash_msg',
39-
'invenio.base',
38+
'invenio_base',
4039
]
4140
return cfg
4241

@@ -65,8 +64,3 @@ def test_flash_message_escaping(self):
6564
self.assertTrue(message in response.data,
6665
'flash message should not have been escaped for ' +
6766
'context "{}"'.format(context))
68-
69-
TEST_SUITE = make_test_suite(FlashMessageSecurityTest)
70-
71-
if __name__ == "__main__":
72-
run_test_suite(TEST_SUITE)

tests/test_scripts_config.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
2+
#
23
# This file is part of Invenio.
3-
# Copyright (C) 2014 CERN.
4+
# Copyright (C) 2014, 2015 CERN.
45
#
56
# Invenio is free software; you can redistribute it and/or
67
# modify it under the terms of the GNU General Public License as
@@ -16,18 +17,19 @@
1617
# along with Invenio; if not, write to the Free Software Foundation, Inc.,
1718
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.A
1819

19-
"""Test invenio.base.scripts.config."""
20+
"""Test invenio_base.scripts.config."""
2021

2122
import os
2223
import sys
23-
import mock
2424
import tempfile
2525

2626
from flask import current_app
27-
from invenio_base.wrappers import lazy_import
28-
from invenio.testsuite import make_test_suite, InvenioTestCase
2927

30-
config = lazy_import("invenio.base.scripts.config")
28+
from invenio.testsuite import InvenioTestCase
29+
30+
from invenio_base.scripts import config
31+
32+
import mock
3133

3234

3335
class TestConfig(InvenioTestCase):
@@ -138,6 +140,3 @@ def test_update_true_to_false(self):
138140
self.assertRegexpMatches(f.read(), "DEBUG\s*=\s*False")
139141

140142
sys.stdout = _stdout
141-
142-
143-
TEST_SUITE = make_test_suite(TestConfig)

0 commit comments

Comments
 (0)