Browse Source

changes after linting

pull/1/head
Holger Frey 5 years ago
parent
commit
fe31bb02ab
  1. 4
      superx_budget/helpers.py
  2. 2
      superx_budget/pyramid/__init__.py
  3. 10
      superx_budget/pyramid/security.py
  4. 14
      tests/test_superx_parser.py

4
superx_budget/helpers.py

@ -4,9 +4,7 @@ from pathlib import Path
import openpyxl import openpyxl
DEFAULT_RECIPIENTS = [ DEFAULT_RECIPIENTS = ["frey@imtek.de"]
"frey@imtek.de",
]
def excel_value_as_number(value): def excel_value_as_number(value):

2
superx_budget/pyramid/__init__.py

@ -34,7 +34,7 @@ def main(global_config, **settings):
config.set_root_factory(Root) config.set_root_factory(Root)
config.add_request_method( config.add_request_method(
lambda r: Path(settings["budgets.dir"]), "budgets_dir", reify=True, lambda r: Path(settings["budgets.dir"]), "budgets_dir", reify=True
) )
age = int(settings.get("static_views.cache_max_age", 0)) age = int(settings.get("static_views.cache_max_age", 0))

10
superx_budget/pyramid/security.py

@ -21,9 +21,7 @@ def get_user(request):
return request.unauthenticated_userid return request.unauthenticated_userid
@forbidden_view_config( @forbidden_view_config(renderer="superx_budget:pyramid/templates/login.jinja2")
renderer="superx_budget:pyramid/templates/login.jinja2",
)
def forbidden_view(request): def forbidden_view(request):
return {"error": False} return {"error": False}
@ -42,9 +40,7 @@ def login(request):
return {"error": True} return {"error": True}
@view_config( @view_config(context=Root, name="logout", permission="login")
context=Root, name="logout", permission="login",
)
def logout(request): def logout(request):
headers = forget(request) headers = forget(request)
return HTTPFound("/", headers=headers) return HTTPFound("/", headers=headers)
@ -53,7 +49,7 @@ def logout(request):
def includeme(config): def includeme(config):
settings = config.get_settings() settings = config.get_settings()
authn_policy = MyAuthenticationPolicy( authn_policy = MyAuthenticationPolicy(
settings["auth.secret"], hashalg="sha512", settings["auth.secret"], hashalg="sha512"
) )
config.set_authentication_policy(authn_policy) config.set_authentication_policy(authn_policy)
config.set_authorization_policy(ACLAuthorizationPolicy()) config.set_authorization_policy(ACLAuthorizationPolicy())

14
tests/test_superx_parser.py

@ -51,12 +51,7 @@ def test_get_export_metadata_raises_error(faulty_data):
def test_skip_export_data_until_table_header_ok(): def test_skip_export_data_until_table_header_ok():
from superx_budget.superx import _skip_export_data_until_table_header from superx_budget.superx import _skip_export_data_until_table_header
rows = [ rows = [[""], [""], ["Kostenstelle"], ["Daten"]]
[""],
[""],
["Kostenstelle"],
["Daten"],
]
iterator = iter(rows) iterator = iter(rows)
_skip_export_data_until_table_header(iterator) _skip_export_data_until_table_header(iterator)
data_line = next(iterator) data_line = next(iterator)
@ -68,12 +63,7 @@ def test_skip_export_data_until_table_header_raises_error():
from superx_budget.superx import _skip_export_data_until_table_header from superx_budget.superx import _skip_export_data_until_table_header
from superx_budget.exceptions import SuperXParserError from superx_budget.exceptions import SuperXParserError
rows = [ rows = [[""], [""], ["Keine Kostenstelle"], ["Daten"]]
[""],
[""],
["Keine Kostenstelle"],
["Daten"],
]
iterator = iter(rows) iterator = iter(rows)
with pytest.raises(SuperXParserError): with pytest.raises(SuperXParserError):
_skip_export_data_until_table_header(iterator) _skip_export_data_until_table_header(iterator)

Loading…
Cancel
Save