|
| 1 | +""" |
| 2 | +Alerts trigger tests for v2 |
| 3 | +Test Run ID: {{testRunId}} |
| 4 | +""" |
| 5 | + |
| 6 | +from firebase_functions import alerts_fn |
| 7 | + |
| 8 | +REGION = "{{region}}" |
| 9 | + |
| 10 | +# TODO: All this does is test that the function is deployable. |
| 11 | +# Since you cannot directly trigger alerts in a CI environment, we cannot test |
| 12 | +# the internals without mocking. |
| 13 | + |
| 14 | +{{#each functions}} |
| 15 | +{{#if (eq trigger "onAlertPublished")}} |
| 16 | +@alerts_fn.on_alert_published( |
| 17 | + alert_type="{{alertType}}", |
| 18 | + region=REGION, |
| 19 | + timeout_sec={{timeout}} |
| 20 | +) |
| 21 | +def {{name}}{{../testRunId}}(event: alerts_fn.AlertEvent) -> None: |
| 22 | + """ |
| 23 | + Test function: {{name}} |
| 24 | + Trigger: {{trigger}} |
| 25 | + Alert Type: {{alertType}} |
| 26 | + """ |
| 27 | + # Since we cannot trigger alerts in CI, this just tests deployability |
| 28 | + # In a real implementation, you would: |
| 29 | + # test_id = event.data.get("testId") |
| 30 | + # db = firestore.client() |
| 31 | + # db.collection("{{name}}").document(test_id).set({ |
| 32 | + # "event": str(event) |
| 33 | + # }) |
| 34 | + pass |
| 35 | + |
| 36 | +{{/if}} |
| 37 | +{{#if (eq trigger "onInAppFeedbackPublished")}} |
| 38 | +@alerts_fn.on_in_app_feedback_published( |
| 39 | + region=REGION, |
| 40 | + timeout_sec={{timeout}} |
| 41 | +) |
| 42 | +def {{name}}{{../testRunId}}(event: alerts_fn.AlertEvent) -> None: |
| 43 | + """ |
| 44 | + Test function: {{name}} |
| 45 | + Trigger: {{trigger}} |
| 46 | + """ |
| 47 | + pass |
| 48 | + |
| 49 | +{{/if}} |
| 50 | +{{#if (eq trigger "onNewTesterIosDevicePublished")}} |
| 51 | +@alerts_fn.on_new_tester_ios_device_published( |
| 52 | + region=REGION, |
| 53 | + timeout_sec={{timeout}} |
| 54 | +) |
| 55 | +def {{name}}{{../testRunId}}(event: alerts_fn.AlertEvent) -> None: |
| 56 | + """ |
| 57 | + Test function: {{name}} |
| 58 | + Trigger: {{trigger}} |
| 59 | + """ |
| 60 | + pass |
| 61 | + |
| 62 | +{{/if}} |
| 63 | +{{#if (eq trigger "onPlanAutomatedUpdatePublished")}} |
| 64 | +@alerts_fn.on_plan_automated_update_published( |
| 65 | + region=REGION, |
| 66 | + timeout_sec={{timeout}} |
| 67 | +) |
| 68 | +def {{name}}{{../testRunId}}(event: alerts_fn.AlertEvent) -> None: |
| 69 | + """ |
| 70 | + Test function: {{name}} |
| 71 | + Trigger: {{trigger}} |
| 72 | + """ |
| 73 | + pass |
| 74 | + |
| 75 | +{{/if}} |
| 76 | +{{#if (eq trigger "onPlanUpdatePublished")}} |
| 77 | +@alerts_fn.on_plan_update_published( |
| 78 | + region=REGION, |
| 79 | + timeout_sec={{timeout}} |
| 80 | +) |
| 81 | +def {{name}}{{../testRunId}}(event: alerts_fn.AlertEvent) -> None: |
| 82 | + """ |
| 83 | + Test function: {{name}} |
| 84 | + Trigger: {{trigger}} |
| 85 | + """ |
| 86 | + pass |
| 87 | + |
| 88 | +{{/if}} |
| 89 | +{{#if (eq trigger "onNewAnrIssuePublished")}} |
| 90 | +@alerts_fn.on_new_anr_issue_published( |
| 91 | + region=REGION, |
| 92 | + timeout_sec={{timeout}} |
| 93 | +) |
| 94 | +def {{name}}{{../testRunId}}(event: alerts_fn.AlertEvent) -> None: |
| 95 | + """ |
| 96 | + Test function: {{name}} |
| 97 | + Trigger: {{trigger}} |
| 98 | + """ |
| 99 | + pass |
| 100 | + |
| 101 | +{{/if}} |
| 102 | +{{#if (eq trigger "onNewFatalIssuePublished")}} |
| 103 | +@alerts_fn.on_new_fatal_issue_published( |
| 104 | + region=REGION, |
| 105 | + timeout_sec={{timeout}} |
| 106 | +) |
| 107 | +def {{name}}{{../testRunId}}(event: alerts_fn.AlertEvent) -> None: |
| 108 | + """ |
| 109 | + Test function: {{name}} |
| 110 | + Trigger: {{trigger}} |
| 111 | + """ |
| 112 | + pass |
| 113 | + |
| 114 | +{{/if}} |
| 115 | +{{#if (eq trigger "onNewNonfatalIssuePublished")}} |
| 116 | +@alerts_fn.on_new_nonfatal_issue_published( |
| 117 | + region=REGION, |
| 118 | + timeout_sec={{timeout}} |
| 119 | +) |
| 120 | +def {{name}}{{../testRunId}}(event: alerts_fn.AlertEvent) -> None: |
| 121 | + """ |
| 122 | + Test function: {{name}} |
| 123 | + Trigger: {{trigger}} |
| 124 | + """ |
| 125 | + pass |
| 126 | + |
| 127 | +{{/if}} |
| 128 | +{{#if (eq trigger "onRegressionAlertPublished")}} |
| 129 | +@alerts_fn.on_regression_alert_published( |
| 130 | + region=REGION, |
| 131 | + timeout_sec={{timeout}} |
| 132 | +) |
| 133 | +def {{name}}{{../testRunId}}(event: alerts_fn.AlertEvent) -> None: |
| 134 | + """ |
| 135 | + Test function: {{name}} |
| 136 | + Trigger: {{trigger}} |
| 137 | + """ |
| 138 | + pass |
| 139 | + |
| 140 | +{{/if}} |
| 141 | +{{#if (eq trigger "onStabilityDigestPublished")}} |
| 142 | +@alerts_fn.on_stability_digest_published( |
| 143 | + region=REGION, |
| 144 | + timeout_sec={{timeout}} |
| 145 | +) |
| 146 | +def {{name}}{{../testRunId}}(event: alerts_fn.AlertEvent) -> None: |
| 147 | + """ |
| 148 | + Test function: {{name}} |
| 149 | + Trigger: {{trigger}} |
| 150 | + """ |
| 151 | + pass |
| 152 | + |
| 153 | +{{/if}} |
| 154 | +{{#if (eq trigger "onVelocityAlertPublished")}} |
| 155 | +@alerts_fn.on_velocity_alert_published( |
| 156 | + region=REGION, |
| 157 | + timeout_sec={{timeout}} |
| 158 | +) |
| 159 | +def {{name}}{{../testRunId}}(event: alerts_fn.AlertEvent) -> None: |
| 160 | + """ |
| 161 | + Test function: {{name}} |
| 162 | + Trigger: {{trigger}} |
| 163 | + """ |
| 164 | + pass |
| 165 | + |
| 166 | +{{/if}} |
| 167 | +{{#if (eq trigger "onThresholdAlertPublished")}} |
| 168 | +@alerts_fn.on_threshold_alert_published( |
| 169 | + region=REGION, |
| 170 | + timeout_sec={{timeout}} |
| 171 | +) |
| 172 | +def {{name}}{{../testRunId}}(event: alerts_fn.AlertEvent) -> None: |
| 173 | + """ |
| 174 | + Test function: {{name}} |
| 175 | + Trigger: {{trigger}} |
| 176 | + """ |
| 177 | + pass |
| 178 | + |
| 179 | +{{/if}} |
| 180 | +{{/each}} |
0 commit comments