Delete .smoke_phase6.py
This commit is contained in:
115
.smoke_phase6.py
115
.smoke_phase6.py
@@ -1,115 +0,0 @@
|
||||
import xmlrpc.client
|
||||
from odoo.addons.fusion_helpdesk.utils import build_scope_domain
|
||||
from odoo.addons.fusion_helpdesk.utils import build_ticket_vals
|
||||
|
||||
SMOKE_EMAIL = 'phase6-smoke@example.com'
|
||||
SMOKE_NAME = 'Phase6 Smoke (delete me)'
|
||||
|
||||
def line(k, v):
|
||||
print('SMOKE|%s|%s' % (k, v))
|
||||
|
||||
ICP = env['ir.config_parameter'].sudo()
|
||||
cfg = {
|
||||
'url': (ICP.get_param('fusion_helpdesk.remote_url') or '').strip().rstrip('/'),
|
||||
'db': (ICP.get_param('fusion_helpdesk.remote_db') or '').strip(),
|
||||
'login': (ICP.get_param('fusion_helpdesk.remote_login') or '').strip(),
|
||||
'password': ICP.get_param('fusion_helpdesk.remote_password') or '',
|
||||
'team_id': int(ICP.get_param('fusion_helpdesk.remote_team_id') or 0) or False,
|
||||
'client_label': (ICP.get_param('fusion_helpdesk.client_label') or '').strip(),
|
||||
}
|
||||
line('CFG_URL', cfg['url'])
|
||||
line('CFG_DB', cfg['db'])
|
||||
line('CFG_LOGIN', cfg['login'])
|
||||
line('CFG_TEAM', cfg['team_id'])
|
||||
line('CFG_LABEL', repr(cfg['client_label']))
|
||||
|
||||
common = xmlrpc.client.ServerProxy(cfg['url'] + '/xmlrpc/2/common', allow_none=True)
|
||||
uid = common.authenticate(cfg['db'], cfg['login'], cfg['password'], {})
|
||||
line('AUTH_UID', uid)
|
||||
models = xmlrpc.client.ServerProxy(cfg['url'] + '/xmlrpc/2/object', allow_none=True)
|
||||
|
||||
|
||||
def kw(model, method, args, kwargs=None):
|
||||
return models.execute_kw(cfg['db'], uid, cfg['password'], model, method, args, kwargs or {})
|
||||
|
||||
|
||||
vals = build_ticket_vals(
|
||||
kind='bug', subject='Phase 6 deploy smoke test',
|
||||
body_html='<p>Automated smoke test from entech after deploy. Safe to delete.</p>',
|
||||
team_id=cfg['team_id'], client_label=cfg['client_label'],
|
||||
reporter_name=SMOKE_NAME, reporter_email=SMOKE_EMAIL,
|
||||
company_name='SMOKE-TEST',
|
||||
)
|
||||
line('VALS', vals)
|
||||
|
||||
tid = kw('helpdesk.ticket', 'create', [vals])
|
||||
line('CREATED_TICKET_ID', tid)
|
||||
|
||||
rb = kw('helpdesk.ticket', 'read', [[tid], [
|
||||
'name', 'partner_id', 'partner_email', 'partner_name',
|
||||
'x_fc_client_label', 'message_partner_ids', 'ticket_ref']])[0]
|
||||
line('READ_NAME', rb['name'])
|
||||
line('READ_PARTNER_ID', rb['partner_id'])
|
||||
line('READ_PARTNER_EMAIL', rb['partner_email'])
|
||||
line('READ_PARTNER_NAME', rb['partner_name'])
|
||||
line('READ_LABEL', repr(rb['x_fc_client_label']))
|
||||
line('READ_FOLLOWERS', rb['message_partner_ids'])
|
||||
partner_id = rb['partner_id'][0] if rb['partner_id'] else None
|
||||
line('ASSERT_PARTNER_RESOLVED', bool(partner_id))
|
||||
line('ASSERT_LABEL_MATCHES', rb['x_fc_client_label'] == cfg['client_label'])
|
||||
line('ASSERT_FOLLOWER', bool(partner_id) and partner_id in (rb['message_partner_ids'] or []))
|
||||
|
||||
# Ack email queued by the central create-override?
|
||||
acks = kw('mail.mail', 'search_read',
|
||||
[[('subject', 'ilike', 'received your request')]],
|
||||
{'fields': ['id', 'state', 'email_to', 'subject'], 'order': 'id desc', 'limit': 5})
|
||||
line('ACK_CANDIDATES', acks)
|
||||
ack_mail_ids = [m['id'] for m in acks if SMOKE_EMAIL in (m.get('email_to') or '')]
|
||||
line('ASSERT_ACK_FOR_SMOKE', bool(ack_mail_ids))
|
||||
|
||||
# Support reply (as the service/agent account) -> should show in public thread
|
||||
kw('helpdesk.ticket', 'message_post', [[tid]], {
|
||||
'body': '<p>Smoke test support reply.</p>', 'body_is_html': True,
|
||||
'message_type': 'comment', 'subtype_xmlid': 'mail.mt_comment',
|
||||
})
|
||||
pub = kw('mail.message', 'search_read',
|
||||
[[('model', '=', 'helpdesk.ticket'), ('res_id', '=', tid),
|
||||
('message_type', 'in', ['comment', 'email'])]],
|
||||
{'fields': ['id', 'author_id', 'subtype_id'], 'order': 'id asc'})
|
||||
line('PUBLIC_MSG_COUNT', len(pub))
|
||||
|
||||
# Inbox scope: would the entech reporter (email+label, non-admin) find this ticket?
|
||||
dom = build_scope_domain(cfg['client_label'], SMOKE_EMAIL, False)
|
||||
line('SCOPE_DOMAIN', dom)
|
||||
found = kw('helpdesk.ticket', 'search', [dom], {'limit': 50})
|
||||
line('SCOPE_FOUND_IDS', found)
|
||||
line('ASSERT_INBOX_SEES_TICKET', tid in found)
|
||||
|
||||
# Cross-deployment leak guard: a different label must NOT see it
|
||||
dom_other = build_scope_domain('SOME-OTHER-LABEL', SMOKE_EMAIL, False)
|
||||
found_other = kw('helpdesk.ticket', 'search', [dom_other], {'limit': 50})
|
||||
line('ASSERT_NO_LEAK_OTHER_LABEL', tid not in found_other)
|
||||
|
||||
# ---- Cleanup (best effort) ------------------------------------------------
|
||||
cleanup = {'mail': False, 'ticket': False, 'partner': False}
|
||||
try:
|
||||
if ack_mail_ids:
|
||||
kw('mail.mail', 'unlink', [ack_mail_ids])
|
||||
cleanup['mail'] = True
|
||||
except Exception as e:
|
||||
line('CLEANUP_MAIL_ERR', e)
|
||||
try:
|
||||
kw('helpdesk.ticket', 'unlink', [[tid]])
|
||||
cleanup['ticket'] = True
|
||||
except Exception as e:
|
||||
line('CLEANUP_TICKET_ERR', e)
|
||||
try:
|
||||
if partner_id:
|
||||
p = kw('res.partner', 'read', [[partner_id], ['email']])
|
||||
if p and p[0].get('email') == SMOKE_EMAIL:
|
||||
kw('res.partner', 'unlink', [[partner_id]])
|
||||
cleanup['partner'] = True
|
||||
except Exception as e:
|
||||
line('CLEANUP_PARTNER_ERR', e)
|
||||
line('CLEANUP', cleanup)
|
||||
line('DONE', 'ok')
|
||||
Reference in New Issue
Block a user