Compare commits
No commits in common. "2fcff6b2a4a1df07ef2e49dfb46cf4502fa58cce" and "ac65ec891b8169d07fc26fd6908e0e12dbd4a27f" have entirely different histories.
2fcff6b2a4
...
ac65ec891b
20 changed files with 43 additions and 76 deletions
|
@ -2,8 +2,4 @@
|
||||||
|
|
||||||
[MESSAGES CONTROL]
|
[MESSAGES CONTROL]
|
||||||
disable=all
|
disable=all
|
||||||
enable=dangerous-default-value,
|
enable=dangerous-default-value
|
||||||
inconsistent-return-statements,
|
|
||||||
redefined-argument-from-local,
|
|
||||||
unspecified-encoding,
|
|
||||||
unused-import,
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# WuttJamaican -- Base package for Wutta Framework
|
# WuttJamaican -- Base package for Wutta Framework
|
||||||
# Copyright © 2023-2025 Lance Edgar
|
# Copyright © 2023-2024 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Wutta Framework.
|
# This file is part of Wutta Framework.
|
||||||
#
|
#
|
||||||
|
@ -24,6 +24,7 @@
|
||||||
WuttJamaican - app handler
|
WuttJamaican - app handler
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import datetime
|
||||||
import importlib
|
import importlib
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
@ -229,7 +230,7 @@ class AppHandler:
|
||||||
|
|
||||||
If ``obj`` is *not* specified, this behaves a bit differently.
|
If ``obj`` is *not* specified, this behaves a bit differently.
|
||||||
It first will look for a :term:`config setting` named
|
It first will look for a :term:`config setting` named
|
||||||
``wutta.app_dist`` (or similar, depending on :attr:`appname`).
|
``wutta.app_dist`` (or similar, dpending on :attr:`appname`).
|
||||||
If there is such a config value, it is returned. Otherwise
|
If there is such a config value, it is returned. Otherwise
|
||||||
the "auto-locate" logic described above happens, but using
|
the "auto-locate" logic described above happens, but using
|
||||||
``self`` instead of ``obj``.
|
``self`` instead of ``obj``.
|
||||||
|
@ -280,7 +281,8 @@ class AppHandler:
|
||||||
return dist
|
return dist
|
||||||
|
|
||||||
# fall back to configured dist, if obj lookup failed
|
# fall back to configured dist, if obj lookup failed
|
||||||
return self.config.get(f'{self.appname}.app_dist')
|
if obj is not None:
|
||||||
|
return self.config.get(f'{self.appname}.app_dist')
|
||||||
|
|
||||||
def get_version(self, dist=None, obj=None):
|
def get_version(self, dist=None, obj=None):
|
||||||
"""
|
"""
|
||||||
|
@ -300,7 +302,6 @@ class AppHandler:
|
||||||
dist = self.get_distribution(obj=obj)
|
dist = self.get_distribution(obj=obj)
|
||||||
if dist:
|
if dist:
|
||||||
return version(dist)
|
return version(dist)
|
||||||
return None
|
|
||||||
|
|
||||||
def get_model(self):
|
def get_model(self):
|
||||||
"""
|
"""
|
||||||
|
@ -463,7 +464,7 @@ class AppHandler:
|
||||||
"""
|
"""
|
||||||
output = template.render(**context)
|
output = template.render(**context)
|
||||||
if output_path:
|
if output_path:
|
||||||
with open(output_path, 'wt', encoding='utf_8') as f:
|
with open(output_path, 'wt') as f:
|
||||||
f.write(output)
|
f.write(output)
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,6 @@ class AuthHandler(GenericHandler):
|
||||||
if user and user.active and user.password:
|
if user and user.active and user.password:
|
||||||
if self.check_user_password(user, password):
|
if self.check_user_password(user, password):
|
||||||
return user
|
return user
|
||||||
return None
|
|
||||||
|
|
||||||
def authenticate_user_token(self, session, token):
|
def authenticate_user_token(self, session, token):
|
||||||
"""
|
"""
|
||||||
|
@ -123,7 +122,6 @@ class AuthHandler(GenericHandler):
|
||||||
user = token.user
|
user = token.user
|
||||||
if user.active:
|
if user.active:
|
||||||
return user
|
return user
|
||||||
return None
|
|
||||||
|
|
||||||
def check_user_password(self, user, password, **kwargs):
|
def check_user_password(self, user, password, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
@ -160,7 +158,7 @@ class AuthHandler(GenericHandler):
|
||||||
model = self.app.model
|
model = self.app.model
|
||||||
|
|
||||||
if not key:
|
if not key:
|
||||||
return None
|
return
|
||||||
|
|
||||||
# maybe it is a uuid
|
# maybe it is a uuid
|
||||||
if isinstance(key, _uuid.UUID):
|
if isinstance(key, _uuid.UUID):
|
||||||
|
@ -190,7 +188,6 @@ class AuthHandler(GenericHandler):
|
||||||
session=session)
|
session=session)
|
||||||
if key:
|
if key:
|
||||||
return self.get_role(session, key)
|
return self.get_role(session, key)
|
||||||
return None
|
|
||||||
|
|
||||||
def get_user(self, obj, session=None, **kwargs):
|
def get_user(self, obj, session=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
@ -259,7 +256,6 @@ class AuthHandler(GenericHandler):
|
||||||
person = self.app.get_person(obj)
|
person = self.app.get_person(obj)
|
||||||
if person:
|
if person:
|
||||||
return person.user
|
return person.user
|
||||||
return None
|
|
||||||
|
|
||||||
def make_person(self, **kwargs):
|
def make_person(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# WuttJamaican -- Base package for Wutta Framework
|
# WuttJamaican -- Base package for Wutta Framework
|
||||||
# Copyright © 2023-2025 Lance Edgar
|
# Copyright © 2023-2024 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Wutta Framework.
|
# This file is part of Wutta Framework.
|
||||||
#
|
#
|
||||||
|
@ -25,6 +25,7 @@ WuttJamaican - app configuration
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import configparser
|
import configparser
|
||||||
|
import importlib
|
||||||
import logging
|
import logging
|
||||||
import logging.config
|
import logging.config
|
||||||
import os
|
import os
|
||||||
|
@ -273,7 +274,7 @@ class WuttaConfig:
|
||||||
# re-write as temp file with "final" values
|
# re-write as temp file with "final" values
|
||||||
fd, temp_path = tempfile.mkstemp(suffix='.ini')
|
fd, temp_path = tempfile.mkstemp(suffix='.ini')
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
with open(temp_path, 'wt', encoding='utf_8') as f:
|
with open(temp_path, 'wt') as f:
|
||||||
temp_config.write(f)
|
temp_config.write(f)
|
||||||
|
|
||||||
# and finally, load that into our main config
|
# and finally, load that into our main config
|
||||||
|
@ -285,14 +286,14 @@ class WuttaConfig:
|
||||||
# bring in any "required" files
|
# bring in any "required" files
|
||||||
requires = config.get(f'{self.appname}.config.require')
|
requires = config.get(f'{self.appname}.config.require')
|
||||||
if requires:
|
if requires:
|
||||||
for p in self.parse_list(requires):
|
for path in self.parse_list(requires):
|
||||||
self._load_ini_configs(p, configs, require=True)
|
self._load_ini_configs(path, configs, require=True)
|
||||||
|
|
||||||
# bring in any "included" files
|
# bring in any "included" files
|
||||||
includes = config.get(f'{self.appname}.config.include')
|
includes = config.get(f'{self.appname}.config.include')
|
||||||
if includes:
|
if includes:
|
||||||
for p in self.parse_list(includes):
|
for path in self.parse_list(includes):
|
||||||
self._load_ini_configs(p, configs, require=False)
|
self._load_ini_configs(path, configs, require=False)
|
||||||
|
|
||||||
def get_prioritized_files(self):
|
def get_prioritized_files(self):
|
||||||
"""
|
"""
|
||||||
|
@ -466,8 +467,6 @@ class WuttaConfig:
|
||||||
if default is not UNSPECIFIED:
|
if default is not UNSPECIFIED:
|
||||||
return default
|
return default
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
def get_from_db(self, key, session=None, **kwargs):
|
def get_from_db(self, key, session=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Retrieve a config value from database settings table.
|
Retrieve a config value from database settings table.
|
||||||
|
@ -512,7 +511,6 @@ class WuttaConfig:
|
||||||
value = self.get(*args, **kwargs)
|
value = self.get(*args, **kwargs)
|
||||||
if value is not None:
|
if value is not None:
|
||||||
return int(value)
|
return int(value)
|
||||||
return None
|
|
||||||
|
|
||||||
def get_list(self, *args, **kwargs):
|
def get_list(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
@ -527,7 +525,6 @@ class WuttaConfig:
|
||||||
value = self.get(*args, **kwargs)
|
value = self.get(*args, **kwargs)
|
||||||
if value is not None:
|
if value is not None:
|
||||||
return self.parse_list(value)
|
return self.parse_list(value)
|
||||||
return None
|
|
||||||
|
|
||||||
def get_dict(self, prefix):
|
def get_dict(self, prefix):
|
||||||
"""
|
"""
|
||||||
|
@ -614,7 +611,7 @@ class WuttaConfig:
|
||||||
# write INI file and return path
|
# write INI file and return path
|
||||||
fd, path = tempfile.mkstemp(suffix='.conf')
|
fd, path = tempfile.mkstemp(suffix='.conf')
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
with open(path, 'wt', encoding='utf_8') as f:
|
with open(path, 'wt') as f:
|
||||||
parser.write(f)
|
parser.write(f)
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ import sqlalchemy as sa
|
||||||
from sqlalchemy import orm
|
from sqlalchemy import orm
|
||||||
from sqlalchemy.ext.associationproxy import association_proxy
|
from sqlalchemy.ext.associationproxy import association_proxy
|
||||||
|
|
||||||
from . import Base, uuid_column, uuid_fk_column
|
from .base import Base, uuid_column, uuid_fk_column
|
||||||
|
|
||||||
|
|
||||||
class Role(Base):
|
class Role(Base):
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# WuttJamaican -- Base package for Wutta Framework
|
# WuttJamaican -- Base package for Wutta Framework
|
||||||
# Copyright © 2023-2025 Lance Edgar
|
# Copyright © 2023-2024 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Wutta Framework.
|
# This file is part of Wutta Framework.
|
||||||
#
|
#
|
||||||
|
@ -36,7 +36,8 @@ import sqlalchemy as sa
|
||||||
from sqlalchemy import orm
|
from sqlalchemy import orm
|
||||||
from sqlalchemy.ext.associationproxy import association_proxy
|
from sqlalchemy.ext.associationproxy import association_proxy
|
||||||
|
|
||||||
from wuttjamaican.db.util import naming_convention, ModelBase, uuid_column
|
from wuttjamaican.db.util import (naming_convention, ModelBase,
|
||||||
|
uuid_column, uuid_fk_column)
|
||||||
|
|
||||||
|
|
||||||
class WuttaModelBase(ModelBase):
|
class WuttaModelBase(ModelBase):
|
||||||
|
@ -214,4 +215,3 @@ class Person(Base):
|
||||||
|
|
||||||
if self.users:
|
if self.users:
|
||||||
return self.users[0]
|
return self.users[0]
|
||||||
return None
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# WuttJamaican -- Base package for Wutta Framework
|
# WuttJamaican -- Base package for Wutta Framework
|
||||||
# Copyright © 2023-2025 Lance Edgar
|
# Copyright © 2023-2024 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Wutta Framework.
|
# This file is part of Wutta Framework.
|
||||||
#
|
#
|
||||||
|
@ -31,7 +31,7 @@ from sqlalchemy import orm
|
||||||
from sqlalchemy.ext.declarative import declared_attr
|
from sqlalchemy.ext.declarative import declared_attr
|
||||||
from sqlalchemy.ext.orderinglist import ordering_list
|
from sqlalchemy.ext.orderinglist import ordering_list
|
||||||
|
|
||||||
from wuttjamaican.db.model import uuid_column, User
|
from wuttjamaican.db.model import uuid_column, uuid_fk_column, User
|
||||||
from wuttjamaican.db.util import UUID
|
from wuttjamaican.db.util import UUID
|
||||||
|
|
||||||
|
|
||||||
|
@ -263,7 +263,6 @@ class BatchMixin:
|
||||||
"""
|
"""
|
||||||
if self.id:
|
if self.id:
|
||||||
return f'{self.id:08d}'
|
return f'{self.id:08d}'
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
class BatchRowMixin:
|
class BatchRowMixin:
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# WuttJamaican -- Base package for Wutta Framework
|
# WuttJamaican -- Base package for Wutta Framework
|
||||||
# Copyright © 2023-2025 Lance Edgar
|
# Copyright © 2023-2024 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Wutta Framework.
|
# This file is part of Wutta Framework.
|
||||||
#
|
#
|
||||||
|
@ -29,7 +29,7 @@ import datetime
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from sqlalchemy import orm
|
from sqlalchemy import orm
|
||||||
|
|
||||||
from . import Base, uuid_column, uuid_fk_column
|
from .base import Base, uuid_column, uuid_fk_column
|
||||||
from wuttjamaican.enum import UpgradeStatus
|
from wuttjamaican.enum import UpgradeStatus
|
||||||
from wuttjamaican.db.util import UUID
|
from wuttjamaican.db.util import UUID
|
||||||
from wuttjamaican.util import make_true_uuid
|
from wuttjamaican.util import make_true_uuid
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# WuttJamaican -- Base package for Wutta Framework
|
# WuttJamaican -- Base package for Wutta Framework
|
||||||
# Copyright © 2023-2025 Lance Edgar
|
# Copyright © 2023-2024 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Wutta Framework.
|
# This file is part of Wutta Framework.
|
||||||
#
|
#
|
||||||
|
@ -66,7 +66,6 @@ class ModelBase:
|
||||||
state = sa.inspect(self)
|
state = sa.inspect(self)
|
||||||
if hasattr(state.attrs, key):
|
if hasattr(state.attrs, key):
|
||||||
return getattr(self, key)
|
return getattr(self, key)
|
||||||
raise KeyError(f"model instance has no attr with key: {key}")
|
|
||||||
|
|
||||||
|
|
||||||
class UUID(sa.types.TypeDecorator):
|
class UUID(sa.types.TypeDecorator):
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# WuttJamaican -- Base package for Wutta Framework
|
# WuttJamaican -- Base package for Wutta Framework
|
||||||
# Copyright © 2023-2025 Lance Edgar
|
# Copyright © 2023-2024 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Wutta Framework.
|
# This file is part of Wutta Framework.
|
||||||
#
|
#
|
||||||
|
@ -358,7 +358,6 @@ class EmailHandler(GenericHandler):
|
||||||
if instance:
|
if instance:
|
||||||
setting = setting(self.config)
|
setting = setting(self.config)
|
||||||
return setting
|
return setting
|
||||||
return None
|
|
||||||
|
|
||||||
def make_message(self, **kwargs):
|
def make_message(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
@ -574,7 +573,6 @@ class EmailHandler(GenericHandler):
|
||||||
if template:
|
if template:
|
||||||
context = context or {}
|
context = context or {}
|
||||||
return template.render(**context)
|
return template.render(**context)
|
||||||
return None
|
|
||||||
|
|
||||||
def get_auto_html_body(self, key, context=None):
|
def get_auto_html_body(self, key, context=None):
|
||||||
"""
|
"""
|
||||||
|
@ -587,7 +585,6 @@ class EmailHandler(GenericHandler):
|
||||||
if template:
|
if template:
|
||||||
context = context or {}
|
context = context or {}
|
||||||
return template.render(**context)
|
return template.render(**context)
|
||||||
return None
|
|
||||||
|
|
||||||
def get_auto_body_template(self, key, mode):
|
def get_auto_body_template(self, key, mode):
|
||||||
""" """
|
""" """
|
||||||
|
@ -604,7 +601,6 @@ class EmailHandler(GenericHandler):
|
||||||
return templates.get_template(f'{key}.{mode}.mako')
|
return templates.get_template(f'{key}.{mode}.mako')
|
||||||
except TopLevelLookupException:
|
except TopLevelLookupException:
|
||||||
pass
|
pass
|
||||||
return None
|
|
||||||
|
|
||||||
def get_notes(self, key):
|
def get_notes(self, key):
|
||||||
"""
|
"""
|
||||||
|
@ -656,8 +652,8 @@ class EmailHandler(GenericHandler):
|
||||||
|
|
||||||
:returns: True if this email type is enabled, otherwise false.
|
:returns: True if this email type is enabled, otherwise false.
|
||||||
"""
|
"""
|
||||||
for k in set([key, 'default']):
|
for key in set([key, 'default']):
|
||||||
enabled = self.config.get_bool(f'{self.config.appname}.email.{k}.enabled')
|
enabled = self.config.get_bool(f'{self.config.appname}.email.{key}.enabled')
|
||||||
if enabled is not None:
|
if enabled is not None:
|
||||||
return enabled
|
return enabled
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# WuttJamaican -- Base package for Wutta Framework
|
# WuttJamaican -- Base package for Wutta Framework
|
||||||
# Copyright © 2023-2025 Lance Edgar
|
# Copyright © 2023-2024 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Wutta Framework.
|
# This file is part of Wutta Framework.
|
||||||
#
|
#
|
||||||
|
@ -25,6 +25,7 @@ Install Handler
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import stat
|
import stat
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
@ -254,7 +255,6 @@ class InstallHandler(GenericHandler):
|
||||||
sa.inspect(engine).has_table('whatever')
|
sa.inspect(engine).has_table('whatever')
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
return str(error)
|
return str(error)
|
||||||
return None
|
|
||||||
|
|
||||||
def make_template_context(self, dbinfo, **kwargs):
|
def make_template_context(self, dbinfo, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# WuttJamaican -- Base package for Wutta Framework
|
# WuttJamaican -- Base package for Wutta Framework
|
||||||
# Copyright © 2023-2025 Lance Edgar
|
# Copyright © 2023-2024 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Wutta Framework.
|
# This file is part of Wutta Framework.
|
||||||
#
|
#
|
||||||
|
@ -88,5 +88,3 @@ class PeopleHandler(GenericHandler):
|
||||||
user = obj
|
user = obj
|
||||||
if user.person:
|
if user.person:
|
||||||
return user.person
|
return user.person
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
|
@ -308,14 +308,14 @@ class ProblemHandler(GenericHandler):
|
||||||
if not self.is_enabled(check):
|
if not self.is_enabled(check):
|
||||||
log.debug("problem check is not enabled: %s", key)
|
log.debug("problem check is not enabled: %s", key)
|
||||||
if not force:
|
if not force:
|
||||||
return None
|
return
|
||||||
|
|
||||||
weekday = datetime.date.today().weekday()
|
weekday = datetime.date.today().weekday()
|
||||||
if not self.should_run_for_weekday(check, weekday):
|
if not self.should_run_for_weekday(check, weekday):
|
||||||
log.debug("problem check is not scheduled for %s: %s",
|
log.debug("problem check is not scheduled for %s: %s",
|
||||||
calendar.day_name[weekday], key)
|
calendar.day_name[weekday], key)
|
||||||
if not force:
|
if not force:
|
||||||
return None
|
return
|
||||||
|
|
||||||
check_instance = check(self.config)
|
check_instance = check(self.config)
|
||||||
problems = self.find_problems(check_instance)
|
problems = self.find_problems(check_instance)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# WuttJamaican -- Base package for Wutta Framework
|
# WuttJamaican -- Base package for Wutta Framework
|
||||||
# Copyright © 2023-2025 Lance Edgar
|
# Copyright © 2023-2024 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Wutta Framework.
|
# This file is part of Wutta Framework.
|
||||||
#
|
#
|
||||||
|
@ -196,7 +196,6 @@ class ReportHandler(GenericHandler):
|
||||||
if instance:
|
if instance:
|
||||||
report = report(self.config)
|
report = report(self.config)
|
||||||
return report
|
return report
|
||||||
return None
|
|
||||||
|
|
||||||
def make_report_data(self, report, params=None, progress=None, **kwargs):
|
def make_report_data(self, report, params=None, progress=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -95,7 +95,7 @@ class FileTestCase(TestCase):
|
||||||
myconf = self.write_file('my.conf', '<file contents>')
|
myconf = self.write_file('my.conf', '<file contents>')
|
||||||
"""
|
"""
|
||||||
path = os.path.join(self.tempdir, filename)
|
path = os.path.join(self.tempdir, filename)
|
||||||
with open(path, 'wt', encoding='utf_8') as f:
|
with open(path, 'wt') as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# WuttJamaican -- Base package for Wutta Framework
|
# WuttJamaican -- Base package for Wutta Framework
|
||||||
# Copyright © 2023-2025 Lance Edgar
|
# Copyright © 2023-2024 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Wutta Framework.
|
# This file is part of Wutta Framework.
|
||||||
#
|
#
|
||||||
|
@ -256,11 +256,11 @@ def parse_list(value):
|
||||||
parser.whitespace += ','
|
parser.whitespace += ','
|
||||||
parser.whitespace_split = True
|
parser.whitespace_split = True
|
||||||
values = list(parser)
|
values = list(parser)
|
||||||
for i, val in enumerate(values):
|
for i, value in enumerate(values):
|
||||||
if val.startswith('"') and val.endswith('"'):
|
if value.startswith('"') and value.endswith('"'):
|
||||||
values[i] = val[1:-1]
|
values[i] = value[1:-1]
|
||||||
elif val.startswith("'") and val.endswith("'"):
|
elif value.startswith("'") and value.endswith("'"):
|
||||||
values[i] = val[1:-1]
|
values[i] = value[1:-1]
|
||||||
return values
|
return values
|
||||||
|
|
||||||
|
|
||||||
|
@ -354,8 +354,8 @@ def resource_path(path):
|
||||||
|
|
||||||
package, filename = path.split(':')
|
package, filename = path.split(':')
|
||||||
ref = files(package) / filename
|
ref = files(package) / filename
|
||||||
with as_file(ref) as p:
|
with as_file(ref) as path:
|
||||||
return str(p)
|
return str(path)
|
||||||
|
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,6 @@ else:
|
||||||
batch = MyBatch(id=42, uuid=_uuid.UUID('0675cdac-ffc9-7690-8000-6023de1c8cfd'))
|
batch = MyBatch(id=42, uuid=_uuid.UUID('0675cdac-ffc9-7690-8000-6023de1c8cfd'))
|
||||||
self.assertEqual(repr(batch), "MyBatch(uuid=UUID('0675cdac-ffc9-7690-8000-6023de1c8cfd'))")
|
self.assertEqual(repr(batch), "MyBatch(uuid=UUID('0675cdac-ffc9-7690-8000-6023de1c8cfd'))")
|
||||||
self.assertEqual(str(batch), "00000042")
|
self.assertEqual(str(batch), "00000042")
|
||||||
self.assertEqual(batch.id_str, "00000042")
|
|
||||||
|
|
||||||
batch2 = MyBatch()
|
|
||||||
self.assertIsNone(batch2.id_str)
|
|
||||||
|
|
||||||
|
|
||||||
class TestBatchRowMixin(DataTestCase):
|
class TestBatchRowMixin(DataTestCase):
|
||||||
|
|
|
@ -22,11 +22,9 @@ else:
|
||||||
def test_dict_behavior(self):
|
def test_dict_behavior(self):
|
||||||
setting = Setting()
|
setting = Setting()
|
||||||
self.assertEqual(list(iter(setting)), [('name', None), ('value', None)])
|
self.assertEqual(list(iter(setting)), [('name', None), ('value', None)])
|
||||||
self.assertIsNone(setting.name)
|
|
||||||
self.assertIsNone(setting['name'])
|
self.assertIsNone(setting['name'])
|
||||||
setting.name = 'foo'
|
setting.name = 'foo'
|
||||||
self.assertEqual(setting['name'], 'foo')
|
self.assertEqual(setting['name'], 'foo')
|
||||||
self.assertRaises(KeyError, lambda: setting['notfound'])
|
|
||||||
|
|
||||||
|
|
||||||
class TestUUID(TestCase):
|
class TestUUID(TestCase):
|
||||||
|
|
|
@ -375,10 +375,6 @@ app_title = WuttaTest
|
||||||
ver = self.app.get_version(obj=query)
|
ver = self.app.get_version(obj=query)
|
||||||
self.assertEqual(ver, version('SQLAlchemy'))
|
self.assertEqual(ver, version('SQLAlchemy'))
|
||||||
|
|
||||||
# random object will not yield a dist nor version
|
|
||||||
ver = self.app.get_version(obj=42)
|
|
||||||
self.assertIsNone(ver)
|
|
||||||
|
|
||||||
# can override dist via config
|
# can override dist via config
|
||||||
self.config.setdefault('wuttatest.app_dist', 'python-configuration')
|
self.config.setdefault('wuttatest.app_dist', 'python-configuration')
|
||||||
ver = self.app.get_version()
|
ver = self.app.get_version()
|
||||||
|
|
|
@ -94,10 +94,6 @@ class TestReportHandler(ConfigTestCase):
|
||||||
self.assertTrue(issubclass(report, mod.Report))
|
self.assertTrue(issubclass(report, mod.Report))
|
||||||
self.assertIs(report, MockFooReport)
|
self.assertIs(report, MockFooReport)
|
||||||
|
|
||||||
# not found
|
|
||||||
report = handler.get_report('unknown')
|
|
||||||
self.assertIsNone(report)
|
|
||||||
|
|
||||||
def test_make_report_data(self):
|
def test_make_report_data(self):
|
||||||
providers = {
|
providers = {
|
||||||
'wuttatest': MagicMock(report_modules=['tests.test_reports']),
|
'wuttatest': MagicMock(report_modules=['tests.test_reports']),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue