How to use triggers method in qawolf

Best JavaScript code snippet using qawolf

deploy_test.js

Source:deploy_test.js Github

copy

Full Screen

1'use strict';2const assert = require('chai').assert;3const expect = require('chai').expect;4const sinon = require('sinon');5const datastore = require('../datastore');6const deploy = require('../deploy');7const google = require('googleapis');8const sandbox = sinon.createSandbox();9describe('deploy.deployConfig()', function() {10 // TODO: issue stubbing function in a 'then' statement11});12describe('deploy.deleteDeployment()', function() {13 // TODO: issue stubbing function in a 'then' statement14});15describe('deploy.getTriggers()', function() {16 const path = ['ScheduledDeployments', 123456];17 const scheduledDeployment = {name: 'test-deployment', path: path};18 let getEntityKeyStub;19 let getChildrenOfEntityStub;20 beforeEach(function() {21 getEntityKeyStub = sandbox.stub(datastore, 'getEntityKey');22 getChildrenOfEntityStub = sandbox.stub(datastore, 'getChildrenOfEntity');23 getEntityKeyStub.returns({path: path});24 });25 afterEach(function() {26 sandbox.restore();27 });28 it('gets successfully', function() {29 const triggers =30 [{name: 'trigger-one'}, {name: 'trigger-two'}, {name: 'trigger-three'}];31 getChildrenOfEntityStub.resolves([triggers]);32 return deploy.getTriggers(scheduledDeployment)33 .then(function(returnedTriggers) {34 expect(returnedTriggers).to.equal(triggers);35 });36 });37 it('returns a rejected promise upon error', function() {38 const error = new Error('Uh oh!');39 getChildrenOfEntityStub.rejects(error);40 return deploy.getTriggers(scheduledDeployment).catch(function(err) {41 expect(err).to.equal(error);42 });43 });44});45describe('deploy.getActiveTriggers()', function() {46 let isTriggerFormatValidStub;47 let crontabWithinIntervalStub;48 let clock;49 let parent;50 beforeEach(function() {51 clock = sinon.useFakeTimers(Date.parse('2017-08-10 00:30:00'));52 parent = {id: 11, name: 'test-deployment'};53 });54 afterEach(function() {55 sandbox.restore();56 clock.restore();57 });58 it('returns an empty array if list of Triggers is empty', function() {59 const triggers = [];60 return deploy.getActiveTriggers(triggers, parent)61 .then(function(activeTriggers) {62 assert.equal(activeTriggers.length, 0);63 });64 });65 it('rejects Promise if any Trigger has an invalid format', function() {66 const triggers = [67 {68 'name': 'test-trigger',69 'type': 'timer',70 'time': '30 10 * * *',71 'action': 'CREATE_OR_UPDATE'72 },73 {74 'name': 'invalid-trigger',75 'type': 'timer',76 'time': '30 12 * * *',77 'action': 'THIS_IS_NOT_AN_ACTION'78 }79 ];80 return deploy.getActiveTriggers(triggers, parent)81 .then(function() {82 return Promise.reject('Promise was not supposed to succeed.');83 })84 .catch(function(err) {85 expect(err).to.exist;86 });87 });88 it('returns an empty array if no Triggers are active', function() {89 parent.lastDeployed = Date.parse('2017-08-10 00:25:00');90 const triggers = [91 {92 'name': 'first-trigger',93 'type': 'timer',94 'time': '20 0 * * *',95 'action': 'CREATE_OR_UPDATE'96 },97 {98 'name': 'second-trigger',99 'type': 'timer',100 'time': '30 0 9 8 *',101 'action': 'CREATE_OR_UPDATE'102 }103 ];104 return deploy.getActiveTriggers(triggers, parent)105 .then(function(activeTriggers) {106 assert.equal(activeTriggers.length, 0);107 });108 });109 it('returns a single active Trigger', function() {110 parent.lastDeployed = Date.parse('2017-08-10 00:20:00');111 const trigger1 = {112 'name': 'create-trigger',113 'type': 'timer',114 'time': '20 0 * * *',115 'action': 'CREATE_OR_UPDATE'116 };117 const trigger2 = {118 'name': 'delete-trigger',119 'type': 'timer',120 'time': '30 0 * * *',121 'action': 'DELETE'122 };123 return deploy.getActiveTriggers([trigger1, trigger2], parent)124 .then(function(activeTriggers) {125 assert.equal(activeTriggers.length, 1);126 assert.deepEqual(127 activeTriggers[0],128 {timestamp: Date.parse('2017-08-10 00:30:00'), entity: trigger2});129 });130 });131 it('returns two active triggers', function() {132 parent.lastDeployed = Date.parse('2017-08-10 00:20:00');133 const trigger1 = {134 'name': 'create-trigger',135 'type': 'timer',136 'time': '33 0 * * *',137 'action': 'CREATE_OR_UPDATE'138 };139 const trigger2 = {140 'name': 'delete-trigger',141 'type': 'timer',142 'time': '34 0 * * *',143 'action': 'DELETE'144 };145 return deploy.getActiveTriggers([trigger1, trigger2], parent)146 .then(function(activeTriggers) {147 assert.equal(activeTriggers.length, 2);148 assert.deepEqual(activeTriggers, [149 {timestamp: Date.parse('2017-08-10 00:33:00'), entity: trigger1},150 {timestamp: Date.parse('2017-08-10 00:34:00'), entity: trigger2}151 ]);152 });153 });154});155describe('deploy.processActiveTriggers()', function() {156 const parent = {id: 11, name: 'test-deployment'};157 const timestamp = (new Date()).getTime();158 const laterTimestamp = timestamp + 1;159 let getEntityKeyStub;160 let deployConfigStub;161 let deleteDeploymentStub;162 beforeEach(function() {163 deployConfigStub = sandbox.stub(deploy, 'deployConfig');164 deleteDeploymentStub = sandbox.stub(deploy, 'deleteDeployment');165 getEntityKeyStub = sandbox.stub(datastore, 'getEntityKey');166 getEntityKeyStub.returns({id: 11});167 });168 afterEach(function() {169 sandbox.restore();170 });171 it('takes no action if list of triggers is empty', function() {172 const triggers = [];173 deploy.processActiveTriggers(triggers, parent);174 assert.equal(deployConfigStub.callCount, 0);175 assert.equal(deleteDeploymentStub.callCount, 0);176 });177 it('invokes deployment if latest active trigger is CREATE_OR_UPDATE',178 function() {179 const createTrigger = {180 timestamp: laterTimestamp,181 entity: {182 'name': 'create-trigger',183 'type': 'timer',184 'time': '34 0 * * *',185 'action': 'CREATE_OR_UPDATE'186 }187 };188 const deleteTrigger = {189 timestamp: timestamp,190 entity: {191 'name': 'delete-trigger',192 'type': 'timer',193 'time': '33 0 * * *',194 'action': 'DELETE'195 }196 };197 deploy.processActiveTriggers([createTrigger, deleteTrigger], parent);198 assert.equal(deleteDeploymentStub.callCount, 0);199 assert.equal(deployConfigStub.callCount, 1);200 assert(deployConfigStub.calledWith(createTrigger.entity));201 });202 it('invokes deployment deletion if latest active trigger is DELETE',203 function() {204 const triggers = [205 {206 timestamp: timestamp,207 entity: {208 'name': 'create-trigger',209 'type': 'timer',210 'time': '33 0 * * *',211 'action': 'CREATE_OR_UPDATE'212 }213 },214 {215 timestamp: laterTimestamp,216 entity: {217 'name': 'delete-trigger',218 'type': 'timer',219 'time': '34 0 * * *',220 'action': 'DELETE'221 }222 }223 ];224 deploy.processActiveTriggers(triggers, parent);225 assert.equal(deployConfigStub.callCount, 0);226 assert.equal(deleteDeploymentStub.callCount, 1);227 });228});229describe('deploy.crontabWithinInterval()', function() {230 const range = 10; // minutes between Cron events231 const lastDeployed = Date.parse('2017-08-10 00:00:00');232 it('make deployment now', function() {233 const time = Date.parse('2017-08-10 00:15:00');234 const crontab = '* * * * *';235 return deploy.crontabWithinInterval(time, range, crontab, lastDeployed)236 .then(function(response) {237 expect(response).to.equal(time);238 })239 });240 it('make upcoming deployment at edge of time interval', function() {241 const time = Date.parse('2017-08-10 00:15:00');242 const crontab = '10 * * * *';243 return deploy.crontabWithinInterval(time, range, crontab, lastDeployed)244 .then(function(response) {245 expect(response).to.equal(Date.parse('2017-08-10 00:10:00'));246 });247 });248 it('make previous deployment at edge of time interval', function() {249 const time = Date.parse('2017-08-10 00:35:00');250 const crontab = '30 * * * *';251 return deploy.crontabWithinInterval(time, range, crontab, lastDeployed)252 .then(function(response) {253 expect(response).to.equal(Date.parse('2017-08-10 00:30:00'));254 });255 });256 it('make a missed deployment; time is past interval end', function() {257 const time = Date.parse('2017-08-10 10:35:01');258 const crontab = '30 10 * * *';259 return deploy.crontabWithinInterval(time, range, crontab, lastDeployed)260 .then(function(response) {261 expect(response).to.equal(Date.parse('2017-08-10 10:30:00'));262 });263 });264 it('no deployment; time is past interval start', function() {265 const time = Date.parse('2017-08-10 00:24:59');266 const crontab = '30 * * * *';267 return deploy.crontabWithinInterval(time, range, crontab, lastDeployed)268 .then(function(response) {269 expect(response).to.equal(0);270 });271 });272 it('interprets fancy crontab', function() {273 const time = Date.parse('2017-08-10 03:16:00');274 const crontab = '20 3,9 10-15 Aug *';275 return deploy.crontabWithinInterval(time, range, crontab, lastDeployed)276 .then(function(response) {277 expect(response).to.equal(Date.parse('2017-08-10 03:20:00'));278 });279 });280});281describe('deploy.compareTriggers()', function() {282 const one = {283 timestamp: Date.parse('2017-08-10 00:01:00'),284 entity: {name: 'apple'}285 };286 const two = {287 timestamp: Date.parse('2017-08-10 00:02:00'),288 entity: {name: 'banana'}289 };290 const three = {291 timestamp: Date.parse('2017-08-10 00:01:00'),292 entity: {name: 'banana'}293 };294 it('prioritizes later timestamp as first parameter', function() {295 const response = deploy.compareTriggers(two, one);296 assert.equal(response, -1);297 });298 it('prioritizes later timestamp as second parameter', function() {299 const response = deploy.compareTriggers(one, two);300 assert.equal(response, 1);301 });302 it('prioritizes first parameter with later alphabetical name if timestamps equal',303 function() {304 const response = deploy.compareTriggers(three, one);305 assert.equal(response, -1);306 });307 it('prioritizes second parameter with later alphabetical name if timestamps equal',308 function() {309 const response = deploy.compareTriggers(one, three);310 assert.equal(response, 1);311 });312 it('gives equal priority to identical timestamps and names', function() {313 const response = deploy.compareTriggers(one, one);314 assert.equal(response, 0);315 });...

Full Screen

Full Screen

triggers_tests.py

Source:triggers_tests.py Github

copy

Full Screen

...24 the_dict = {}25 sg = student_groups.StudentGroupDTO(self.COURSE_NAME, the_dict)26 self.assertEquals([], cls.copy_from_settings(sg))27 self.assertFalse(settings_name in the_dict)28 expected_triggers = self.create_triggers(cls)29 # Copy each encoded trigger in the expected_triggers into the30 # StudentGroupDTO property, so that they are distinct dict objects.31 sg.set_triggers(32 settings_name, [et.copy() for et in expected_triggers])33 self.assertTrue(settings_name in the_dict)34 self.assertItemsEqual(expected_triggers, cls.copy_from_settings(sg))35 def check_in_student_group(self, cls, settings_name):36 # in_settings() has side-effects on the supplied settings if empty.37 the_dict = {}38 sg = student_groups.StudentGroupDTO(self.COURSE_NAME, the_dict)39 self.assertEquals([], cls.in_settings(sg))40 self.assertTrue(settings_name in the_dict)41 expected_triggers = self.create_triggers(cls)42 # Copy each encoded trigger in the expected_triggers into the43 # StudentGroupDTO property, so that they are distinct dict objects.44 sg.set_triggers(45 settings_name, [et.copy() for et in expected_triggers])46 self.assertTrue(settings_name in the_dict)47 self.assertItemsEqual(expected_triggers, cls.in_settings(sg))48 def create_payload_triggers(self, cls, availabilities=None, payload=None):49 payload, expected_triggers, env = self.BASE.create_payload_triggers(50 self, cls, availabilities=availabilities, payload=payload)51 properties = {cls.SETTINGS_NAME: expected_triggers}52 # Course start/end date/time settings in the 'course' dict of the53 # Course settings map to StudentGroupDTO properties of the same name.54 for setting, when in env.get('course', {}).iteritems():55 properties[setting] = when56 expected_group = student_groups.StudentGroupDTO(57 self.COURSE_NAME, properties)58 return payload, expected_triggers, expected_group59 def check_payload_into_student_group(self, cls, settings_name):60 """Checks payload_into_settings, from_payload, set_into_settings."""61 payload, expected_triggers, expected = self.create_payload_triggers(62 cls, availabilities=cls.AVAILABILITY_VALUES)63 the_dict = {}64 sg = student_groups.StudentGroupDTO(self.COURSE_NAME, the_dict)65 cls.payload_into_settings(payload, self.course, sg)66 # Order should not matter, but the way the triggers values are67 # generated, for some trigger test classes, they are in fact in68 # a particular order (e.g. in KNOWN_MILESTONE order).69 self.assertItemsEqual(expected_triggers,70 sg.get_triggers(settings_name))71 self.assertItemsEqual(expected_triggers,72 the_dict[settings_name])73 # So, place the potentially non-ordered results in that order before74 # comparing nested structures that contain them.75 not_in_order = sg.get_triggers(settings_name)76 in_order = self.place_triggers_in_expected_order(not_in_order, cls)77 sg.set_triggers(settings_name, in_order)78 self.assertEquals(expected.dict, sg.dict)79 # Absent from payload should remove from settings. Use student_group80 # created above, since it will have properties needing removal81 # (start_date and end_date).82 cls.payload_into_settings(self.empty_form, self.course, sg)83 # Property is always obtained from StudentGroupDTO, but as empty list.84 self.assertEquals([], sg.get_triggers(settings_name))85 # Even when not actually stored as an empty list inside the DTO.86 self.assertEquals({settings_name: []}, sg.dict)87 self.assertEquals([], the_dict.get(settings_name))88class ContentOverrideTriggerTests(OverrideTriggerTestsMixin,89 triggers_tests.ContentTriggerTestBase):90 """Tests the ContentOverrideTrigger class."""91 # "Content Override Trigger Test", but UNICODE-obfuscated.92 COURSE_TITLE = u'ℂȫἢťеηţ Őύėɼгῑɗё Тṙіɠǵḛѓ Τѐṡʈ'93 COURSE_NAME = 'content_override_trigger_test'94 sg_content_ot = student_groups.ContentOverrideTrigger95 BASE = triggers_tests.ContentTriggerTestBase96 def test_name_logged_str(self):97 self.check_names(self.sg_content_ot,98 availabilities=self.sg_content_ot.AVAILABILITY_VALUES)...

Full Screen

Full Screen

config+commands.template.ts

Source:config+commands.template.ts Github

copy

Full Screen

1/*2..######...#######..##.....##.##.....##....###....##....##.########...######.3.##....##.##.....##.###...###.###...###...##.##...###...##.##.....##.##....##4.##.......##.....##.####.####.####.####..##...##..####..##.##.....##.##......5.##.......##.....##.##.###.##.##.###.##.##.....##.##.##.##.##.....##..######.6.##.......##.....##.##.....##.##.....##.#########.##..####.##.....##.......##7.##....##.##.....##.##.....##.##.....##.##.....##.##...###.##.....##.##....##8..######...#######..##.....##.##.....##.##.....##.##....##.########...######.9 */10Config.events = {...Config.events,11 /*12 .######..######...####..13 ...##......##....##.....14 ...##......##.....####..15 ...##......##........##.16 ...##......##.....####..17 */18 [KeysTemplate.COMMAND_TTS_ON]: {19 triggers: {20 command: {}21 }22 },23 [KeysTemplate.COMMAND_TTS_OFF]: {24 triggers: {25 command: {}26 }27 },28 [KeysTemplate.COMMAND_TTS_SILENCE]: {29 triggers: {30 command: {}31 }32 },33 [KeysTemplate.COMMAND_TTS_DIE]: {34 triggers: {35 command: {}36 }37 },38 [KeysTemplate.COMMAND_TTS_NICK]: {39 triggers: {40 command: {41 permissions: {42 VIPs: true,43 subscribers: true44 }45 }46 }47 },48 [KeysTemplate.COMMAND_TTS_MUTE]: {49 triggers: {50 command: {}51 }52 },53 [KeysTemplate.COMMAND_TTS_UNMUTE]: {54 triggers: {55 command: {}56 }57 },58 [KeysTemplate.COMMAND_TTS_VOICES]: {59 triggers: {60 command: {61 permissions: {62 everyone: true63 },64 cooldown: 60 * 565 }66 },67 actions: {68 chat: 'Preview Google TTS voices here, pick a Wavenet (mandatory) voice and use the name with the "Set Your Voice" reward: https://cloud.google.com/text-to-speech/docs/voices'69 }70 },71 /*72 ..####...##..##...####...######.73 .##..##..##..##..##..##....##...74 .##......######..######....##...75 .##..##..##..##..##..##....##...76 ..####...##..##..##..##....##...77 */78 [KeysTemplate.COMMAND_CHAT]: {79 triggers: {80 command: {81 permissions: {82 VIPs: true83 }84 }85 }86 },87 [KeysTemplate.COMMAND_CHAT_ON]: {88 triggers: {89 command: {}90 }91 },92 [KeysTemplate.COMMAND_CHAT_OFF]: {93 triggers: {94 command: {}95 }96 },97 [KeysTemplate.COMMAND_PING_ON]: {98 triggers: {99 command: {}100 }101 },102 [KeysTemplate.COMMAND_PING_OFF]: {103 triggers: {104 command: {}105 }106 },107 [KeysTemplate.COMMAND_QUOTE]: {108 triggers: {109 command: {}110 }111 },112 /*113 .##.......####....####..114 .##......##..##..##.....115 .##......##..##..##.###.116 .##......##..##..##..##.117 .######...####....####..118 */119 [KeysTemplate.COMMAND_LOG_ON]: {120 triggers: {121 command: {122 permissions: {123 moderators: false124 }125 }126 }127 },128 [KeysTemplate.COMMAND_LOG_OFF]: {129 triggers: {130 command: {131 permissions: {132 moderators: false133 }134 }135 }136 },137 /*138 ..####....####....####...##......######.139 .##......##..##..##..##..##......##.....140 ..####...##......######..##......####...141 .....##..##..##..##..##..##......##.....142 ..####....####...##..##..######..######.143 */144 [KeysTemplate.COMMAND_SCALE]: {145 triggers: {146 command: {}147 }148 },149 /*150 ..####...######..######...####...##...##..##..##..#####..151 .##........##....##......##..##..###.###..##..##..##..##.152 ..####.....##....####....######..##.#.##..##..##..#####..153 .....##....##....##......##..##..##...##...####...##..##.154 ..####.....##....######..##..##..##...##....##....##..##.155 */156 [KeysTemplate.COMMAND_BRIGHTNESS]: {157 triggers: {158 command: {159 permissions: {160 moderators: false161 }162 }163 }164 },165 [KeysTemplate.COMMAND_REFRESHRATE]: {166 triggers: {167 command: {168 permissions: {169 moderators: false170 }171 }172 }173 },174 [KeysTemplate.COMMAND_VRVIEWEYE]: {175 triggers: {176 command: {177 permissions: {178 moderators: false179 }180 }181 }182 },183 /*184 .#####...######...####...######..######...####...##..##...####...#####...##..##.185 .##..##....##....##..##....##......##....##..##..###.##..##..##..##..##...####..186 .##..##....##....##........##......##....##..##..##.###..######..#####.....##...187 .##..##....##....##..##....##......##....##..##..##..##..##..##..##..##....##...188 .#####...######...####.....##....######...####...##..##..##..##..##..##....##...189 */190 [KeysTemplate.COMMAND_DICTIONARY]: {191 triggers: {192 command: {}193 }194 },195 /*196 .#####...######..##...##...####...#####...#####....####..197 .##..##..##......##...##..##..##..##..##..##..##..##.....198 .#####...####....##.#.##..######..#####...##..##...####..199 .##..##..##......#######..##..##..##..##..##..##......##.200 .##..##..######...##.##...##..##..##..##..#####....####..201 */202 [KeysTemplate.COMMAND_UPDATEREWARDS]: {203 triggers: {204 command: {205 permissions: {206 moderators: false207 }208 }209 }210 },211 [KeysTemplate.COMMAND_GAMEREWARDS_ON]: {212 triggers: {213 command: {}214 }215 },216 [KeysTemplate.COMMAND_GAMEREWARDS_OFF]: {217 triggers: {218 command: {}219 }220 },221 [KeysTemplate.COMMAND_REFUND_REDEMPTION]: {222 triggers: {223 command: {224 cooldown: 30225 }226 }227 },228 [KeysTemplate.COMMAND_CLEAR_REDEMPTIONS]: {229 triggers: {230 command: {231 permissions: {232 moderators: false233 },234 cooldown: 60235 }236 }237 },238 [KeysTemplate.COMMAND_RESET_INCREWARD]: {239 triggers: {240 command: {241 permissions: {242 moderators: false243 },244 cooldown: 20245 }246 }247 },248 /*249 ..####...##..##...####...######..######..##...##.250 .##.......####...##........##....##......###.###.251 ..####.....##.....####.....##....####....##.#.##.252 .....##....##........##....##....##......##...##.253 ..####.....##.....####.....##....######..##...##.254 */ 255 [KeysTemplate.COMMAND_RELOADWIDGET]: {256 triggers: {257 command: {258 permissions: {259 moderators: false260 }261 }262 }263 },264 [KeysTemplate.COMMAND_CHANNELTROPHY_STATS]: {265 triggers: {266 command: {267 permissions: {268 moderators: false269 }270 }271 }272 },273 [KeysTemplate.COMMAND_CLIPS]: {274 triggers: {275 command: {276 permissions: {277 moderators: false278 }279 }280 }281 },282 [KeysTemplate.COMMAND_GAMERESET]: {283 triggers: {284 command: {285 permissions: {286 moderators: false287 }288 }289 }290 },291 [KeysTemplate.COMMAND_RAID]: {292 triggers: {293 command: {}294 }295 },296 [KeysTemplate.COMMAND_UNRAID]: {297 triggers: {298 command: {}299 }300 },301 /*302 .#####...##..##..#####...##......######...####..303 .##..##..##..##..##..##..##........##....##..##.304 .#####...##..##..#####...##........##....##.....305 .##......##..##..##..##..##........##....##..##.306 .##.......####...#####...######..######...####..307 */308 [KeysTemplate.COMMAND_GAME]: {309 triggers: {310 command: {311 permissions: {312 everyone: true313 },314 cooldown: 3*60315 }316 },317 actions: {318 sign: {319 title: 'Current Game',320 image: '%gameBanner',321 subtitle: '%gameName\n%gamePrice',322 durationMs: 10000323 },324 chat: 'Game: %gameName - Released: %gameRelease - Price: %gamePrice - Link: %gameLink'325 }326 },327 /*328 .######..##..##...####...##...##..#####...##......######...####..329 .##.......####...##..##..###.###..##..##..##......##......##.....330 .####......##....######..##.#.##..#####...##......####.....####..331 .##.......####...##..##..##...##..##......##......##..........##.332 .######..##..##..##..##..##...##..##......######..######...####..333 */334 [KeysTemplate.COMMAND_SAY]: { // Announces something with the TTS335 triggers: {336 command: {}337 },338 actions: {339 speech: {340 entries: '%userInput'341 }342 }343 },344 [KeysTemplate.COMMAND_LABEL]: { // Writes a label to the disk that can be used as a source345 triggers: {346 command: {}347 },348 actions: {349 speech: {350 entries: 'Label set to "%userInput"'351 },352 label: "your_label_in_settings.txt"353 }354 },355 [KeysTemplate.COMMAND_TODO]: { // Puts a post in Discord using the Discord webhook with the same key356 triggers: {357 command: {}358 },359 actions: {360 speech: {361 entries: 'To do list appended with: %userInput'362 },363 discord: '-> %userInput'364 }365 },366 [KeysTemplate.COMMAND_END_STREAM]: {367 triggers: {368 command: {369 permissions: {370 moderators: false371 }372 }373 },374 actions: {375 speech: {376 entries: 'Running stream end tasks'377 },378 commands: { 379 entries: [380 KeysTemplate.COMMAND_CHANNELTROPHY_STATS,381 KeysTemplate.COMMAND_CLIPS,382 KeysTemplate.COMMAND_CLEAR_REDEMPTIONS,383 KeysTemplate.COMMAND_RESET_INCREWARD384 ],385 interval: 20386 }387 }388 }...

Full Screen

Full Screen

triggers.js

Source:triggers.js Github

copy

Full Screen

1Tinytest.addAsync(2'Triggers - runTriggers - run all and after',3function(test, done) {4 var store = [];5 var triggers = MakeTriggers(2, store);6 Triggers.runTriggers(triggers, null, null, function() {7 test.equal(store, [0, 1]);8 done();9 });10});11Tinytest.addAsync(12'Triggers - runTriggers - redirect with url',13function(test, done) {14 var store = [];15 var url = "http://google.com";16 var triggers = MakeTriggers(2, store);17 triggers.splice(1, 0, function(context, redirect) {18 redirect(url); 19 });20 Triggers.runTriggers(triggers, null, function(u) {21 test.equal(store, [0]);22 test.equal(u, url);23 done();24 }, null);25});26Tinytest.addAsync(27'Triggers - runTriggers - redirect without url',28function(test, done) {29 var store = [];30 var url = "http://google.com";31 var triggers = MakeTriggers(2, store);32 triggers.splice(1, 0, function(context, redirect) {33 try {34 redirect(); 35 } catch(ex) {36 test.isTrue(/requires an URL/.test(ex.message));37 test.equal(store, [0]);38 done();39 }40 });41 Triggers.runTriggers(triggers, null, null, null);42});43Tinytest.addAsync(44'Triggers - runTriggers - redirect in a different event loop',45function(test, done) {46 var store = [];47 var url = "http://google.com";48 var triggers = MakeTriggers(2, store);49 var doneCalled = false;50 triggers.splice(1, 0, function(context, redirect) {51 setTimeout(function() {52 try {53 redirect(url); 54 } catch(ex) {55 test.isTrue(/sync/.test(ex.message));56 test.equal(store, [0, 1]);57 test.isTrue(doneCalled);58 done();59 }60 }, 0);61 });62 Triggers.runTriggers(triggers, null, null, function() {63 doneCalled = true;64 });65});66Tinytest.addAsync(67'Triggers - runTriggers - redirect called multiple times',68function(test, done) {69 var store = [];70 var url = "http://google.com";71 var triggers = MakeTriggers(2, store);72 var redirectCalled = false;73 triggers.splice(1, 0, function(context, redirect) {74 redirect(url); 75 try {76 redirect(url);77 } catch(ex) {78 test.isTrue(/already redirected/.test(ex.message));79 test.equal(store, [0]);80 test.isTrue(redirectCalled);81 done();82 }83 });84 Triggers.runTriggers(triggers, null, function() {85 redirectCalled = true;86 }, null);87});88Tinytest.addAsync(89'Triggers - runTriggers - stop callback',90function(test, done) {91 var store = [];92 var triggers = MakeTriggers(2, store);93 triggers.splice(1, 0, function(context, redirect, stop) {94 stop();95 });96 Triggers.runTriggers(triggers, null, null, function() {97 store.push(2);98 });99 test.equal(store, [0]);100 done();101});102Tinytest.addAsync(103'Triggers - runTriggers - get context',104function(test, done) {105 var context = {};106 var trigger = function(c) {107 test.equal(c, context);108 done();109 };110 Triggers.runTriggers([trigger], context, function() {}, function() {});111});112Tinytest.addAsync(113'Triggers - createRouteBoundTriggers - matching trigger',114function(test, done) {115 var context = {route: {name: "abc"}};116 var redirect = function() {};117 var trigger = function(c, r) {118 test.equal(c, context);119 test.equal(r, redirect);120 done();121 };122 var triggers = Triggers.createRouteBoundTriggers([trigger], ["abc"]);123 triggers[0](context, redirect);124});125Tinytest.addAsync(126'Triggers - createRouteBoundTriggers - multiple matching triggers',127function(test, done) {128 var context = {route: {name: "abc"}};129 var redirect = function() {};130 var doneCount = 0;131 var trigger = function(c, r) {132 test.equal(c, context);133 test.equal(r, redirect);134 doneCount++;135 };136 var triggers = Triggers.createRouteBoundTriggers([trigger, trigger], ["abc"]);137 triggers[0](context, redirect);138 triggers[1](context, redirect);139 test.equal(doneCount, 2);140 done();141});142Tinytest.addAsync(143'Triggers - createRouteBoundTriggers - no matching trigger',144function(test, done) {145 var context = {route: {name: "some-other-route"}};146 var redirect = function() {};147 var doneCount = 0;148 var trigger = function(c, r) {149 test.equal(c, context);150 test.equal(r, redirect);151 doneCount++;152 };153 var triggers = Triggers.createRouteBoundTriggers([trigger], ["abc"]);154 triggers[0](context, redirect);155 test.equal(doneCount, 0);156 done();157});158Tinytest.addAsync(159'Triggers - createRouteBoundTriggers - negate logic',160function(test, done) {161 var context = {route: {name: "some-other-route"}};162 var redirect = function() {};163 var doneCount = 0;164 var trigger = function(c, r) {165 test.equal(c, context);166 test.equal(r, redirect);167 doneCount++;168 };169 var triggers = Triggers.createRouteBoundTriggers([trigger], ["abc"], true);170 triggers[0](context, redirect);171 test.equal(doneCount, 1);172 done();173});174Tinytest.addAsync(175'Triggers - applyFilters - no filters',176function(test, done) {177 var original = [];178 test.equal(Triggers.applyFilters(original), original);179 done();180});181Tinytest.addAsync(182'Triggers - applyFilters - single trigger to array',183function(test, done) {184 var original = function() {};185 test.equal(Triggers.applyFilters(original)[0], original);186 done();187});188Tinytest.addAsync(189'Triggers - applyFilters - only and except both',190function(test, done) {191 var original = [];192 try {193 Triggers.applyFilters(original, {only: [], except: []});194 } catch(ex) {195 test.isTrue(/only and except/.test(ex.message));196 done();197 }198});199Tinytest.addAsync(200'Triggers - applyFilters - only is not an array',201function(test, done) {202 var original = [];203 try {204 Triggers.applyFilters(original, {only: "name"});205 } catch(ex) {206 test.isTrue(/to be an array/.test(ex.message));207 done();208 }209});210Tinytest.addAsync(211'Triggers - applyFilters - except is not an array',212function(test, done) {213 var original = [];214 try {215 Triggers.applyFilters(original, {except: "name"});216 } catch(ex) {217 test.isTrue(/to be an array/.test(ex.message));218 done();219 }220});221Tinytest.addAsync(222'Triggers - applyFilters - unsupported filter',223function(test, done) {224 var original = [];225 try {226 Triggers.applyFilters(original, {wowFilter: []});227 } catch(ex) {228 test.isTrue(/not supported/.test(ex.message));229 done();230 }231});232Tinytest.addAsync(233'Triggers - applyFilters - just only filter',234function(test, done) {235 var bounded = Triggers.applyFilters(done, {only: ["abc"]});236 bounded[0]({route: {name: "abc"}});237});238Tinytest.addAsync(239'Triggers - applyFilters - just except filter',240function(test, done) {241 var bounded = Triggers.applyFilters(done, {except: ["abc"]});242 bounded[0]({route: {name: "some-other"}});243});244function MakeTriggers(count, store) {245 var triggers = [];246 function addTrigger(no) {247 triggers.push(function() {248 store.push(no);249 });250 }251 for(var lc=0; lc<count; lc++) {252 addTrigger(lc);253 }254 return triggers;...

Full Screen

Full Screen

trigger.py

Source:trigger.py Github

copy

Full Screen

1#!/usr/bin/env python2# -*- coding: utf-8 -*-3import re4import click5from clk.colors import Colorer6from clk.commands.alias import get_choices7from clk.config import config8from clk.decorators import argument, flag, group, use_settings9from clk.lib import echo_key_value, quote10from clk.log import get_logger11from clk.overloads import CommandSettingsKeyType, CommandType12LOGGER = get_logger(__name__)13def format(cmds):14 """Format the trigger command"""15 return ' , '.join(' '.join(quote(arg) for arg in cmd) for cmd in cmds)16class TriggersConfig(object):17 pass18@group()19@use_settings('triggers', TriggersConfig, override=False)20def trigger():21 """Manipulate command triggers22 It is mostly useful if you want to trigger specific behaviors around usual23 commands, generally to work around issues in tools you are forced to use.24 To trigger the execution of a command B each time a command A is executed,25 and just before, run:26 triggers pre set A B27 To trigger the execution of a command B only after a successful execution of A:28 triggers onsuccess set A B29 To add the trigger of the execution of a command C after a successful30 execution of A (hence a successful execution of A would run B, and then C):31 triggers onsuccess append A C32 """33 pass34@trigger.command(ignore_unknown_options=True, change_directory_options=False, handle_dry_run=True)35@argument('position', type=click.Choice(['pre', 'post', 'error', 'success']), help='The trigger position')36@argument('cmd', type=CommandType(), help='The command to which the trigger is associated command')37@argument('triggered-command', type=CommandType(), help='The command to trigger')38@argument('params', nargs=-1, help='The parameters passed to the triggered command')39def set(cmd, triggered_command, params, position):40 """Set a triggers"""41 if cmd.startswith('-'):42 raise click.UsageError('triggers must not start with dashes (-)')43 if re.match(r'^\w', cmd) is None:44 raise click.ClickException('Invalid triggers name: ' + cmd)45 commands = []46 text = [triggered_command] + list(params)47 sep = ','48 while sep in text:49 index = text.index(sep)50 commands.append(text[:index])51 del text[:index + 1]52 if text:53 commands.append(text)54 if cmd in config.triggers.writable:55 config.triggers.writable[cmd][position] = commands56 else:57 config.triggers.writable[cmd] = {position: commands}58 config.triggers.write()59set.get_choices = get_choices60@trigger.command(handle_dry_run=True)61@argument('position', type=click.Choice(['pre', 'post', 'error', 'success']), help='The trigger position')62@argument('cmds',63 nargs=-1,64 type=CommandSettingsKeyType('triggers'),65 help='The commands where the triggers will be unset')66def unset(cmds, position):67 """Unset some triggers"""68 for cmd in cmds:69 if cmd not in config.triggers.writable:70 raise click.ClickException("The %s configuration has no '%s' triggers registered."71 'Try using another profile option (like --local or --global)' %72 (config.triggers.writeprofile, cmd))73 for cmd in cmds:74 LOGGER.status('Erasing {} triggers from {} settings'.format(cmd, config.triggers.writeprofile))75 del config.triggers.writable[cmd]76 config.triggers.write()77@trigger.command(handle_dry_run=True)78@flag(79 '--name-only/--no-name-only',80 help='Only display the triggers names',81)82@Colorer.color_options83@argument('position', type=click.Choice(['pre', 'post', 'error', 'success']), help='The trigger position')84@argument('triggers', nargs=-1, type=CommandSettingsKeyType('triggers'), help='The commands to show')85def show(name_only, triggers, position, **kwargs):86 """Show the triggers"""87 show_triggers = triggers or sorted(config.triggers.readonly.keys())88 with Colorer(kwargs) as colorer:89 for triggers_ in show_triggers:90 if name_only:91 click.echo(triggers_)92 else:93 values = {94 profile.name: format(config.triggers.all_settings[profile.name].get(triggers_,95 {}).get(position, []))96 for profile in config.all_enabled_profiles97 }98 args = colorer.colorize(values, config.triggers.readprofile)99 echo_key_value(triggers_, ' , '.join(args), config.alt_style)100@trigger.command(handle_dry_run=True)101@argument('origin', type=CommandSettingsKeyType('triggers'), help='The current trigger')102@argument('destination', help='The new trigger')103@argument('position', type=click.Choice(['pre', 'post', 'error', 'success']), help='The trigger position')104def rename(origin, destination, position):105 """Rename a triggers"""106 config.triggers.writable[destination] = config.triggers.readonly[origin]107 if origin in config.triggers.writable:108 del config.triggers.writable[origin]109 # rename the triggers when used in the other triggers110 renamed_in = set()111 for a, data in config.triggers.writable.items():112 cmds = data[position]113 for cmd in cmds:114 if cmd[0] == origin:115 LOGGER.debug('%s renamed in %s' % (origin, a))116 cmd[0] = destination117 renamed_in.add(a)118 # warn the user if the triggers is used at other profile, and thus has not been renamed there119 for a, cmds in config.triggers.readonly.items():120 cmds = data[position]121 for cmd in cmds:122 if cmd[0] == origin and a not in renamed_in:123 LOGGER.warning('%s is still used in %s at another configuration profile.'124 ' You may want to correct this manually.' % (origin, a))125 config.triggers.write()126@trigger.command(ignore_unknown_options=True, handle_dry_run=True)127@argument('cmd', type=CommandType(), help='The command to modify')128@argument('params', nargs=-1, required=True, help='The extra parameters')129@argument('position', type=click.Choice(['pre', 'post', 'error', 'success']), help='The trigger position')130def append(cmd, params, position):131 """Add some commands at the end of the triggers"""132 commands = []133 text = list(params)134 sep = ','135 while sep in text:136 index = text.index(sep)137 commands.append(text[:index])138 del text[:index + 1]139 if text:140 commands.append(text)141 data = config.triggers.readonly.get(cmd, {})142 data[position] = data.get(position, []) + commands143 config.triggers.writable[cmd] = data144 config.triggers.write()...

Full Screen

Full Screen

Base.js

Source:Base.js Github

copy

Full Screen

1/**2 * Base class for form field triggers3 * @private4 */5Ext.define('Ext.field.trigger.Base', {6 extend: 'Ext.Widget',7 alias: 'trigger.base',8 mixins: [9 'Ext.mixin.Factoryable'10 ],11 factoryConfig: {12 defaultType: 'trigger',13 aliasPrefix: 'trigger.'14 },15 isTrigger: true,16 config: {17 /**18 * @cfg {Ext.field.Text}19 * The text field that created this trigger20 * @private21 */22 field: null,23 /**24 * @cfg {String} [group]25 * The name of an optional group trigger that this trigger belongs to. If no trigger26 * Exists by that name one will automatically be created. A group trigger is a27 * special trigger that contains other triggers. Those triggers' elements are28 * appended to the group trigger's element in the DOM.29 *30 * The {@link #weight} of grouped triggers is relative to other triggers in the group.31 */32 group: null,33 /**34 * @cfg {'left'/'right'} [side='right']35 * The side of the text field's input to render the trigger on.36 */37 side: null,38 /**39 * @cfg {String}40 * The key used to identify this trigger in the text field's triggers config.41 * @private42 */43 name: null,44 /**45 * The triggers contained in this trigger (only applicable for trigger groups)46 * @private47 */48 triggers: null49 },50 classCls: Ext.baseCSSPrefix + 'trigger',51 groupedCls: Ext.baseCSSPrefix + 'grouped',52 inheritUi: true,53 statics: {54 /**55 * Sorts an array of triggers in place by weight56 * @param {Ext.field.Trigger[]} triggers57 * @return {Ext.field.Trigger[]}58 * @private59 * @static60 */61 sort: function(triggers) {62 Ext.sortByWeight(triggers);63 return triggers;64 }65 },66 doDestroy: function() {67 var triggers = this.getTriggers(),68 i, ln;69 if (triggers) {70 for (i = 0, ln = triggers.length; i < ln; i++) {71 triggers[i].destroy();72 }73 }74 this.setTriggers(null);75 this.callParent();76 },77 updateField: function(field) {78 // All Components MUST have an upward link through either parent or ownerCmp79 this.field = this.ownerCmp = field;80 this.doInheritUi();81 },82 updateGroup: function(group) {83 if (!this.isConfiguring) {84 this.getField().syncTriggers();85 }86 },87 updateSide: function() {88 if (!this.isConfiguring) {89 this.getField().syncTriggers();90 }91 },92 updateTriggers: function(triggers) {93 var me = this,94 dom = me.element.dom,95 i, ln;96 me.toggleCls(me.groupedCls, !!(triggers && triggers.length));97 if (triggers) {98 for (i = 0, ln = triggers.length; i < ln; i++) {99 dom.appendChild(triggers[i].element.dom);100 }101 }102 }...

Full Screen

Full Screen

plot.py

Source:plot.py Github

copy

Full Screen

...48 new elements to the ``send`` method. Calls to ``next`` or 49 ``send(None)`` are ignored.50 """51 self.state = state52 self.triggers = self._format_triggers(triggers)53 self._plot = None54 @staticmethod55 def _format_triggers(triggers):56 return dict((frozenset(k), (v[0], _format_triggers(v[1])))57 for k, v in triggers.iteritems())58 def start(self, world):59 self._plot = plot(world, state, triggers)60 self._plot.next()61 def update(self, *updates):62 """Update the plot state with `updates`, and call any trigger63 functions if their elements are now present.64 Updates are applied in the order given.65 """...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { triggers } = require("qawolf");2const qawolf = require("qawolf");3const browser = await qawolf.launch();4const page = await browser.newPage();5await page.type('[name="q"]', "qawolf");6await page.click('[name="btnK"]');7await triggers.click(page, "text=QA Wolf: End-to-end testing for developers");8await triggers.click(page, "text=How to get started with QA Wolf");9await triggers.click(page, "text=Get Started");10await triggers.click(page, "text=Create an account");11await triggers.click(page, "text=Sign up");12await triggers.click(page, "text=Get started");

Full Screen

Using AI Code Generation

copy

Full Screen

1import { triggers } from 'qawolf';2describe('test', () => {3 it('test', async () => {4 await triggers();5 });6});7const { triggers } = require('qawolf');8describe('test', () => {9 it('test', async () => {10 await triggers();11 });12});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run qawolf automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful