Improve trigger tests
review690002
This commit is contained in:
1 parent
c861f0fb70
commit
6efc1f6a0c
3 files changed
+27
-6
No files matched your search
@@ -121,6 +121,7 @@ def register():
|
||||
ExportDataTarget2,
|
||||
ExportDataRelation,
|
||||
Triggered,
|
||||
TriggerAction,
|
||||
TestAccess,
|
||||
TestWizardStart,
|
||||
WorkflowedModel,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
from trytond.model import ModelSQL, fields
|
||||
|
||||
__all__ = [
|
||||
'Triggered',
|
||||
'Triggered', 'TriggerAction',
|
||||
]
|
||||
|
||||
TRIGGER_LOGS = []
|
||||
@@ -14,6 +14,11 @@ class Triggered(ModelSQL):
|
||||
__name__ = 'test.triggered'
|
||||
name = fields.Char('Name')
|
||||
|
||||
|
||||
class TriggerAction(ModelSQL):
|
||||
'Trigger Action Model'
|
||||
__name__ = 'test.trigger_action'
|
||||
|
||||
@staticmethod
|
||||
def trigger(records, trigger):
|
||||
'''
|
||||
|
||||
@@ -52,13 +52,16 @@ class TriggerTestCase(unittest.TestCase):
|
||||
model, = self.model.search([
|
||||
('model', '=', 'test.triggered'),
|
||||
])
|
||||
action_model, = self.model.search([
|
||||
('model', '=', 'test.trigger_action'),
|
||||
])
|
||||
|
||||
values = {
|
||||
'name': 'Test',
|
||||
'model': model.id,
|
||||
'on_time': True,
|
||||
'condition': 'True',
|
||||
'action_model': model.id,
|
||||
'action_model': action_model.id,
|
||||
'action_function': 'test',
|
||||
}
|
||||
self.assert_(self.trigger.create([values]))
|
||||
@@ -92,13 +95,16 @@ class TriggerTestCase(unittest.TestCase):
|
||||
model, = self.model.search([
|
||||
('model', '=', 'test.triggered'),
|
||||
])
|
||||
action_model, = self.model.search([
|
||||
('model', '=', 'test.trigger_action'),
|
||||
])
|
||||
|
||||
trigger, = self.trigger.create([{
|
||||
'name': 'Test',
|
||||
'model': model.id,
|
||||
'on_create': True,
|
||||
'condition': 'True',
|
||||
'action_model': model.id,
|
||||
'action_model': action_model.id,
|
||||
'action_function': 'trigger',
|
||||
}])
|
||||
|
||||
@@ -162,13 +168,16 @@ class TriggerTestCase(unittest.TestCase):
|
||||
model, = self.model.search([
|
||||
('model', '=', 'test.triggered'),
|
||||
])
|
||||
action_model, = self.model.search([
|
||||
('model', '=', 'test.trigger_action'),
|
||||
])
|
||||
|
||||
trigger, = self.trigger.create([{
|
||||
'name': 'Test',
|
||||
'model': model.id,
|
||||
'on_write': True,
|
||||
'condition': 'True',
|
||||
'action_model': model.id,
|
||||
'action_model': action_model.id,
|
||||
'action_function': 'trigger',
|
||||
}])
|
||||
|
||||
@@ -272,6 +281,9 @@ class TriggerTestCase(unittest.TestCase):
|
||||
model, = self.model.search([
|
||||
('model', '=', 'test.triggered'),
|
||||
])
|
||||
action_model, = self.model.search([
|
||||
('model', '=', 'test.trigger_action'),
|
||||
])
|
||||
|
||||
triggered, = self.triggered.create([{
|
||||
'name': 'Test',
|
||||
@@ -282,7 +294,7 @@ class TriggerTestCase(unittest.TestCase):
|
||||
'model': model.id,
|
||||
'on_delete': True,
|
||||
'condition': 'True',
|
||||
'action_model': model.id,
|
||||
'action_model': action_model.id,
|
||||
'action_function': 'trigger',
|
||||
}])
|
||||
|
||||
@@ -360,13 +372,16 @@ class TriggerTestCase(unittest.TestCase):
|
||||
model, = self.model.search([
|
||||
('model', '=', 'test.triggered'),
|
||||
])
|
||||
action_model, = self.model.search([
|
||||
('model', '=', 'test.trigger_action'),
|
||||
])
|
||||
|
||||
trigger, = self.trigger.create([{
|
||||
'name': 'Test',
|
||||
'model': model.id,
|
||||
'on_time': True,
|
||||
'condition': 'True',
|
||||
'action_model': model.id,
|
||||
'action_model': action_model.id,
|
||||
'action_function': 'trigger',
|
||||
}])
|
||||
|
||||
|
||||
Reference in new issue
Block a user