server/general: rename 'misc' to 'util'
This commit is contained in:
parent
57b18c6461
commit
a926838b90
19 changed files with 48 additions and 48 deletions
|
@ -1,6 +1,6 @@
|
||||||
import re
|
import re
|
||||||
from szurubooru import config, db, errors
|
from szurubooru import config, db, errors
|
||||||
from szurubooru.func import misc
|
from szurubooru.func import util
|
||||||
|
|
||||||
class TagCategoryNotFoundError(errors.NotFoundError): pass
|
class TagCategoryNotFoundError(errors.NotFoundError): pass
|
||||||
class TagCategoryAlreadyExistsError(errors.ValidationError): pass
|
class TagCategoryAlreadyExistsError(errors.ValidationError): pass
|
||||||
|
@ -30,7 +30,7 @@ def update_name(category, name):
|
||||||
if already_exists:
|
if already_exists:
|
||||||
raise TagCategoryAlreadyExistsError(
|
raise TagCategoryAlreadyExistsError(
|
||||||
'A category with this name already exists.')
|
'A category with this name already exists.')
|
||||||
if misc.value_exceeds_column_size(name, db.TagCategory.name):
|
if util.value_exceeds_column_size(name, db.TagCategory.name):
|
||||||
raise InvalidTagCategoryNameError('Name is too long.')
|
raise InvalidTagCategoryNameError('Name is too long.')
|
||||||
_verify_name_validity(name)
|
_verify_name_validity(name)
|
||||||
category.name = name
|
category.name = name
|
||||||
|
@ -38,7 +38,7 @@ def update_name(category, name):
|
||||||
def update_color(category, color):
|
def update_color(category, color):
|
||||||
if not color:
|
if not color:
|
||||||
raise InvalidTagCategoryNameError('Color cannot be empty.')
|
raise InvalidTagCategoryNameError('Color cannot be empty.')
|
||||||
if misc.value_exceeds_column_size(color, db.TagCategory.color):
|
if util.value_exceeds_column_size(color, db.TagCategory.color):
|
||||||
raise InvalidTagCategoryColorError('Color is too long.')
|
raise InvalidTagCategoryColorError('Color is too long.')
|
||||||
category.color = color
|
category.color = color
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import os
|
||||||
import re
|
import re
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from szurubooru import config, db, errors
|
from szurubooru import config, db, errors
|
||||||
from szurubooru.func import misc, tag_categories
|
from szurubooru.func import util, tag_categories
|
||||||
|
|
||||||
class TagNotFoundError(errors.NotFoundError): pass
|
class TagNotFoundError(errors.NotFoundError): pass
|
||||||
class TagAlreadyExistsError(errors.ValidationError): pass
|
class TagAlreadyExistsError(errors.ValidationError): pass
|
||||||
|
@ -68,7 +68,7 @@ def get_tag_by_name(name):
|
||||||
.first()
|
.first()
|
||||||
|
|
||||||
def get_tags_by_names(names):
|
def get_tags_by_names(names):
|
||||||
names = misc.icase_unique(names)
|
names = util.icase_unique(names)
|
||||||
if len(names) == 0:
|
if len(names) == 0:
|
||||||
return []
|
return []
|
||||||
expr = sqlalchemy.sql.false()
|
expr = sqlalchemy.sql.false()
|
||||||
|
@ -77,7 +77,7 @@ def get_tags_by_names(names):
|
||||||
return db.session.query(db.Tag).join(db.TagName).filter(expr).all()
|
return db.session.query(db.Tag).join(db.TagName).filter(expr).all()
|
||||||
|
|
||||||
def get_or_create_tags_by_names(names):
|
def get_or_create_tags_by_names(names):
|
||||||
names = misc.icase_unique(names)
|
names = util.icase_unique(names)
|
||||||
for name in names:
|
for name in names:
|
||||||
_verify_name_validity(name)
|
_verify_name_validity(name)
|
||||||
related_tags = get_tags_by_names(names)
|
related_tags = get_tags_by_names(names)
|
||||||
|
@ -120,14 +120,14 @@ def update_category_name(tag, category_name):
|
||||||
tag.category = category
|
tag.category = category
|
||||||
|
|
||||||
def update_names(tag, names):
|
def update_names(tag, names):
|
||||||
names = misc.icase_unique([name for name in names if name])
|
names = util.icase_unique([name for name in names if name])
|
||||||
if not len(names):
|
if not len(names):
|
||||||
raise InvalidTagNameError('At least one name must be specified.')
|
raise InvalidTagNameError('At least one name must be specified.')
|
||||||
for name in names:
|
for name in names:
|
||||||
_verify_name_validity(name)
|
_verify_name_validity(name)
|
||||||
expr = sqlalchemy.sql.false()
|
expr = sqlalchemy.sql.false()
|
||||||
for name in names:
|
for name in names:
|
||||||
if misc.value_exceeds_column_size(name, db.TagName.name):
|
if util.value_exceeds_column_size(name, db.TagName.name):
|
||||||
raise InvalidTagNameError('Name is too long.')
|
raise InvalidTagNameError('Name is too long.')
|
||||||
expr = expr | db.TagName.name.ilike(name)
|
expr = expr | db.TagName.name.ilike(name)
|
||||||
if tag.tag_id:
|
if tag.tag_id:
|
||||||
|
|
|
@ -2,7 +2,7 @@ import datetime
|
||||||
import re
|
import re
|
||||||
from sqlalchemy import func
|
from sqlalchemy import func
|
||||||
from szurubooru import config, db, errors
|
from szurubooru import config, db, errors
|
||||||
from szurubooru.func import auth, misc, files, images
|
from szurubooru.func import auth, util, files, images
|
||||||
|
|
||||||
class UserNotFoundError(errors.NotFoundError): pass
|
class UserNotFoundError(errors.NotFoundError): pass
|
||||||
class UserAlreadyExistsError(errors.ValidationError): pass
|
class UserAlreadyExistsError(errors.ValidationError): pass
|
||||||
|
@ -45,7 +45,7 @@ def create_user(name, password, email, auth_user):
|
||||||
def update_name(user, name, auth_user):
|
def update_name(user, name, auth_user):
|
||||||
if not name:
|
if not name:
|
||||||
raise InvalidUserNameError('Name cannot be empty.')
|
raise InvalidUserNameError('Name cannot be empty.')
|
||||||
if misc.value_exceeds_column_size(name, db.User.name):
|
if util.value_exceeds_column_size(name, db.User.name):
|
||||||
raise InvalidUserNameError('User name is too long.')
|
raise InvalidUserNameError('User name is too long.')
|
||||||
other_user = get_user_by_name(name)
|
other_user = get_user_by_name(name)
|
||||||
if other_user and other_user.user_id != auth_user.user_id:
|
if other_user and other_user.user_id != auth_user.user_id:
|
||||||
|
@ -72,9 +72,9 @@ def update_email(user, email):
|
||||||
email = email.strip()
|
email = email.strip()
|
||||||
if not email:
|
if not email:
|
||||||
email = None
|
email = None
|
||||||
if email and misc.value_exceeds_column_size(email, db.User.email):
|
if email and util.value_exceeds_column_size(email, db.User.email):
|
||||||
raise InvalidEmailError('Email is too long.')
|
raise InvalidEmailError('Email is too long.')
|
||||||
if not misc.is_valid_email(email):
|
if not util.is_valid_email(email):
|
||||||
raise InvalidEmailError('E-mail is invalid.')
|
raise InvalidEmailError('E-mail is invalid.')
|
||||||
user.email = email
|
user.email = email
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
import szurubooru.errors
|
import szurubooru.errors
|
||||||
from szurubooru.func import misc
|
from szurubooru.func import util
|
||||||
from szurubooru.search import criteria
|
from szurubooru.search import criteria
|
||||||
|
|
||||||
class BaseSearchConfig(object):
|
class BaseSearchConfig(object):
|
||||||
|
@ -82,24 +82,24 @@ class BaseSearchConfig(object):
|
||||||
Parse the datetime inside the criterion.
|
Parse the datetime inside the criterion.
|
||||||
'''
|
'''
|
||||||
if isinstance(criterion, criteria.PlainSearchCriterion):
|
if isinstance(criterion, criteria.PlainSearchCriterion):
|
||||||
min_date, max_date = misc.parse_time_range(criterion.value)
|
min_date, max_date = util.parse_time_range(criterion.value)
|
||||||
expr = column.between(min_date, max_date)
|
expr = column.between(min_date, max_date)
|
||||||
elif isinstance(criterion, criteria.ArraySearchCriterion):
|
elif isinstance(criterion, criteria.ArraySearchCriterion):
|
||||||
expr = sqlalchemy.sql.false()
|
expr = sqlalchemy.sql.false()
|
||||||
for value in criterion.values:
|
for value in criterion.values:
|
||||||
min_date, max_date = misc.parse_time_range(value)
|
min_date, max_date = util.parse_time_range(value)
|
||||||
expr = expr | column.between(min_date, max_date)
|
expr = expr | column.between(min_date, max_date)
|
||||||
elif isinstance(criterion, criteria.RangedSearchCriterion):
|
elif isinstance(criterion, criteria.RangedSearchCriterion):
|
||||||
assert criterion.min_value or criterion.max_value
|
assert criterion.min_value or criterion.max_value
|
||||||
if criterion.min_value and criterion.max_value:
|
if criterion.min_value and criterion.max_value:
|
||||||
min_date = misc.parse_time_range(criterion.min_value)[0]
|
min_date = util.parse_time_range(criterion.min_value)[0]
|
||||||
max_date = misc.parse_time_range(criterion.max_value)[1]
|
max_date = util.parse_time_range(criterion.max_value)[1]
|
||||||
expr = column.between(min_date, max_date)
|
expr = column.between(min_date, max_date)
|
||||||
elif criterion.min_value:
|
elif criterion.min_value:
|
||||||
min_date = misc.parse_time_range(criterion.min_value)[0]
|
min_date = util.parse_time_range(criterion.min_value)[0]
|
||||||
expr = column >= min_date
|
expr = column >= min_date
|
||||||
elif criterion.max_value:
|
elif criterion.max_value:
|
||||||
max_date = misc.parse_time_range(criterion.max_value)[1]
|
max_date = util.parse_time_range(criterion.max_value)[1]
|
||||||
expr = column <= max_date
|
expr = column <= max_date
|
||||||
else:
|
else:
|
||||||
assert False
|
assert False
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
from szurubooru import api, config, db, errors
|
from szurubooru import api, config, db, errors
|
||||||
from szurubooru.func import misc, tag_categories
|
from szurubooru.func import util, tag_categories
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def test_ctx(tmpdir, config_injector, context_factory, user_factory):
|
def test_ctx(tmpdir, config_injector, context_factory, user_factory):
|
||||||
|
@ -11,7 +11,7 @@ def test_ctx(tmpdir, config_injector, context_factory, user_factory):
|
||||||
'ranks': ['anonymous', 'regular_user'],
|
'ranks': ['anonymous', 'regular_user'],
|
||||||
'privileges': {'tag_categories:create': 'regular_user'},
|
'privileges': {'tag_categories:create': 'regular_user'},
|
||||||
})
|
})
|
||||||
ret = misc.dotdict()
|
ret = util.dotdict()
|
||||||
ret.context_factory = context_factory
|
ret.context_factory = context_factory
|
||||||
ret.user_factory = user_factory
|
ret.user_factory = user_factory
|
||||||
ret.api = api.TagCategoryListApi()
|
ret.api = api.TagCategoryListApi()
|
||||||
|
|
|
@ -2,7 +2,7 @@ import pytest
|
||||||
import os
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from szurubooru import api, config, db, errors
|
from szurubooru import api, config, db, errors
|
||||||
from szurubooru.func import misc, tags, tag_categories
|
from szurubooru.func import util, tags, tag_categories
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def test_ctx(
|
def test_ctx(
|
||||||
|
@ -19,7 +19,7 @@ def test_ctx(
|
||||||
},
|
},
|
||||||
'ranks': ['anonymous', 'regular_user'],
|
'ranks': ['anonymous', 'regular_user'],
|
||||||
})
|
})
|
||||||
ret = misc.dotdict()
|
ret = util.dotdict()
|
||||||
ret.context_factory = context_factory
|
ret.context_factory = context_factory
|
||||||
ret.user_factory = user_factory
|
ret.user_factory = user_factory
|
||||||
ret.tag_factory = tag_factory
|
ret.tag_factory = tag_factory
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import datetime
|
import datetime
|
||||||
import pytest
|
import pytest
|
||||||
from szurubooru import api, db, errors
|
from szurubooru import api, db, errors
|
||||||
from szurubooru.func import misc, tag_categories
|
from szurubooru.func import util, tag_categories
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def test_ctx(
|
def test_ctx(
|
||||||
|
@ -15,7 +15,7 @@ def test_ctx(
|
||||||
'ranks': ['anonymous', 'regular_user', 'mod', 'admin'],
|
'ranks': ['anonymous', 'regular_user', 'mod', 'admin'],
|
||||||
'rank_names': {'regular_user': 'Peasant'},
|
'rank_names': {'regular_user': 'Peasant'},
|
||||||
})
|
})
|
||||||
ret = misc.dotdict()
|
ret = util.dotdict()
|
||||||
ret.context_factory = context_factory
|
ret.context_factory = context_factory
|
||||||
ret.user_factory = user_factory
|
ret.user_factory = user_factory
|
||||||
ret.tag_category_factory = tag_category_factory
|
ret.tag_category_factory = tag_category_factory
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
from szurubooru import api, config, db, errors
|
from szurubooru import api, config, db, errors
|
||||||
from szurubooru.func import misc, tag_categories
|
from szurubooru.func import util, tag_categories
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def test_ctx(
|
def test_ctx(
|
||||||
|
@ -19,7 +19,7 @@ def test_ctx(
|
||||||
'tag_categories:edit:color': 'regular_user',
|
'tag_categories:edit:color': 'regular_user',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
ret = misc.dotdict()
|
ret = util.dotdict()
|
||||||
ret.context_factory = context_factory
|
ret.context_factory = context_factory
|
||||||
ret.user_factory = user_factory
|
ret.user_factory = user_factory
|
||||||
ret.tag_category_factory = tag_category_factory
|
ret.tag_category_factory = tag_category_factory
|
||||||
|
|
|
@ -2,7 +2,7 @@ import datetime
|
||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
from szurubooru import api, config, db, errors
|
from szurubooru import api, config, db, errors
|
||||||
from szurubooru.func import misc, tags
|
from szurubooru.func import util, tags
|
||||||
|
|
||||||
def get_tag(name):
|
def get_tag(name):
|
||||||
return db.session \
|
return db.session \
|
||||||
|
@ -27,7 +27,7 @@ def test_ctx(
|
||||||
db.session.add_all([
|
db.session.add_all([
|
||||||
db.TagCategory(name) for name in ['meta', 'character', 'copyright']])
|
db.TagCategory(name) for name in ['meta', 'character', 'copyright']])
|
||||||
db.session.flush()
|
db.session.flush()
|
||||||
ret = misc.dotdict()
|
ret = util.dotdict()
|
||||||
ret.context_factory = context_factory
|
ret.context_factory = context_factory
|
||||||
ret.user_factory = user_factory
|
ret.user_factory = user_factory
|
||||||
ret.tag_factory = tag_factory
|
ret.tag_factory = tag_factory
|
||||||
|
|
|
@ -2,7 +2,7 @@ import pytest
|
||||||
import os
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from szurubooru import api, config, db, errors
|
from szurubooru import api, config, db, errors
|
||||||
from szurubooru.func import misc, tags
|
from szurubooru.func import util, tags
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def test_ctx(
|
def test_ctx(
|
||||||
|
@ -14,7 +14,7 @@ def test_ctx(
|
||||||
},
|
},
|
||||||
'ranks': ['anonymous', 'regular_user'],
|
'ranks': ['anonymous', 'regular_user'],
|
||||||
})
|
})
|
||||||
ret = misc.dotdict()
|
ret = util.dotdict()
|
||||||
ret.context_factory = context_factory
|
ret.context_factory = context_factory
|
||||||
ret.user_factory = user_factory
|
ret.user_factory = user_factory
|
||||||
ret.tag_factory = tag_factory
|
ret.tag_factory = tag_factory
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import datetime
|
import datetime
|
||||||
import pytest
|
import pytest
|
||||||
from szurubooru import api, db, errors
|
from szurubooru import api, db, errors
|
||||||
from szurubooru.func import misc, tags
|
from szurubooru.func import util, tags
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def test_ctx(context_factory, config_injector, user_factory, tag_factory):
|
def test_ctx(context_factory, config_injector, user_factory, tag_factory):
|
||||||
|
@ -14,7 +14,7 @@ def test_ctx(context_factory, config_injector, user_factory, tag_factory):
|
||||||
'ranks': ['anonymous', 'regular_user', 'mod', 'admin'],
|
'ranks': ['anonymous', 'regular_user', 'mod', 'admin'],
|
||||||
'rank_names': {'regular_user': 'Peasant'},
|
'rank_names': {'regular_user': 'Peasant'},
|
||||||
})
|
})
|
||||||
ret = misc.dotdict()
|
ret = util.dotdict()
|
||||||
ret.context_factory = context_factory
|
ret.context_factory = context_factory
|
||||||
ret.user_factory = user_factory
|
ret.user_factory = user_factory
|
||||||
ret.tag_factory = tag_factory
|
ret.tag_factory = tag_factory
|
||||||
|
|
|
@ -2,7 +2,7 @@ import datetime
|
||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
from szurubooru import api, config, db, errors
|
from szurubooru import api, config, db, errors
|
||||||
from szurubooru.func import misc, tags
|
from szurubooru.func import util, tags
|
||||||
|
|
||||||
def get_tag(name):
|
def get_tag(name):
|
||||||
return db.session \
|
return db.session \
|
||||||
|
@ -32,7 +32,7 @@ def test_ctx(
|
||||||
db.session.add_all([
|
db.session.add_all([
|
||||||
db.TagCategory(name) for name in ['meta', 'character', 'copyright']])
|
db.TagCategory(name) for name in ['meta', 'character', 'copyright']])
|
||||||
db.session.flush()
|
db.session.flush()
|
||||||
ret = misc.dotdict()
|
ret = util.dotdict()
|
||||||
ret.context_factory = context_factory
|
ret.context_factory = context_factory
|
||||||
ret.user_factory = user_factory
|
ret.user_factory = user_factory
|
||||||
ret.tag_factory = tag_factory
|
ret.tag_factory = tag_factory
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import datetime
|
import datetime
|
||||||
import pytest
|
import pytest
|
||||||
from szurubooru import api, config, db, errors
|
from szurubooru import api, config, db, errors
|
||||||
from szurubooru.func import auth, misc, users
|
from szurubooru.func import auth, util, users
|
||||||
|
|
||||||
EMPTY_PIXEL = \
|
EMPTY_PIXEL = \
|
||||||
b'\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x01\x00\x00\x00\x00' \
|
b'\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x01\x00\x00\x00\x00' \
|
||||||
|
@ -23,7 +23,7 @@ def test_ctx(config_injector, context_factory, user_factory):
|
||||||
'rank_names': {},
|
'rank_names': {},
|
||||||
'privileges': {'users:create': 'anonymous'},
|
'privileges': {'users:create': 'anonymous'},
|
||||||
})
|
})
|
||||||
ret = misc.dotdict()
|
ret = util.dotdict()
|
||||||
ret.context_factory = context_factory
|
ret.context_factory = context_factory
|
||||||
ret.user_factory = user_factory
|
ret.user_factory = user_factory
|
||||||
ret.api = api.UserListApi()
|
ret.api = api.UserListApi()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import pytest
|
import pytest
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from szurubooru import api, db, errors
|
from szurubooru import api, db, errors
|
||||||
from szurubooru.func import misc, users
|
from szurubooru.func import util, users
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def test_ctx(config_injector, context_factory, user_factory):
|
def test_ctx(config_injector, context_factory, user_factory):
|
||||||
|
@ -12,7 +12,7 @@ def test_ctx(config_injector, context_factory, user_factory):
|
||||||
},
|
},
|
||||||
'ranks': ['anonymous', 'regular_user', 'mod', 'admin'],
|
'ranks': ['anonymous', 'regular_user', 'mod', 'admin'],
|
||||||
})
|
})
|
||||||
ret = misc.dotdict()
|
ret = util.dotdict()
|
||||||
ret.context_factory = context_factory
|
ret.context_factory = context_factory
|
||||||
ret.user_factory = user_factory
|
ret.user_factory = user_factory
|
||||||
ret.api = api.UserDetailApi()
|
ret.api = api.UserDetailApi()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import datetime
|
import datetime
|
||||||
import pytest
|
import pytest
|
||||||
from szurubooru import api, db, errors
|
from szurubooru import api, db, errors
|
||||||
from szurubooru.func import misc, users
|
from szurubooru.func import util, users
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def test_ctx(context_factory, config_injector, user_factory):
|
def test_ctx(context_factory, config_injector, user_factory):
|
||||||
|
@ -14,7 +14,7 @@ def test_ctx(context_factory, config_injector, user_factory):
|
||||||
'ranks': ['anonymous', 'regular_user', 'mod', 'admin'],
|
'ranks': ['anonymous', 'regular_user', 'mod', 'admin'],
|
||||||
'rank_names': {'regular_user': 'Peasant'},
|
'rank_names': {'regular_user': 'Peasant'},
|
||||||
})
|
})
|
||||||
ret = misc.dotdict()
|
ret = util.dotdict()
|
||||||
ret.context_factory = context_factory
|
ret.context_factory = context_factory
|
||||||
ret.user_factory = user_factory
|
ret.user_factory = user_factory
|
||||||
ret.list_api = api.UserListApi()
|
ret.list_api = api.UserListApi()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import datetime
|
import datetime
|
||||||
import pytest
|
import pytest
|
||||||
from szurubooru import api, config, db, errors
|
from szurubooru import api, config, db, errors
|
||||||
from szurubooru.func import auth, misc, users
|
from szurubooru.func import auth, util, users
|
||||||
|
|
||||||
EMPTY_PIXEL = \
|
EMPTY_PIXEL = \
|
||||||
b'\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x01\x00\x00\x00\x00' \
|
b'\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x01\x00\x00\x00\x00' \
|
||||||
|
@ -33,7 +33,7 @@ def test_ctx(config_injector, context_factory, user_factory):
|
||||||
'users:edit:any:avatar': 'admin',
|
'users:edit:any:avatar': 'admin',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
ret = misc.dotdict()
|
ret = util.dotdict()
|
||||||
ret.context_factory = context_factory
|
ret.context_factory = context_factory
|
||||||
ret.user_factory = user_factory
|
ret.user_factory = user_factory
|
||||||
ret.api = api.UserDetailApi()
|
ret.api = api.UserDetailApi()
|
||||||
|
|
|
@ -5,7 +5,7 @@ import pytest
|
||||||
import freezegun
|
import freezegun
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from szurubooru import api, config, db
|
from szurubooru import api, config, db
|
||||||
from szurubooru.func import misc
|
from szurubooru.func import util
|
||||||
|
|
||||||
class QueryCounter(object):
|
class QueryCounter(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import pytest
|
import pytest
|
||||||
from szurubooru import errors
|
from szurubooru import errors
|
||||||
from szurubooru.func import misc
|
from szurubooru.func import util
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
dt = datetime
|
dt = datetime
|
||||||
|
|
||||||
def test_parsing_empty_date_time():
|
def test_parsing_empty_date_time():
|
||||||
with pytest.raises(errors.ValidationError):
|
with pytest.raises(errors.ValidationError):
|
||||||
misc.parse_time_range('')
|
util.parse_time_range('')
|
||||||
|
|
||||||
@pytest.mark.parametrize('input,output', [
|
@pytest.mark.parametrize('input,output', [
|
||||||
('today', (dt(1997, 1, 2, 0, 0, 0), dt(1997, 1, 2, 23, 59, 59))),
|
('today', (dt(1997, 1, 2, 0, 0, 0), dt(1997, 1, 2, 23, 59, 59))),
|
||||||
|
@ -22,7 +22,7 @@ def test_parsing_empty_date_time():
|
||||||
])
|
])
|
||||||
def test_parsing_date_time(fake_datetime, input, output):
|
def test_parsing_date_time(fake_datetime, input, output):
|
||||||
with fake_datetime('1997-01-02 03:04:05'):
|
with fake_datetime('1997-01-02 03:04:05'):
|
||||||
assert misc.parse_time_range(input) == output
|
assert util.parse_time_range(input) == output
|
||||||
|
|
||||||
@pytest.mark.parametrize('input,output', [
|
@pytest.mark.parametrize('input,output', [
|
||||||
([], []),
|
([], []),
|
||||||
|
@ -33,4 +33,4 @@ def test_parsing_date_time(fake_datetime, input, output):
|
||||||
(['a', 'A', 'b', 'B'], ['a', 'b']),
|
(['a', 'A', 'b', 'B'], ['a', 'b']),
|
||||||
])
|
])
|
||||||
def test_icase_unique(input, output):
|
def test_icase_unique(input, output):
|
||||||
assert misc.icase_unique(input) == output
|
assert util.icase_unique(input) == output
|
||||||
|
|
Loading…
Reference in a new issue