How to use override_description method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

net_flow_interface_filter_dto.py

Source:net_flow_interface_filter_dto.py Github

copy

Full Screen

...215 :type: list[str]216 """217 self._origin_ips = origin_ips218 @property219 def override_description(self):220 """Gets the override_description of this NetFlowInterfaceFilterDto. # noqa: E501221 :return: The override_description of this NetFlowInterfaceFilterDto. # noqa: E501222 :rtype: int223 """224 return self._override_description225 @override_description.setter226 def override_description(self, override_description):227 """Sets the override_description of this NetFlowInterfaceFilterDto.228 :param override_description: The override_description of this NetFlowInterfaceFilterDto. # noqa: E501229 :type: int230 """231 self._override_description = override_description232 @property233 def override_name(self):234 """Gets the override_name of this NetFlowInterfaceFilterDto. # noqa: E501235 :return: The override_name of this NetFlowInterfaceFilterDto. # noqa: E501236 :rtype: int237 """238 return self._override_name239 @override_name.setter240 def override_name(self, override_name):...

Full Screen

Full Screen

net_flow_interface_dto.py

Source:net_flow_interface_dto.py Github

copy

Full Screen

...229 :type: str230 """231 self._origin_ip = origin_ip232 @property233 def override_description(self):234 """Gets the override_description of this NetFlowInterfaceDto. # noqa: E501235 :return: The override_description of this NetFlowInterfaceDto. # noqa: E501236 :rtype: int237 """238 return self._override_description239 @override_description.setter240 def override_description(self, override_description):241 """Sets the override_description of this NetFlowInterfaceDto.242 :param override_description: The override_description of this NetFlowInterfaceDto. # noqa: E501243 :type: int244 """245 self._override_description = override_description246 @property247 def override_name(self):248 """Gets the override_name of this NetFlowInterfaceDto. # noqa: E501249 :return: The override_name of this NetFlowInterfaceDto. # noqa: E501250 :rtype: int251 """252 return self._override_name253 @override_name.setter254 def override_name(self, override_name):...

Full Screen

Full Screen

test_opsgenie_notification.py

Source:test_opsgenie_notification.py Github

copy

Full Screen

1import json2import pytest3import requests4from datetime import datetime5from mock import MagicMock6from zmon_worker_monitor.zmon_worker.encoder import JsonDataEncoder7from zmon_worker_monitor.zmon_worker.notifications.opsgenie import NotifyOpsgenie, NotificationError, \8 get_user_agent, CAPTURES_TOO_LARGE_MSG, MAX_MESSAGE_SIZE, update_with_size_constraints9URL_CREATE = 'https://api.opsgenie.com/v2/alerts'10URL_CLOSE = 'https://api.opsgenie.com/v2/alerts/{}/close'11API_KEY = '123'12MESSAGE = 'ZMON ALERT'13HEADERS = {14 'User-Agent': get_user_agent(),15 'Content-type': 'application/json',16 'Authorization': 'GenieKey {}'.format(API_KEY),17}18@pytest.mark.parametrize('is_alert,priority,override_description,set_custom_fileds',19 ((True, None, None, None),20 (True, 'P4', None, None),21 (False, None, None, None),22 (True, None, "override description", None),23 (True, None, None, {'custom_field': 'values'}))24 )25def test_opsgenie_notification(monkeypatch, is_alert, priority, override_description, set_custom_fileds):26 post = MagicMock()27 monkeypatch.setattr('requests.post', post)28 alert = {29 'alert_changed': True, 'changed': True, 'is_alert': is_alert, 'entity': {'id': 'e-1'}, 'worker': 'worker-1',30 'alert_evaluation_ts': 1234,31 'alert_def': {32 'name': 'Alert',33 'team': 'zmon',34 'responsible_team': 'zmon',35 'id': 123,36 'priority': 1,37 }38 }39 NotifyOpsgenie._config = {'notifications.opsgenie.apikey': API_KEY}40 kwargs = {}41 if priority:42 kwargs['priority'] = priority43 else:44 priority = 'P1'45 if override_description:46 r = NotifyOpsgenie.notify(47 alert,48 message=MESSAGE,49 include_alert=False,50 teams=['team-1', 'team-2'],51 description=override_description,52 custom_fields=set_custom_fileds,53 **kwargs54 )55 else:56 r = NotifyOpsgenie.notify(57 alert,58 message=MESSAGE,59 include_alert=False,60 teams=['team-1', 'team-2'],61 custom_fields=set_custom_fileds,62 **kwargs63 )64 params = {}65 if is_alert:66 details = {'alert_evaluation_ts': 1234}67 if set_custom_fileds:68 details.update(set_custom_fileds)69 data = {70 'alias': 'ZMON-123',71 'message': MESSAGE,72 'description': '',73 'entity': 'e-1',74 'priority': priority,75 'tags': [123],76 'teams': [{'name': 'team-1'}, {'name': 'team-2'}],77 'source': 'worker-1',78 'note': '',79 'details': details,80 }81 if override_description:82 data['description'] = override_description83 else:84 data = {85 'user': 'ZMON',86 'source': 'worker-1',87 'note': '',88 }89 params = {'identifierType': 'alias'}90 assert r == 091 URL = URL_CREATE if is_alert else URL_CLOSE.format('ZMON-123')92 post.assert_called_with(URL, data=json.dumps(data, cls=JsonDataEncoder, sort_keys=True), headers=HEADERS, timeout=5,93 params=params)94@pytest.mark.parametrize('include_captures, is_alert,priority,override_description',95 ((True, True, None, None),96 (True, True, 'P4', None),97 (False, False, None, None),98 (False, True, None, "override description"))99 )100def test_opsgenie_notification_captures(monkeypatch, include_captures, is_alert, priority, override_description):101 post = MagicMock()102 monkeypatch.setattr('requests.post', post)103 alert = {104 'alert_changed': True, 'changed': True, 'is_alert': is_alert, 'entity': {'id': 'e-1'}, 'worker': 'worker-1',105 'alert_evaluation_ts': 1234,106 'captures': {'foo': 'bar'},107 'alert_def': {108 'name': 'Alert',109 'team': 'zmon',110 'responsible_team': 'zmon',111 'id': 123,112 'priority': 1,113 }114 }115 NotifyOpsgenie._config = {'notifications.opsgenie.apikey': API_KEY}116 kwargs = {}117 if priority:118 kwargs['priority'] = priority119 else:120 priority = 'P1'121 if override_description:122 r = NotifyOpsgenie.notify(123 alert,124 message=MESSAGE,125 include_alert=False,126 include_captures=include_captures,127 teams=['team-1', 'team-2'],128 description=override_description,129 **kwargs130 )131 else:132 r = NotifyOpsgenie.notify(133 alert,134 message=MESSAGE,135 include_alert=False,136 include_captures=include_captures,137 teams=['team-1', 'team-2'],138 **kwargs139 )140 params = {}141 if include_captures:142 details = {'alert_evaluation_ts': 1234, 'captures.foo': 'bar'}143 else:144 details = {'alert_evaluation_ts': 1234}145 if is_alert:146 data = {147 'alias': 'ZMON-123',148 'message': MESSAGE,149 'description': '',150 'entity': 'e-1',151 'priority': priority,152 'tags': [123],153 'teams': [{'name': 'team-1'}, {'name': 'team-2'}],154 'source': 'worker-1',155 'note': '',156 'details': details,157 }158 if override_description:159 data['description'] = override_description160 else:161 data = {162 'user': 'ZMON',163 'source': 'worker-1',164 'note': '',165 }166 params = {'identifierType': 'alias'}167 assert r == 0168 URL = URL_CREATE if is_alert else URL_CLOSE.format('ZMON-123')169 post.assert_called_with(URL, data=json.dumps(data, cls=JsonDataEncoder, sort_keys=True), headers=HEADERS, timeout=5,170 params=params)171def test_opsgenie_notification_large_captures(monkeypatch):172 post = MagicMock()173 monkeypatch.setattr('requests.post', post)174 alert = {175 'alert_changed': True, 'changed': True, 'is_alert': True, 'entity': {'id': 'e-1'}, 'worker': 'worker-1',176 'alert_evaluation_ts': 1234,177 'captures': {'foo': 'x' * 10000},178 'alert_def': {179 'name': 'Alert',180 'team': 'zmon',181 'responsible_team': 'zmon',182 'id': 123,183 'priority': 1,184 }185 }186 NotifyOpsgenie._config = {'notifications.opsgenie.apikey': API_KEY}187 kwargs = {}188 kwargs['priority'] = 'P1'189 r = NotifyOpsgenie.notify(190 alert,191 message=MESSAGE,192 include_alert=False,193 include_captures=True,194 teams=['team-1', 'team-2'],195 **kwargs196 )197 params = {}198 details = {'alert_evaluation_ts': 1234, 'captures': CAPTURES_TOO_LARGE_MSG}199 data = {200 'alias': 'ZMON-123',201 'message': MESSAGE,202 'description': '',203 'entity': 'e-1',204 'priority': 'P1',205 'tags': [123],206 'teams': [{'name': 'team-1'}, {'name': 'team-2'}],207 'source': 'worker-1',208 'note': '',209 'details': details,210 }211 assert r == 0212 URL = URL_CREATE213 post.assert_called_with(URL, data=json.dumps(data, cls=JsonDataEncoder, sort_keys=True), headers=HEADERS, timeout=5,214 params=params)215def test_opsgenie_notification_large_message(monkeypatch):216 post = MagicMock()217 monkeypatch.setattr('requests.post', post)218 alert = {219 'alert_changed': True, 'changed': True, 'is_alert': True, 'entity': {'id': 'e-1'}, 'worker': 'worker-1',220 'alert_evaluation_ts': 1234,221 'captures': {'foo': 'x'},222 'alert_def': {223 'name': 'Alert',224 'team': 'zmon',225 'responsible_team': 'zmon',226 'id': 123,227 'priority': 1,228 }229 }230 NotifyOpsgenie._config = {'notifications.opsgenie.apikey': API_KEY}231 kwargs = {}232 kwargs['priority'] = 'P1'233 r = NotifyOpsgenie.notify(234 alert,235 message=MESSAGE + " " + "x" * 130,236 include_alert=False,237 include_captures=True,238 teams=['team-1', 'team-2'],239 **kwargs240 )241 params = {}242 details = {'alert_evaluation_ts': 1234, 'captures.foo': 'x'}243 data = {244 'alias': 'ZMON-123',245 'message': MESSAGE + " " + "x" * (MAX_MESSAGE_SIZE - len(MESSAGE) - 4) + "...",246 'description': '',247 'entity': 'e-1',248 'priority': 'P1',249 'tags': [123],250 'teams': [{'name': 'team-1'}, {'name': 'team-2'}],251 'source': 'worker-1',252 'note': '',253 'details': details,254 }255 assert r == 0256 URL = URL_CREATE257 post.assert_called_with(URL, data=json.dumps(data, cls=JsonDataEncoder, sort_keys=True), headers=HEADERS, timeout=5,258 params=params)259def test_opsgenie_notification_per_entity(monkeypatch):260 post = MagicMock()261 monkeypatch.setattr('requests.post', post)262 alert = {263 'changed': True, 'is_alert': True, 'entity': {'id': 'e-1', 'application': 'app_id'}, 'worker': 'worker-1',264 'time': datetime.now(),265 'alert_evaluation_ts': 1234,266 'alert_def': {267 'name': 'Alert',268 'team': 'team-1',269 'id': 123,270 'responsible_team': 'zmon',271 'priority': 3,272 'tags': ['tag-1'],273 },274 }275 NotifyOpsgenie._config = {276 'notifications.opsgenie.apikey': API_KEY,277 'zmon.host': 'https://zmon.example.org/'278 }279 r = NotifyOpsgenie.notify(alert, message=MESSAGE, per_entity=True, teams='team-1')280 data = {281 'alias': 'ZMON-123-e-1',282 'message': MESSAGE,283 'description': '',284 'source': 'worker-1',285 'note': 'https://zmon.example.org/#/alert-details/123',286 'entity': 'e-1',287 'details': {288 'worker': alert['worker'],289 'zmon_team': alert['alert_def']['team'],290 'entity': alert['entity']['id'],291 'infrastructure_account': 'UNKNOWN',292 'alert_evaluation_ts': 1234,293 'alert_url': 'https://zmon.example.org/#/alert-details/123',294 'owning_team': alert['alert_def']['responsible_team'],295 'application': alert['entity']['application']296 },297 'priority': 'P3',298 'tags': ['tag-1', 123],299 'teams': [{'name': 'team-1'}],300 }301 assert r == 0302 post.assert_called_with(URL_CREATE, data=json.dumps(data, cls=JsonDataEncoder, sort_keys=True), headers=HEADERS,303 timeout=5, params={})304def test_opsgenie_notification_no_change(monkeypatch):305 alert = {306 'is_alert': True, 'alert_changed': False, 'entity': {'id': 'e-1'}, 'worker': 'worker-1',307 'alert_def': {'name': 'Alert', 'team': 'zmon', 'responsible_team': 'zmon', 'id': 123, 'priority': 1},308 }309 NotifyOpsgenie._config = {310 'notifications.opsgenie.apikey': API_KEY,311 'zmon.host': 'https://zmon.example.org/'312 }313 r = NotifyOpsgenie.notify(alert, message=MESSAGE, per_entity=False, teams='team-1', repeat=55)314 assert r == 55315def test_opsgenie_notification_error_api_key(monkeypatch):316 NotifyOpsgenie._config = {}317 alert = {318 'alert_changed': True, 'changed': True, 'is_alert': True, 'entity': {'id': 'e-1'}, 'worker': 'worker-1',319 'alert_evaluation_ts': 1234,320 'alert_def': {321 'name': 'Alert',322 'team': 'zmon',323 'responsible_team': 'zmon',324 'id': 123,325 'priority': 1,326 }327 }328 with pytest.raises(NotificationError):329 NotifyOpsgenie.notify(alert, message=MESSAGE)330def test_opsgenie_notification_error_teams(monkeypatch):331 NotifyOpsgenie._config = {'notifications.opsgenie.apikey': API_KEY}332 alert = {333 'alert_changed': True, 'changed': True, 'is_alert': True, 'entity': {'id': 'e-1'}, 'worker': 'worker-1',334 'alert_evaluation_ts': 1234,335 'alert_def': {336 'name': 'Alert',337 'team': 'zmon',338 'responsible_team': 'zmon',339 'id': 123,340 'priority': 1,341 }342 }343 with pytest.raises(NotificationError):344 NotifyOpsgenie.notify(alert, message=MESSAGE)345 with pytest.raises(NotificationError):346 NotifyOpsgenie.notify(alert, teams='team-1', message=MESSAGE, priority='p1')347def test_opsgenie_notification_exception(monkeypatch):348 post = MagicMock()349 post.side_effect = Exception350 monkeypatch.setattr('requests.post', post)351 alert = {352 'alert_changed': True, 'changed': True, 'is_alert': True, 'entity': {'id': 'e-1'}, 'worker': 'worker-1',353 'alert_def': {'name': 'Alert', 'team': 'zmon', 'responsible_team': 'zmon', 'id': 123, 'priority': 1},354 }355 NotifyOpsgenie._config = {'notifications.opsgenie.apikey': API_KEY}356 r = NotifyOpsgenie.notify(alert, message=MESSAGE, per_entity=True, teams='team-1')357 assert r == 0358 resp = requests.Response()359 resp.status_code = 400360 post.side_effect = requests.HTTPError(response=resp)361 monkeypatch.setattr('requests.post', post)362 r = NotifyOpsgenie.notify(alert, message=MESSAGE, per_entity=True, teams='team-1')363 assert r == 0364def test_opsgenie_update_with_size_constraints():365 details = {'foo': 'bar'}366 data = {'bar': 'baz'}367 defaults = {'bar': 'bar'}368 update_with_size_constraints(details, data, 100, defaults)369 assert details == {'foo': 'bar', 'bar': 'baz'}370 update_with_size_constraints(details, data, 1, defaults)...

Full Screen

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 Lemoncheesecake 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