Show More
@@ -39,12 +39,11 b' import kallithea' | |||
|
39 | 39 | from kallithea.lib import webutils |
|
40 | 40 | from kallithea.lib.auth import HasPermissionAnyDecorator, LoginRequired |
|
41 | 41 | from kallithea.lib.base import BaseController, render |
|
42 | from kallithea.lib.celerylib import tasks | |
|
43 | 42 | from kallithea.lib.utils import repo2db_mapper, set_app_settings |
|
44 | 43 | from kallithea.lib.utils2 import safe_str |
|
45 | 44 | from kallithea.lib.vcs import VCSError |
|
46 | 45 | from kallithea.lib.webutils import url |
|
47 | from kallithea.model import db, meta | |
|
46 | from kallithea.model import async_tasks, db, meta | |
|
48 | 47 | from kallithea.model.forms import ApplicationSettingsForm, ApplicationUiSettingsForm, ApplicationVisualisationForm |
|
49 | 48 | from kallithea.model.notification import EmailNotificationModel |
|
50 | 49 | from kallithea.model.scm import ScmModel |
@@ -301,7 +300,7 b' class SettingsController(BaseController)' | |||
|
301 | 300 | |
|
302 | 301 | recipients = [test_email] if test_email else None |
|
303 | 302 | |
|
304 | tasks.send_email(recipients, test_email_subj, | |
|
303 | async_tasks.send_email(recipients, test_email_subj, | |
|
305 | 304 | test_email_txt_body, test_email_html_body) |
|
306 | 305 | |
|
307 | 306 | webutils.flash(_('Send email task created'), category='success') |
@@ -379,7 +378,7 b' class SettingsController(BaseController)' | |||
|
379 | 378 | if request.POST: |
|
380 | 379 | repo_location = self._get_hg_ui_settings()['paths_root_path'] |
|
381 | 380 | full_index = request.POST.get('full_index', False) |
|
382 | tasks.whoosh_index(repo_location, full_index) | |
|
381 | async_tasks.whoosh_index(repo_location, full_index) | |
|
383 | 382 | webutils.flash(_('Whoosh reindex task scheduled'), category='success') |
|
384 | 383 | raise HTTPFound(location=url('admin_settings_search')) |
|
385 | 384 |
@@ -41,7 +41,6 b' from webob.exc import HTTPBadRequest' | |||
|
41 | 41 | from kallithea.lib import ext_json, webutils |
|
42 | 42 | from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired |
|
43 | 43 | from kallithea.lib.base import BaseRepoController, jsonify, render |
|
44 | from kallithea.lib.celerylib.tasks import get_commits_stats | |
|
45 | 44 | from kallithea.lib.conf import ALL_EXTS, ALL_READMES, LANGUAGES_EXTENSIONS_MAP |
|
46 | 45 | from kallithea.lib.markup_renderer import MarkupRenderer |
|
47 | 46 | from kallithea.lib.page import Page |
@@ -49,7 +48,7 b' from kallithea.lib.utils2 import safe_in' | |||
|
49 | 48 | from kallithea.lib.vcs.backends.base import EmptyChangeset |
|
50 | 49 | from kallithea.lib.vcs.exceptions import ChangesetError, EmptyRepositoryError, NodeDoesNotExistError |
|
51 | 50 | from kallithea.lib.vcs.nodes import FileNode |
|
52 | from kallithea.model import db | |
|
51 | from kallithea.model import async_tasks, db | |
|
53 | 52 | |
|
54 | 53 | |
|
55 | 54 | log = logging.getLogger(__name__) |
@@ -209,5 +208,5 b' class SummaryController(BaseRepoControll' | |||
|
209 | 208 | c.trending_languages = [] |
|
210 | 209 | |
|
211 | 210 | recurse_limit = 500 # don't recurse more than 500 times when parsing |
|
212 | get_commits_stats(c.db_repo.repo_name, ts_min_y, ts_max_y, recurse_limit) | |
|
211 | async_tasks.get_commits_stats(c.db_repo.repo_name, ts_min_y, ts_max_y, recurse_limit) | |
|
213 | 212 | return render('summary/statistics.html') |
@@ -23,7 +23,7 b' import kallithea' | |||
|
23 | 23 | |
|
24 | 24 | |
|
25 | 25 | class CeleryConfig(object): |
|
26 |
imports = ['kallithea. |
|
|
26 | imports = ['kallithea.model.async_tasks'] | |
|
27 | 27 | task_always_eager = False |
|
28 | 28 | |
|
29 | 29 | # map from Kallithea .ini Celery 3 config names to Celery 4 config names |
@@ -12,8 +12,8 b'' | |||
|
12 | 12 | # You should have received a copy of the GNU General Public License |
|
13 | 13 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
14 | 14 | """ |
|
15 |
kallithea. |
|
|
16 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
|
15 | kallithea.model.async_tasks | |
|
16 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
|
17 | 17 | |
|
18 | 18 | Kallithea task modules, containing all task that suppose to be run |
|
19 | 19 | by celery daemon |
@@ -45,8 +45,7 b' from kallithea.lib import celerylib, con' | |||
|
45 | 45 | from kallithea.lib.indexers.daemon import WhooshIndexingDaemon |
|
46 | 46 | from kallithea.lib.utils2 import asbool, ascii_bytes |
|
47 | 47 | from kallithea.lib.vcs.utils import author_email |
|
48 | from kallithea.model import db, userlog | |
|
49 | from kallithea.model.repo import RepoModel | |
|
48 | from kallithea.model import db, repo, userlog | |
|
50 | 49 | |
|
51 | 50 | |
|
52 | 51 | __all__ = ['whoosh_index', 'get_commits_stats', 'send_email'] |
@@ -87,12 +86,12 b' def get_commits_stats(repo_name, ts_min_' | |||
|
87 | 86 | |
|
88 | 87 | co_day_auth_aggr = {} |
|
89 | 88 | commits_by_day_aggregate = {} |
|
90 | repo = db.Repository.get_by_repo_name(repo_name) | |
|
91 | if repo is None: | |
|
89 | db_repo = db.Repository.get_by_repo_name(repo_name) | |
|
90 | if db_repo is None: | |
|
92 | 91 | return True |
|
93 | 92 | |
|
94 | repo = repo.scm_instance | |
|
95 | repo_size = repo.count() | |
|
93 | scm_repo = db_repo.scm_instance | |
|
94 | repo_size = scm_repo.count() | |
|
96 | 95 | # return if repo have no revisions |
|
97 | 96 | if repo_size < 1: |
|
98 | 97 | lock.release() |
@@ -112,7 +111,7 b' def get_commits_stats(repo_name, ts_min_' | |||
|
112 | 111 | if cur_stats is not None: |
|
113 | 112 | last_rev = cur_stats.stat_on_revision |
|
114 | 113 | |
|
115 | if last_rev == repo.get_changeset().revision and repo_size > 1: | |
|
114 | if last_rev == scm_repo.get_changeset().revision and repo_size > 1: | |
|
116 | 115 | # pass silently without any work if we're not on first revision or |
|
117 | 116 | # current state of parsing revision(from db marker) is the |
|
118 | 117 | # last revision |
@@ -130,7 +129,7 b' def get_commits_stats(repo_name, ts_min_' | |||
|
130 | 129 | log.debug('Getting revisions from %s to %s', |
|
131 | 130 | last_rev, last_rev + parse_limit |
|
132 | 131 | ) |
|
133 | for cs in repo[last_rev:last_rev + parse_limit]: | |
|
132 | for cs in scm_repo[last_rev:last_rev + parse_limit]: | |
|
134 | 133 | log.debug('parsing %s', cs) |
|
135 | 134 | last_cs = cs # remember last parsed changeset |
|
136 | 135 | tt = cs.date.timetuple() |
@@ -188,8 +187,8 b' def get_commits_stats(repo_name, ts_min_' | |||
|
188 | 187 | key=itemgetter(0)) |
|
189 | 188 | |
|
190 | 189 | if not co_day_auth_aggr: |
|
191 | co_day_auth_aggr[akc(repo.contact)] = { | |
|
192 | "label": akc(repo.contact), | |
|
190 | co_day_auth_aggr[akc(scm_repo.contact)] = { | |
|
191 | "label": akc(scm_repo.contact), | |
|
193 | 192 | "data": [0, 1], |
|
194 | 193 | "schema": ["commits"], |
|
195 | 194 | } |
@@ -199,7 +198,7 b' def get_commits_stats(repo_name, ts_min_' | |||
|
199 | 198 | stats.commit_activity_combined = ascii_bytes(ext_json.dumps(overview_data)) |
|
200 | 199 | |
|
201 | 200 | log.debug('last revision %s', last_rev) |
|
202 | leftovers = len(repo.revisions[last_rev:]) | |
|
201 | leftovers = len(scm_repo.revisions[last_rev:]) | |
|
203 | 202 | log.debug('revisions to parse %s', leftovers) |
|
204 | 203 | |
|
205 | 204 | if last_rev == 0 or leftovers < parse_limit: |
@@ -221,7 +220,7 b' def get_commits_stats(repo_name, ts_min_' | |||
|
221 | 220 | lock.release() |
|
222 | 221 | |
|
223 | 222 | # execute another task if celery is enabled |
|
224 | if len(repo.revisions) > 1 and kallithea.CELERY_APP and recurse_limit > 0: | |
|
223 | if len(scm_repo.revisions) > 1 and kallithea.CELERY_APP and recurse_limit > 0: | |
|
225 | 224 | get_commits_stats(repo_name, ts_min_y, ts_max_y, recurse_limit - 1) |
|
226 | 225 | elif recurse_limit <= 0: |
|
227 | 226 | log.debug('Not recursing - limit has been reached') |
@@ -376,7 +375,7 b' def create_repo(form_data, cur_user):' | |||
|
376 | 375 | enable_downloads = defs.get('repo_enable_downloads') |
|
377 | 376 | |
|
378 | 377 | try: |
|
379 | repo = RepoModel()._create_repo( | |
|
378 | db_repo = repo.RepoModel()._create_repo( | |
|
380 | 379 | repo_name=repo_name_full, |
|
381 | 380 | repo_type=repo_type, |
|
382 | 381 | description=description, |
@@ -398,30 +397,30 b' def create_repo(form_data, cur_user):' | |||
|
398 | 397 | |
|
399 | 398 | DBS.commit() |
|
400 | 399 | # now create this repo on Filesystem |
|
401 | RepoModel()._create_filesystem_repo( | |
|
400 | repo.RepoModel()._create_filesystem_repo( | |
|
402 | 401 | repo_name=repo_name, |
|
403 | 402 | repo_type=repo_type, |
|
404 | 403 | repo_group=db.RepoGroup.guess_instance(repo_group), |
|
405 | 404 | clone_uri=clone_uri, |
|
406 | 405 | ) |
|
407 | repo = db.Repository.get_by_repo_name(repo_name_full) | |
|
408 | hooks.log_create_repository(repo.get_dict(), created_by=owner.username) | |
|
406 | db_repo = db.Repository.get_by_repo_name(repo_name_full) | |
|
407 | hooks.log_create_repository(db_repo.get_dict(), created_by=owner.username) | |
|
409 | 408 | |
|
410 | 409 | # update repo changeset caches initially |
|
411 | repo.update_changeset_cache() | |
|
410 | db_repo.update_changeset_cache() | |
|
412 | 411 | |
|
413 | 412 | # set new created state |
|
414 | repo.set_state(db.Repository.STATE_CREATED) | |
|
413 | db_repo.set_state(db.Repository.STATE_CREATED) | |
|
415 | 414 | DBS.commit() |
|
416 | 415 | except Exception as e: |
|
417 | 416 | log.warning('Exception %s occurred when forking repository, ' |
|
418 | 417 | 'doing cleanup...' % e) |
|
419 | 418 | # rollback things manually ! |
|
420 | repo = db.Repository.get_by_repo_name(repo_name_full) | |
|
421 | if repo: | |
|
422 | db.Repository.delete(repo.repo_id) | |
|
419 | db_repo = db.Repository.get_by_repo_name(repo_name_full) | |
|
420 | if db_repo: | |
|
421 | db.Repository.delete(db_repo.repo_id) | |
|
423 | 422 | DBS.commit() |
|
424 | RepoModel()._delete_filesystem_repo(repo) | |
|
423 | repo.RepoModel()._delete_filesystem_repo(db_repo) | |
|
425 | 424 | raise |
|
426 | 425 | |
|
427 | 426 | return True |
@@ -455,7 +454,7 b' def create_repo_fork(form_data, cur_user' | |||
|
455 | 454 | try: |
|
456 | 455 | fork_of = db.Repository.guess_instance(form_data.get('fork_parent_id')) |
|
457 | 456 | |
|
458 | RepoModel()._create_repo( | |
|
457 | repo.RepoModel()._create_repo( | |
|
459 | 458 | repo_name=repo_name_full, |
|
460 | 459 | repo_type=repo_type, |
|
461 | 460 | description=form_data['description'], |
@@ -474,39 +473,39 b' def create_repo_fork(form_data, cur_user' | |||
|
474 | 473 | source_repo_path = os.path.join(base_path, fork_of.repo_name) |
|
475 | 474 | |
|
476 | 475 | # now create this repo on Filesystem |
|
477 | RepoModel()._create_filesystem_repo( | |
|
476 | repo.RepoModel()._create_filesystem_repo( | |
|
478 | 477 | repo_name=repo_name, |
|
479 | 478 | repo_type=repo_type, |
|
480 | 479 | repo_group=db.RepoGroup.guess_instance(repo_group), |
|
481 | 480 | clone_uri=source_repo_path, |
|
482 | 481 | ) |
|
483 | repo = db.Repository.get_by_repo_name(repo_name_full) | |
|
484 | hooks.log_create_repository(repo.get_dict(), created_by=owner.username) | |
|
482 | db_repo = db.Repository.get_by_repo_name(repo_name_full) | |
|
483 | hooks.log_create_repository(db_repo.get_dict(), created_by=owner.username) | |
|
485 | 484 | |
|
486 | 485 | # update repo changeset caches initially |
|
487 | repo.update_changeset_cache() | |
|
486 | db_repo.update_changeset_cache() | |
|
488 | 487 | |
|
489 | 488 | # set new created state |
|
490 | repo.set_state(db.Repository.STATE_CREATED) | |
|
489 | db_repo.set_state(db.Repository.STATE_CREATED) | |
|
491 | 490 | DBS.commit() |
|
492 | 491 | except Exception as e: |
|
493 | 492 | log.warning('Exception %s occurred when forking repository, ' |
|
494 | 493 | 'doing cleanup...' % e) |
|
495 | 494 | # rollback things manually ! |
|
496 | repo = db.Repository.get_by_repo_name(repo_name_full) | |
|
497 | if repo: | |
|
498 | db.Repository.delete(repo.repo_id) | |
|
495 | db_repo = db.Repository.get_by_repo_name(repo_name_full) | |
|
496 | if db_repo: | |
|
497 | db.Repository.delete(db_repo.repo_id) | |
|
499 | 498 | DBS.commit() |
|
500 | RepoModel()._delete_filesystem_repo(repo) | |
|
499 | repo.RepoModel()._delete_filesystem_repo(db_repo) | |
|
501 | 500 | raise |
|
502 | 501 | |
|
503 | 502 | return True |
|
504 | 503 | |
|
505 | 504 | |
|
506 | 505 | def __get_codes_stats(repo_name): |
|
507 | repo = db.Repository.get_by_repo_name(repo_name).scm_instance | |
|
506 | scm_repo = db.Repository.get_by_repo_name(repo_name).scm_instance | |
|
508 | 507 | |
|
509 | tip = repo.get_changeset() | |
|
508 | tip = scm_repo.get_changeset() | |
|
510 | 509 | code_stats = {} |
|
511 | 510 | |
|
512 | 511 | for _topnode, _dirnodes, filenodes in tip.walk('/'): |
@@ -34,7 +34,7 b' from tg import tmpl_context as c' | |||
|
34 | 34 | from tg.i18n import ugettext as _ |
|
35 | 35 | |
|
36 | 36 | from kallithea.lib.utils2 import fmt_date |
|
37 | from kallithea.model import db | |
|
37 | from kallithea.model import async_tasks, db | |
|
38 | 38 | |
|
39 | 39 | |
|
40 | 40 | log = logging.getLogger(__name__) |
@@ -66,7 +66,6 b' class NotificationModel(object):' | |||
|
66 | 66 | :param email_kwargs: additional dict to pass as args to email template |
|
67 | 67 | """ |
|
68 | 68 | import kallithea.lib.helpers as h |
|
69 | from kallithea.lib.celerylib import tasks | |
|
70 | 69 | email_kwargs = email_kwargs or {} |
|
71 | 70 | if recipients and not getattr(recipients, '__iter__', False): |
|
72 | 71 | raise Exception('recipients must be a list or iterable') |
@@ -135,7 +134,7 b' class NotificationModel(object):' | |||
|
135 | 134 | |
|
136 | 135 | # send email with notification to participants |
|
137 | 136 | for rec_mail in sorted(rec_mails): |
|
138 | tasks.send_email([rec_mail], email_subject, email_txt_body, | |
|
137 | async_tasks.send_email([rec_mail], email_subject, email_txt_body, | |
|
139 | 138 | email_html_body, headers, |
|
140 | 139 | from_name=created_by_obj.full_name_or_username) |
|
141 | 140 |
@@ -405,8 +405,8 b' class RepoModel(object):' | |||
|
405 | 405 | :param form_data: |
|
406 | 406 | :param cur_user: |
|
407 | 407 | """ |
|
408 |
from kallithea. |
|
|
409 | return tasks.create_repo(form_data, cur_user) | |
|
408 | from kallithea.model import async_tasks | |
|
409 | return async_tasks.create_repo(form_data, cur_user) | |
|
410 | 410 | |
|
411 | 411 | def _update_permissions(self, repo, perms_new=None, perms_updates=None, |
|
412 | 412 | check_perms=True): |
@@ -448,8 +448,8 b' class RepoModel(object):' | |||
|
448 | 448 | :param form_data: |
|
449 | 449 | :param cur_user: |
|
450 | 450 | """ |
|
451 |
from kallithea. |
|
|
452 | return tasks.create_repo_fork(form_data, cur_user) | |
|
451 | from kallithea.model import async_tasks | |
|
452 | return async_tasks.create_repo_fork(form_data, cur_user) | |
|
453 | 453 | |
|
454 | 454 | def delete(self, repo, forks=None, fs_remove=True, cur_user=None): |
|
455 | 455 | """ |
@@ -298,8 +298,7 b' class UserModel(object):' | |||
|
298 | 298 | allowing users to copy-paste or manually enter the token from the |
|
299 | 299 | email. |
|
300 | 300 | """ |
|
301 |
from kallithea. |
|
|
302 | from kallithea.model import notification | |
|
301 | from kallithea.model import async_tasks, notification | |
|
303 | 302 | |
|
304 | 303 | user_email = data['email'] |
|
305 | 304 | user = db.User.get_by_email(user_email) |
@@ -332,7 +331,7 b' class UserModel(object):' | |||
|
332 | 331 | reset_token=token, |
|
333 | 332 | reset_url=link) |
|
334 | 333 | log.debug('sending email') |
|
335 | tasks.send_email([user_email], _("Password reset link"), body, html_body) | |
|
334 | async_tasks.send_email([user_email], _("Password reset link"), body, html_body) | |
|
336 | 335 | log.info('send new password mail to %s', user_email) |
|
337 | 336 | else: |
|
338 | 337 | log.debug("password reset email %s not found", user_email) |
@@ -365,7 +364,7 b' class UserModel(object):' | |||
|
365 | 364 | return expected_token == token |
|
366 | 365 | |
|
367 | 366 | def reset_password(self, user_email, new_passwd): |
|
368 |
from kallithea. |
|
|
367 | from kallithea.model import async_tasks | |
|
369 | 368 | user = db.User.get_by_email(user_email) |
|
370 | 369 | if user is not None: |
|
371 | 370 | if not self.can_change_password(user): |
@@ -376,7 +375,7 b' class UserModel(object):' | |||
|
376 | 375 | if new_passwd is None: |
|
377 | 376 | raise Exception('unable to set new password') |
|
378 | 377 | |
|
379 | tasks.send_email([user_email], | |
|
378 | async_tasks.send_email([user_email], | |
|
380 | 379 | _('Password reset notification'), |
|
381 | 380 | _('The password to your account %s has been changed using password reset form.') % (user.username,)) |
|
382 | 381 | log.info('send password reset mail to %s', user_email) |
@@ -6,7 +6,7 b' import urllib.parse' | |||
|
6 | 6 | import mock |
|
7 | 7 | from tg.util.webtest import test_context |
|
8 | 8 | |
|
9 |
import kallithea.l |
|
|
9 | import kallithea.model.async_tasks | |
|
10 | 10 | from kallithea.lib import webutils |
|
11 | 11 | from kallithea.lib.utils2 import check_password, generate_api_key |
|
12 | 12 | from kallithea.model import db, meta, validators |
@@ -410,7 +410,7 b' class TestLoginController(base.TestContr' | |||
|
410 | 410 | def mock_send_email(recipients, subject, body='', html_body='', headers=None, from_name=None): |
|
411 | 411 | collected.append((recipients, subject, body, html_body)) |
|
412 | 412 | |
|
413 |
with mock.patch.object(kallithea.l |
|
|
413 | with mock.patch.object(kallithea.model.async_tasks, 'send_email', mock_send_email), \ | |
|
414 | 414 | mock.patch.object(time, 'time', lambda: timestamp): |
|
415 | 415 | response = self.app.post(base.url(controller='login', |
|
416 | 416 | action='password_reset'), |
@@ -5,8 +5,8 b' import mock' | |||
|
5 | 5 | from tg.util.webtest import test_context |
|
6 | 6 | |
|
7 | 7 | import kallithea.lib.celerylib |
|
8 | import kallithea.lib.celerylib.tasks | |
|
9 | 8 | import kallithea.lib.helpers as h |
|
9 | import kallithea.model.async_tasks | |
|
10 | 10 | from kallithea.model import db, meta |
|
11 | 11 | from kallithea.model.notification import EmailNotificationModel, NotificationModel |
|
12 | 12 | from kallithea.model.user import UserModel |
@@ -48,7 +48,7 b' class TestNotifications(base.TestControl' | |||
|
48 | 48 | assert body == "hi there" |
|
49 | 49 | assert '>hi there<' in html_body |
|
50 | 50 | assert from_name == 'u1 u1' |
|
51 |
with mock.patch.object(kallithea.l |
|
|
51 | with mock.patch.object(kallithea.model.async_tasks, 'send_email', send_email): | |
|
52 | 52 | NotificationModel().create(created_by=self.u1, |
|
53 | 53 | body='hi there', |
|
54 | 54 | recipients=usrs) |
@@ -73,7 +73,7 b' class TestNotifications(base.TestControl' | |||
|
73 | 73 | l.append('<hr/>\n') |
|
74 | 74 | |
|
75 | 75 | with test_context(self.app): |
|
76 |
with mock.patch.object(kallithea.l |
|
|
76 | with mock.patch.object(kallithea.model.async_tasks, 'send_email', send_email): | |
|
77 | 77 | pr_kwargs = dict( |
|
78 | 78 | pr_nice_id='#7', |
|
79 | 79 | pr_title='The Title', |
@@ -155,7 +155,7 b' class TestNotifications(base.TestControl' | |||
|
155 | 155 | # Email type TYPE_PASSWORD_RESET has no corresponding notification type - test it directly: |
|
156 | 156 | desc = 'TYPE_PASSWORD_RESET' |
|
157 | 157 | kwargs = dict(user='John Doe', reset_token='decbf64715098db5b0bd23eab44bd792670ab746', reset_url='http://reset.com/decbf64715098db5b0bd23eab44bd792670ab746') |
|
158 |
kallithea.l |
|
|
158 | kallithea.model.async_tasks.send_email(['john@doe.com'], | |
|
159 | 159 | "Password reset link", |
|
160 | 160 | EmailNotificationModel().get_email_tmpl(EmailNotificationModel.TYPE_PASSWORD_RESET, 'txt', **kwargs), |
|
161 | 161 | EmailNotificationModel().get_email_tmpl(EmailNotificationModel.TYPE_PASSWORD_RESET, 'html', **kwargs), |
@@ -25,7 +25,7 b' class smtplib_mock(object):' | |||
|
25 | 25 | smtplib_mock.lastmsg = msg |
|
26 | 26 | |
|
27 | 27 | |
|
28 |
@mock.patch('kallithea. |
|
|
28 | @mock.patch('kallithea.model.async_tasks.smtplib', smtplib_mock) | |
|
29 | 29 | class TestMail(base.TestController): |
|
30 | 30 | |
|
31 | 31 | def test_send_mail_trivial(self): |
@@ -40,8 +40,8 b' class TestMail(base.TestController):' | |||
|
40 | 40 | 'smtp_server': mailserver, |
|
41 | 41 | 'app_email_from': envelope_from, |
|
42 | 42 | } |
|
43 |
with mock.patch('kallithea. |
|
|
44 |
kallithea.l |
|
|
43 | with mock.patch('kallithea.model.async_tasks.config', config_mock): | |
|
44 | kallithea.model.async_tasks.send_email(recipients, subject, body, html_body) | |
|
45 | 45 | |
|
46 | 46 | assert smtplib_mock.lastdest == set(recipients) |
|
47 | 47 | assert smtplib_mock.lastsender == envelope_from |
@@ -64,8 +64,8 b' class TestMail(base.TestController):' | |||
|
64 | 64 | 'app_email_from': envelope_from, |
|
65 | 65 | 'email_to': email_to, |
|
66 | 66 | } |
|
67 |
with mock.patch('kallithea. |
|
|
68 |
kallithea.l |
|
|
67 | with mock.patch('kallithea.model.async_tasks.config', config_mock): | |
|
68 | kallithea.model.async_tasks.send_email(recipients, subject, body, html_body) | |
|
69 | 69 | |
|
70 | 70 | assert smtplib_mock.lastdest == set([base.TEST_USER_ADMIN_EMAIL, email_to]) |
|
71 | 71 | assert smtplib_mock.lastsender == envelope_from |
@@ -88,8 +88,8 b' class TestMail(base.TestController):' | |||
|
88 | 88 | 'app_email_from': envelope_from, |
|
89 | 89 | 'email_to': email_to, |
|
90 | 90 | } |
|
91 |
with mock.patch('kallithea. |
|
|
92 |
kallithea.l |
|
|
91 | with mock.patch('kallithea.model.async_tasks.config', config_mock): | |
|
92 | kallithea.model.async_tasks.send_email(recipients, subject, body, html_body) | |
|
93 | 93 | |
|
94 | 94 | assert smtplib_mock.lastdest == set([base.TEST_USER_ADMIN_EMAIL] + email_to.split(',')) |
|
95 | 95 | assert smtplib_mock.lastsender == envelope_from |
@@ -110,8 +110,8 b' class TestMail(base.TestController):' | |||
|
110 | 110 | 'smtp_server': mailserver, |
|
111 | 111 | 'app_email_from': envelope_from, |
|
112 | 112 | } |
|
113 |
with mock.patch('kallithea. |
|
|
114 |
kallithea.l |
|
|
113 | with mock.patch('kallithea.model.async_tasks.config', config_mock): | |
|
114 | kallithea.model.async_tasks.send_email(recipients, subject, body, html_body) | |
|
115 | 115 | |
|
116 | 116 | assert smtplib_mock.lastdest == set([base.TEST_USER_ADMIN_EMAIL]) |
|
117 | 117 | assert smtplib_mock.lastsender == envelope_from |
@@ -133,8 +133,8 b' class TestMail(base.TestController):' | |||
|
133 | 133 | 'smtp_server': mailserver, |
|
134 | 134 | 'app_email_from': envelope_from, |
|
135 | 135 | } |
|
136 |
with mock.patch('kallithea. |
|
|
137 |
kallithea.l |
|
|
136 | with mock.patch('kallithea.model.async_tasks.config', config_mock): | |
|
137 | kallithea.model.async_tasks.send_email(recipients, subject, body, html_body, from_name=author.full_name_or_username) | |
|
138 | 138 | |
|
139 | 139 | assert smtplib_mock.lastdest == set(recipients) |
|
140 | 140 | assert smtplib_mock.lastsender == envelope_from |
@@ -157,8 +157,8 b' class TestMail(base.TestController):' | |||
|
157 | 157 | 'smtp_server': mailserver, |
|
158 | 158 | 'app_email_from': envelope_from, |
|
159 | 159 | } |
|
160 |
with mock.patch('kallithea. |
|
|
161 |
kallithea.l |
|
|
160 | with mock.patch('kallithea.model.async_tasks.config', config_mock): | |
|
161 | kallithea.model.async_tasks.send_email(recipients, subject, body, html_body, from_name=author.full_name_or_username) | |
|
162 | 162 | |
|
163 | 163 | assert smtplib_mock.lastdest == set(recipients) |
|
164 | 164 | assert smtplib_mock.lastsender == envelope_from |
@@ -181,8 +181,8 b' class TestMail(base.TestController):' | |||
|
181 | 181 | 'smtp_server': mailserver, |
|
182 | 182 | 'app_email_from': envelope_from, |
|
183 | 183 | } |
|
184 |
with mock.patch('kallithea. |
|
|
185 |
kallithea.l |
|
|
184 | with mock.patch('kallithea.model.async_tasks.config', config_mock): | |
|
185 | kallithea.model.async_tasks.send_email(recipients, subject, body, html_body, | |
|
186 | 186 | from_name=author.full_name_or_username, headers=headers) |
|
187 | 187 | |
|
188 | 188 | assert smtplib_mock.lastdest == set(recipients) |
@@ -131,7 +131,6 b' conftest' | |||
|
131 | 131 | |
|
132 | 132 | normal_modules = set(''' |
|
133 | 133 | kallithea |
|
134 | kallithea.lib.celerylib.tasks | |
|
135 | 134 | kallithea.lib |
|
136 | 135 | kallithea.lib.auth |
|
137 | 136 | kallithea.lib.auth_modules |
@@ -146,6 +145,7 b' kallithea.lib.utils2' | |||
|
146 | 145 | kallithea.lib.vcs |
|
147 | 146 | kallithea.lib.webutils |
|
148 | 147 | kallithea.model |
|
148 | kallithea.model.async_tasks | |
|
149 | 149 | kallithea.model.scm |
|
150 | 150 | kallithea.templates.py |
|
151 | 151 | '''.split()) |
@@ -158,10 +158,10 b' known_violations = [' | |||
|
158 | 158 | ('kallithea.lib.utils', 'kallithea.model'), # clean up utils |
|
159 | 159 | ('kallithea.lib.utils', 'kallithea.model.db'), |
|
160 | 160 | ('kallithea.lib.utils', 'kallithea.model.scm'), |
|
161 |
('kallithea. |
|
|
162 |
('kallithea. |
|
|
163 |
('kallithea. |
|
|
164 |
('kallithea. |
|
|
161 | ('kallithea.model.async_tasks', 'kallithea.lib.helpers'), | |
|
162 | ('kallithea.model.async_tasks', 'kallithea.lib.hooks'), | |
|
163 | ('kallithea.model.async_tasks', 'kallithea.lib.indexers'), | |
|
164 | ('kallithea.model.async_tasks', 'kallithea.model'), | |
|
165 | 165 | ('kallithea.model', 'kallithea.lib.auth'), # auth.HasXXX |
|
166 | 166 | ('kallithea.model', 'kallithea.lib.auth_modules'), # validators |
|
167 | 167 | ('kallithea.model', 'kallithea.lib.helpers'), |
General Comments 0
You need to be logged in to leave comments.
Login now