Show More
@@ -5,5 +5,5 b' pytest-localserver >= 0.5.0, < 0.6' | |||||
5 | mock >= 3.0.0, < 4.1 |
|
5 | mock >= 3.0.0, < 4.1 | |
6 | Sphinx >= 1.8.0, < 3.1 |
|
6 | Sphinx >= 1.8.0, < 3.1 | |
7 | WebTest >= 2.0.6, < 2.1 |
|
7 | WebTest >= 2.0.6, < 2.1 | |
8 |
isort == |
|
8 | isort == 5.1.2 | |
9 | pyflakes == 2.2.0 |
|
9 | pyflakes == 2.2.0 |
@@ -86,8 +86,8 b' base_config.update_blueprint({' | |||||
86 | # 'debug = true' (not in production!) |
|
86 | # 'debug = true' (not in production!) | |
87 | # See the Kallithea documentation for more information. |
|
87 | # See the Kallithea documentation for more information. | |
88 | try: |
|
88 | try: | |
|
89 | import kajiki # only to check its existence | |||
89 | from tgext.debugbar import enable_debugbar |
|
90 | from tgext.debugbar import enable_debugbar | |
90 | import kajiki # only to check its existence |
|
|||
91 | assert kajiki |
|
91 | assert kajiki | |
92 | except ImportError: |
|
92 | except ImportError: | |
93 | pass |
|
93 | pass |
@@ -130,8 +130,8 b' class CompareController(BaseRepoControll' | |||||
130 |
|
130 | |||
131 | elif alias == 'git': |
|
131 | elif alias == 'git': | |
132 | if org_repo != other_repo: |
|
132 | if org_repo != other_repo: | |
|
133 | from dulwich.client import SubprocessGitClient | |||
133 | from dulwich.repo import Repo |
|
134 | from dulwich.repo import Repo | |
134 | from dulwich.client import SubprocessGitClient |
|
|||
135 |
|
135 | |||
136 | gitrepo = Repo(org_repo.path) |
|
136 | gitrepo = Repo(org_repo.path) | |
137 | SubprocessGitClient(thin_packs=False).fetch(other_repo.path, gitrepo) |
|
137 | SubprocessGitClient(thin_packs=False).fetch(other_repo.path, gitrepo) |
@@ -323,8 +323,8 b' def send_email(recipients, subject, body' | |||||
323 | @celerylib.task |
|
323 | @celerylib.task | |
324 | @celerylib.dbsession |
|
324 | @celerylib.dbsession | |
325 | def create_repo(form_data, cur_user): |
|
325 | def create_repo(form_data, cur_user): | |
|
326 | from kallithea.model.db import Setting | |||
326 | from kallithea.model.repo import RepoModel |
|
327 | from kallithea.model.repo import RepoModel | |
327 | from kallithea.model.db import Setting |
|
|||
328 |
|
328 | |||
329 | DBS = celerylib.get_session() |
|
329 | DBS = celerylib.get_session() | |
330 |
|
330 |
@@ -163,11 +163,9 b' class DbManage(object):' | |||||
163 | self.create_user(username, password, email, True) |
|
163 | self.create_user(username, password, email, True) | |
164 | else: |
|
164 | else: | |
165 | log.info('creating admin and regular test users') |
|
165 | log.info('creating admin and regular test users') | |
166 |
from kallithea.tests.base import TEST_USER_ADMIN_LOGIN, |
|
166 | from kallithea.tests.base import (TEST_USER_ADMIN_EMAIL, TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS, TEST_USER_REGULAR2_EMAIL, | |
167 | TEST_USER_ADMIN_PASS, TEST_USER_ADMIN_EMAIL, \ |
|
167 | TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS, TEST_USER_REGULAR_EMAIL, TEST_USER_REGULAR_LOGIN, | |
168 | TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS, \ |
|
168 | TEST_USER_REGULAR_PASS) | |
169 | TEST_USER_REGULAR_EMAIL, TEST_USER_REGULAR2_LOGIN, \ |
|
|||
170 | TEST_USER_REGULAR2_PASS, TEST_USER_REGULAR2_EMAIL |
|
|||
171 |
|
169 | |||
172 | self.create_user(TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS, |
|
170 | self.create_user(TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS, | |
173 | TEST_USER_ADMIN_EMAIL, True) |
|
171 | TEST_USER_ADMIN_EMAIL, True) |
@@ -632,6 +632,7 b' def person(author, show_attr="username")' | |||||
632 | """Find the user identified by 'author', return one of the users attributes, |
|
632 | """Find the user identified by 'author', return one of the users attributes, | |
633 | default to the username attribute, None if there is no user""" |
|
633 | default to the username attribute, None if there is no user""" | |
634 | from kallithea.model.db import User |
|
634 | from kallithea.model.db import User | |
|
635 | ||||
635 | # if author is already an instance use it for extraction |
|
636 | # if author is already an instance use it for extraction | |
636 | if isinstance(author, User): |
|
637 | if isinstance(author, User): | |
637 | return getattr(author, show_attr) |
|
638 | return getattr(author, show_attr) | |
@@ -646,6 +647,7 b' def person(author, show_attr="username")' | |||||
646 |
|
647 | |||
647 | def person_by_id(id_, show_attr="username"): |
|
648 | def person_by_id(id_, show_attr="username"): | |
648 | from kallithea.model.db import User |
|
649 | from kallithea.model.db import User | |
|
650 | ||||
649 | # maybe it's an ID ? |
|
651 | # maybe it's an ID ? | |
650 | if str(id_).isdigit() or isinstance(id_, int): |
|
652 | if str(id_).isdigit() or isinstance(id_, int): | |
651 | id_ = int(id_) |
|
653 | id_ = int(id_) | |
@@ -974,10 +976,8 b" def gravatar(email_address, cls='', size" | |||||
974 |
|
976 | |||
975 |
|
977 | |||
976 | def gravatar_url(email_address, size=30, default=''): |
|
978 | def gravatar_url(email_address, size=30, default=''): | |
977 | # doh, we need to re-import those to mock it later |
|
|||
978 | from kallithea.config.routing import url |
|
|||
979 | from kallithea.model.db import User |
|
|||
980 | from tg import tmpl_context as c |
|
979 | from tg import tmpl_context as c | |
|
980 | ||||
981 | if not c.visual.use_gravatar: |
|
981 | if not c.visual.use_gravatar: | |
982 | return "" |
|
982 | return "" | |
983 |
|
983 | |||
@@ -987,6 +987,10 b' def gravatar_url(email_address, size=30,' | |||||
987 | if email_address == _def: |
|
987 | if email_address == _def: | |
988 | return default |
|
988 | return default | |
989 |
|
989 | |||
|
990 | # re-import url so tests can mock it | |||
|
991 | from kallithea.config.routing import url | |||
|
992 | from kallithea.model.db import User | |||
|
993 | ||||
990 | parsed_url = urllib.parse.urlparse(url.current(qualified=True)) |
|
994 | parsed_url = urllib.parse.urlparse(url.current(qualified=True)) | |
991 | url = (c.visual.gravatar_url or User.DEFAULT_GRAVATAR_URL) \ |
|
995 | url = (c.visual.gravatar_url or User.DEFAULT_GRAVATAR_URL) \ | |
992 | .replace('{email}', email_address) \ |
|
996 | .replace('{email}', email_address) \ | |
@@ -1022,8 +1026,7 b' def fancy_file_stats(stats):' | |||||
1022 |
|
1026 | |||
1023 | :param stats: two element list of added/deleted lines of code |
|
1027 | :param stats: two element list of added/deleted lines of code | |
1024 | """ |
|
1028 | """ | |
1025 |
from kallithea.lib.diffs import |
|
1029 | from kallithea.lib.diffs import BIN_FILENODE, CHMOD_FILENODE, DEL_FILENODE, MOD_FILENODE, NEW_FILENODE, RENAMED_FILENODE | |
1026 | MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE, BIN_FILENODE |
|
|||
1027 |
|
1030 | |||
1028 | a, d = stats['added'], stats['deleted'] |
|
1031 | a, d = stats['added'], stats['deleted'] | |
1029 | width = 100 |
|
1032 | width = 100 |
@@ -307,6 +307,7 b' def _hook_environment(repo_path):' | |||||
307 | connect to the database. |
|
307 | connect to the database. | |
308 | """ |
|
308 | """ | |
309 | import paste.deploy |
|
309 | import paste.deploy | |
|
310 | ||||
310 | import kallithea.config.application |
|
311 | import kallithea.config.application | |
311 |
|
312 | |||
312 | extras = get_hook_environment() |
|
313 | extras = get_hook_environment() |
@@ -168,8 +168,9 b' class GitRepository(object):' | |||||
168 | if git_command in ['git-receive-pack']: |
|
168 | if git_command in ['git-receive-pack']: | |
169 | # updating refs manually after each push. |
|
169 | # updating refs manually after each push. | |
170 | # Needed for pre-1.7.0.4 git clients using regular HTTP mode. |
|
170 | # Needed for pre-1.7.0.4 git clients using regular HTTP mode. | |
|
171 | from dulwich.server import update_server_info | |||
|
172 | ||||
171 | from kallithea.lib.vcs import get_repo |
|
173 | from kallithea.lib.vcs import get_repo | |
172 | from dulwich.server import update_server_info |
|
|||
173 | repo = get_repo(self.content_path) |
|
174 | repo = get_repo(self.content_path) | |
174 | if repo: |
|
175 | if repo: | |
175 | update_server_info(repo._repo) |
|
176 | update_server_info(repo._repo) | |
@@ -223,6 +224,6 b' class GitDirectory(object):' | |||||
223 |
|
224 | |||
224 |
|
225 | |||
225 | def make_wsgi_app(repo_name, repo_root): |
|
226 | def make_wsgi_app(repo_name, repo_root): | |
226 |
from dulwich.web import |
|
227 | from dulwich.web import GunzipFilter, LimitedInputFilter | |
227 | app = GitDirectory(repo_root, repo_name) |
|
228 | app = GitDirectory(repo_root, repo_name) | |
228 | return GunzipFilter(LimitedInputFilter(app)) |
|
229 | return GunzipFilter(LimitedInputFilter(app)) |
@@ -331,9 +331,8 b' def get_changeset_safe(repo, rev):' | |||||
331 | :param repo: |
|
331 | :param repo: | |
332 | :param rev: |
|
332 | :param rev: | |
333 | """ |
|
333 | """ | |
334 | from kallithea.lib.vcs.backends.base import BaseRepository |
|
334 | from kallithea.lib.vcs.backends.base import BaseRepository, EmptyChangeset | |
335 | from kallithea.lib.vcs.exceptions import RepositoryError |
|
335 | from kallithea.lib.vcs.exceptions import RepositoryError | |
336 | from kallithea.lib.vcs.backends.base import EmptyChangeset |
|
|||
337 | if not isinstance(repo, BaseRepository): |
|
336 | if not isinstance(repo, BaseRepository): | |
338 | raise Exception('You must pass an Repository ' |
|
337 | raise Exception('You must pass an Repository ' | |
339 | 'object as first argument got %s' % type(repo)) |
|
338 | 'object as first argument got %s' % type(repo)) |
@@ -108,8 +108,8 b' def get_highlighted_code(name, code, typ' | |||||
108 | except ImportError: |
|
108 | except ImportError: | |
109 | return code |
|
109 | return code | |
110 | from pygments import highlight |
|
110 | from pygments import highlight | |
111 | from pygments.lexers import guess_lexer_for_filename, ClassNotFound |
|
|||
112 | from pygments.formatters import TerminalFormatter |
|
111 | from pygments.formatters import TerminalFormatter | |
|
112 | from pygments.lexers import ClassNotFound, guess_lexer_for_filename | |||
113 |
|
113 | |||
114 | try: |
|
114 | try: | |
115 | lexer = guess_lexer_for_filename(name, code) |
|
115 | lexer = guess_lexer_for_filename(name, code) |
@@ -307,8 +307,10 b' class Setting(Base, BaseDbModel):' | |||||
307 |
|
307 | |||
308 | @classmethod |
|
308 | @classmethod | |
309 | def get_server_info(cls): |
|
309 | def get_server_info(cls): | |
|
310 | import platform | |||
|
311 | ||||
310 | import pkg_resources |
|
312 | import pkg_resources | |
311 | import platform |
|
313 | ||
312 | from kallithea.lib.utils import check_git_version |
|
314 | from kallithea.lib.utils import check_git_version | |
313 | mods = [(p.project_name, p.version) for p in pkg_resources.working_set] |
|
315 | mods = [(p.project_name, p.version) for p in pkg_resources.working_set] | |
314 | info = { |
|
316 | info = { | |
@@ -595,7 +597,8 b' class User(Base, BaseDbModel):' | |||||
595 |
|
597 | |||
596 | :param author: |
|
598 | :param author: | |
597 | """ |
|
599 | """ | |
598 |
from kallithea.lib.helpers import |
|
600 | from kallithea.lib.helpers import author_name, email | |
|
601 | ||||
599 | # Valid email in the attribute passed, see if they're in the system |
|
602 | # Valid email in the attribute passed, see if they're in the system | |
600 | _email = email(author) |
|
603 | _email = email(author) | |
601 | if _email: |
|
604 | if _email: |
@@ -109,7 +109,8 b' class RepoModel(object):' | |||||
109 |
|
109 | |||
110 | @classmethod |
|
110 | @classmethod | |
111 | def _render_datatable(cls, tmpl, *args, **kwargs): |
|
111 | def _render_datatable(cls, tmpl, *args, **kwargs): | |
112 |
from tg import |
|
112 | from tg import app_globals, request | |
|
113 | from tg import tmpl_context as c | |||
113 | from tg.i18n import ugettext as _ |
|
114 | from tg.i18n import ugettext as _ | |
114 |
|
115 | |||
115 | _tmpl_lookup = app_globals.mako_lookup |
|
116 | _tmpl_lookup = app_globals.mako_lookup | |
@@ -128,7 +129,9 b' class RepoModel(object):' | |||||
128 | admin: return data for action column. |
|
129 | admin: return data for action column. | |
129 | """ |
|
130 | """ | |
130 | _render = self._render_datatable |
|
131 | _render = self._render_datatable | |
131 |
from tg import |
|
132 | from tg import request | |
|
133 | from tg import tmpl_context as c | |||
|
134 | ||||
132 | from kallithea.model.scm import ScmModel |
|
135 | from kallithea.model.scm import ScmModel | |
133 |
|
136 | |||
134 | def repo_lnk(name, rtype, rstate, private, fork_of): |
|
137 | def repo_lnk(name, rtype, rstate, private, fork_of): |
@@ -189,8 +189,8 b' class RepoGroupModel(object):' | |||||
189 | def _update_permissions(self, repo_group, perms_new=None, |
|
189 | def _update_permissions(self, repo_group, perms_new=None, | |
190 | perms_updates=None, recursive=None, |
|
190 | perms_updates=None, recursive=None, | |
191 | check_perms=True): |
|
191 | check_perms=True): | |
|
192 | from kallithea.lib.auth import HasUserGroupPermissionLevel | |||
192 | from kallithea.model.repo import RepoModel |
|
193 | from kallithea.model.repo import RepoModel | |
193 | from kallithea.lib.auth import HasUserGroupPermissionLevel |
|
|||
194 |
|
194 | |||
195 | if not perms_new: |
|
195 | if not perms_new: | |
196 | perms_new = [] |
|
196 | perms_new = [] |
@@ -59,8 +59,7 b' class UserModel(object):' | |||||
59 | if not cur_user: |
|
59 | if not cur_user: | |
60 | cur_user = getattr(get_current_authuser(), 'username', None) |
|
60 | cur_user = getattr(get_current_authuser(), 'username', None) | |
61 |
|
61 | |||
62 |
from kallithea.lib.hooks import |
|
62 | from kallithea.lib.hooks import check_allowed_create_user, log_create_user | |
63 | check_allowed_create_user |
|
|||
64 | _fd = form_data |
|
63 | _fd = form_data | |
65 | user_data = { |
|
64 | user_data = { | |
66 | 'username': _fd['username'], |
|
65 | 'username': _fd['username'], | |
@@ -111,9 +110,8 b' class UserModel(object):' | |||||
111 | if not cur_user: |
|
110 | if not cur_user: | |
112 | cur_user = getattr(get_current_authuser(), 'username', None) |
|
111 | cur_user = getattr(get_current_authuser(), 'username', None) | |
113 |
|
112 | |||
114 |
from kallithea.lib.auth import |
|
113 | from kallithea.lib.auth import check_password, get_crypt_password | |
115 |
from kallithea.lib.hooks import |
|
114 | from kallithea.lib.hooks import check_allowed_create_user, log_create_user | |
116 | check_allowed_create_user |
|
|||
117 | user_data = { |
|
115 | user_data = { | |
118 | 'username': username, 'password': password, |
|
116 | 'username': username, 'password': password, | |
119 | 'email': email, 'firstname': firstname, 'lastname': lastname, |
|
117 | 'email': email, 'firstname': firstname, 'lastname': lastname, | |
@@ -168,8 +166,8 b' class UserModel(object):' | |||||
168 | raise |
|
166 | raise | |
169 |
|
167 | |||
170 | def create_registration(self, form_data): |
|
168 | def create_registration(self, form_data): | |
|
169 | import kallithea.lib.helpers as h | |||
171 | from kallithea.model.notification import NotificationModel |
|
170 | from kallithea.model.notification import NotificationModel | |
172 | import kallithea.lib.helpers as h |
|
|||
173 |
|
171 | |||
174 | form_data['admin'] = False |
|
172 | form_data['admin'] = False | |
175 | form_data['extern_type'] = User.DEFAULT_AUTH_TYPE |
|
173 | form_data['extern_type'] = User.DEFAULT_AUTH_TYPE | |
@@ -317,9 +315,9 b' class UserModel(object):' | |||||
317 | allowing users to copy-paste or manually enter the token from the |
|
315 | allowing users to copy-paste or manually enter the token from the | |
318 | email. |
|
316 | email. | |
319 | """ |
|
317 | """ | |
|
318 | import kallithea.lib.helpers as h | |||
320 | from kallithea.lib.celerylib import tasks |
|
319 | from kallithea.lib.celerylib import tasks | |
321 | from kallithea.model.notification import EmailNotificationModel |
|
320 | from kallithea.model.notification import EmailNotificationModel | |
322 | import kallithea.lib.helpers as h |
|
|||
323 |
|
321 | |||
324 | user_email = data['email'] |
|
322 | user_email = data['email'] | |
325 | user = User.get_by_email(user_email) |
|
323 | user = User.get_by_email(user_email) | |
@@ -386,8 +384,8 b' class UserModel(object):' | |||||
386 | return expected_token == token |
|
384 | return expected_token == token | |
387 |
|
385 | |||
388 | def reset_password(self, user_email, new_passwd): |
|
386 | def reset_password(self, user_email, new_passwd): | |
|
387 | from kallithea.lib import auth | |||
389 | from kallithea.lib.celerylib import tasks |
|
388 | from kallithea.lib.celerylib import tasks | |
390 | from kallithea.lib import auth |
|
|||
391 | user = User.get_by_email(user_email) |
|
389 | user = User.get_by_email(user_email) | |
392 | if user is not None: |
|
390 | if user is not None: | |
393 | if not self.can_change_password(user): |
|
391 | if not self.can_change_password(user): |
@@ -145,7 +145,7 b' class _BaseTestApi(object):' | |||||
145 | assert 'trololo' == Optional.extract('trololo') |
|
145 | assert 'trololo' == Optional.extract('trololo') | |
146 |
|
146 | |||
147 | def test_Optional_OAttr(self): |
|
147 | def test_Optional_OAttr(self): | |
148 |
from kallithea.controllers.api.api import O |
|
148 | from kallithea.controllers.api.api import OAttr, Optional | |
149 |
|
149 | |||
150 | option1 = Optional(OAttr('apiuser')) |
|
150 | option1 = Optional(OAttr('apiuser')) | |
151 | assert 'apiuser' == Optional.extract(option1) |
|
151 | assert 'apiuser' == Optional.extract(option1) |
@@ -156,8 +156,9 b' class TestLibs(base.TestController):' | |||||
156 | (dict(years= -3, months= -2), '3 years and 2 months ago'), |
|
156 | (dict(years= -3, months= -2), '3 years and 2 months ago'), | |
157 | ]) |
|
157 | ]) | |
158 | def test_age(self, age_args, expected): |
|
158 | def test_age(self, age_args, expected): | |
|
159 | from dateutil import relativedelta | |||
|
160 | ||||
159 | from kallithea.lib.utils2 import age |
|
161 | from kallithea.lib.utils2 import age | |
160 | from dateutil import relativedelta |
|
|||
161 | with test_context(self.app): |
|
162 | with test_context(self.app): | |
162 | n = datetime.datetime(year=2012, month=5, day=17) |
|
163 | n = datetime.datetime(year=2012, month=5, day=17) | |
163 | delt = lambda *args, **kwargs: relativedelta.relativedelta(*args, **kwargs) |
|
164 | delt = lambda *args, **kwargs: relativedelta.relativedelta(*args, **kwargs) | |
@@ -181,8 +182,9 b' class TestLibs(base.TestController):' | |||||
181 | (dict(years= -4, months= -8), '5 years ago'), |
|
182 | (dict(years= -4, months= -8), '5 years ago'), | |
182 | ]) |
|
183 | ]) | |
183 | def test_age_short(self, age_args, expected): |
|
184 | def test_age_short(self, age_args, expected): | |
|
185 | from dateutil import relativedelta | |||
|
186 | ||||
184 | from kallithea.lib.utils2 import age |
|
187 | from kallithea.lib.utils2 import age | |
185 | from dateutil import relativedelta |
|
|||
186 | with test_context(self.app): |
|
188 | with test_context(self.app): | |
187 | n = datetime.datetime(year=2012, month=5, day=17) |
|
189 | n = datetime.datetime(year=2012, month=5, day=17) | |
188 | delt = lambda *args, **kwargs: relativedelta.relativedelta(*args, **kwargs) |
|
190 | delt = lambda *args, **kwargs: relativedelta.relativedelta(*args, **kwargs) | |
@@ -200,8 +202,9 b' class TestLibs(base.TestController):' | |||||
200 | (dict(years=1, months=1), 'in 1 year and 1 month') |
|
202 | (dict(years=1, months=1), 'in 1 year and 1 month') | |
201 | ]) |
|
203 | ]) | |
202 | def test_age_in_future(self, age_args, expected): |
|
204 | def test_age_in_future(self, age_args, expected): | |
|
205 | from dateutil import relativedelta | |||
|
206 | ||||
203 | from kallithea.lib.utils2 import age |
|
207 | from kallithea.lib.utils2 import age | |
204 | from dateutil import relativedelta |
|
|||
205 | with test_context(self.app): |
|
208 | with test_context(self.app): | |
206 | n = datetime.datetime(year=2012, month=5, day=17) |
|
209 | n = datetime.datetime(year=2012, month=5, day=17) | |
207 | delt = lambda *args, **kwargs: relativedelta.relativedelta(*args, **kwargs) |
|
210 | delt = lambda *args, **kwargs: relativedelta.relativedelta(*args, **kwargs) | |
@@ -297,6 +300,7 b' class TestLibs(base.TestController):' | |||||
297 | :param text: |
|
300 | :param text: | |
298 | """ |
|
301 | """ | |
299 | import re |
|
302 | import re | |
|
303 | ||||
300 | # quickly change expected url[] into a link |
|
304 | # quickly change expected url[] into a link | |
301 | url_pattern = re.compile(r'(?:url\[)(.+?)(?:\])') |
|
305 | url_pattern = re.compile(r'(?:url\[)(.+?)(?:\])') | |
302 |
|
306 | |||
@@ -570,11 +574,11 b' class TestLibs(base.TestController):' | |||||
570 | ('http://www.example.org/kallithea/repos/', 'abc/xyz/', 'http://www.example.org/kallithea/repos/abc/xyz/'), |
|
574 | ('http://www.example.org/kallithea/repos/', 'abc/xyz/', 'http://www.example.org/kallithea/repos/abc/xyz/'), | |
571 | ]) |
|
575 | ]) | |
572 | def test_canonical_url(self, canonical, test, expected): |
|
576 | def test_canonical_url(self, canonical, test, expected): | |
573 | from kallithea.lib.helpers import canonical_url |
|
577 | # setup url(), used by canonical_url | |
|
578 | import routes | |||
574 | from tg import request |
|
579 | from tg import request | |
575 |
|
580 | |||
576 | # setup url(), used by canonical_url |
|
581 | from kallithea.lib.helpers import canonical_url | |
577 | import routes |
|
|||
578 | m = routes.Mapper() |
|
582 | m = routes.Mapper() | |
579 | m.connect('about', '/about-page') |
|
583 | m.connect('about', '/about-page') | |
580 | url = routes.URLGenerator(m, {'HTTP_HOST': 'http_host.example.org'}) |
|
584 | url = routes.URLGenerator(m, {'HTTP_HOST': 'http_host.example.org'}) | |
@@ -594,11 +598,12 b' class TestLibs(base.TestController):' | |||||
594 | ('http://www.example.org/kallithea/repos/', 'www.example.org'), |
|
598 | ('http://www.example.org/kallithea/repos/', 'www.example.org'), | |
595 | ]) |
|
599 | ]) | |
596 | def test_canonical_hostname(self, canonical, expected): |
|
600 | def test_canonical_hostname(self, canonical, expected): | |
597 | from kallithea.lib.helpers import canonical_hostname |
|
601 | import routes | |
598 | from tg import request |
|
602 | from tg import request | |
599 |
|
603 | |||
|
604 | from kallithea.lib.helpers import canonical_hostname | |||
|
605 | ||||
600 | # setup url(), used by canonical_hostname |
|
606 | # setup url(), used by canonical_hostname | |
601 | import routes |
|
|||
602 | m = routes.Mapper() |
|
607 | m = routes.Mapper() | |
603 | url = routes.URLGenerator(m, {'HTTP_HOST': 'http_host.example.org'}) |
|
608 | url = routes.URLGenerator(m, {'HTTP_HOST': 'http_host.example.org'}) | |
604 |
|
609 |
@@ -68,6 +68,7 b' class WorkdirTestCaseMixin(_BackendTestM' | |||||
68 |
|
68 | |||
69 | def test_checkout_branch(self): |
|
69 | def test_checkout_branch(self): | |
70 | from kallithea.lib.vcs.exceptions import BranchDoesNotExistError |
|
70 | from kallithea.lib.vcs.exceptions import BranchDoesNotExistError | |
|
71 | ||||
71 | # first, 'foobranch' does not exist. |
|
72 | # first, 'foobranch' does not exist. | |
72 | with pytest.raises(BranchDoesNotExistError): |
|
73 | with pytest.raises(BranchDoesNotExistError): | |
73 | self.repo.workdir.checkout_branch(branch='foobranch') |
|
74 | self.repo.workdir.checkout_branch(branch='foobranch') |
@@ -19,7 +19,6 b' import shutil' | |||||
19 | import sys |
|
19 | import sys | |
20 |
|
20 | |||
21 | import click |
|
21 | import click | |
22 |
|
||||
23 | import i18n_utils |
|
22 | import i18n_utils | |
24 |
|
23 | |||
25 |
|
24 | |||
@@ -90,11 +89,8 b' def normalized_merge(local, base, other,' | |||||
90 |
|
89 | |||
91 | and then invoke merge/rebase/graft with the additional argument '--tool i18n'. |
|
90 | and then invoke merge/rebase/graft with the additional argument '--tool i18n'. | |
92 | """ |
|
91 | """ | |
93 |
from mercurial import |
|
92 | from mercurial import context, simplemerge | |
94 | context, |
|
93 | from mercurial import ui as uimod | |
95 | simplemerge, |
|
|||
96 | ui as uimod, |
|
|||
97 | ) |
|
|||
98 |
|
94 | |||
99 | print('i18n normalized-merge: normalizing and merging %s' % output) |
|
95 | print('i18n normalized-merge: normalizing and merging %s' % output) | |
100 |
|
96 |
General Comments 0
You need to be logged in to leave comments.
Login now