Skip to content

Commit

Permalink
Add test for another trigger which also contains payload schema.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kami committed Jun 15, 2016
1 parent aa909f9 commit 1462bb8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
12 changes: 8 additions & 4 deletions st2common/tests/unit/test_triggers_registrar.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ def test_register_all_triggers(self):

packs_base_path = get_fixtures_base_path()
count = triggers_registrar.register_triggers(packs_base_paths=[packs_base_path])
self.assertEqual(count, 2)
self.assertEqual(count, 3)

trigger_type_dbs = TriggerType.get_all()
self.assertEqual(len(trigger_type_dbs), 2)
self.assertEqual(len(trigger_type_dbs), 3)

def test_register_triggers_from_pack(self):
base_path = get_fixtures_base_path()
Expand All @@ -45,9 +45,13 @@ def test_register_triggers_from_pack(self):
self.assertEqual(len(trigger_type_dbs), 0)

count = triggers_registrar.register_triggers(pack_dir=pack_dir)
self.assertEqual(count, 1)
self.assertEqual(count, 2)

trigger_type_dbs = TriggerType.get_all()
self.assertEqual(len(trigger_type_dbs), 1)
self.assertEqual(len(trigger_type_dbs), 2)
self.assertEqual(trigger_type_dbs[0].name, 'event_handler')
self.assertEqual(trigger_type_dbs[0].pack, 'dummy_pack_1')

self.assertEqual(trigger_type_dbs[1].name, 'head_sha_monitor')
self.assertEqual(trigger_type_dbs[1].pack, 'dummy_pack_1')
self.assertEqual(trigger_type_dbs[1].payload_schema['type'], 'object')
25 changes: 25 additions & 0 deletions st2tests/st2tests/fixtures/dummy_pack_1/triggers/git_commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "head_sha_monitor"
description: "Trigger which indicates that a new commit has been detected"
payload_schema:
type: "object"
properties:
author:
type: "string"
author_email:
type: "string"
authored_date:
type: "string"
author_tz_offset:
type: "string"
committer:
type: "string"
committer_email:
type: "string"
committed_date:
type: "string"
committer_tz_offset:
type: "string"
revision:
type: "string"
branch:
type: "string"

0 comments on commit 1462bb8

Please sign in to comment.