How to use update_option method in avocado

Best Python code snippet using avocado_python

project_details.py

Source:project_details.py Github

copy

Full Screen

...277 project_id=project.id,278 user=request.user,279 ).delete()280 if result.get('digestsMinDelay'):281 project.update_option(282 'digests:mail:minimum_delay', result['digestsMinDelay'])283 if result.get('digestsMaxDelay'):284 project.update_option(285 'digests:mail:maximum_delay', result['digestsMaxDelay'])286 if result.get('subjectPrefix') is not None:287 if project.update_option('mail:subject_prefix',288 result['subjectPrefix']):289 changed_proj_settings['mail:subject_prefix'] = result['subjectPrefix']290 if result.get('subjectTemplate'):291 project.update_option('mail:subject_template',292 result['subjectTemplate'])293 if result.get('scrubIPAddresses') is not None:294 if project.update_option('sentry:scrub_ip_address', result['scrubIPAddresses']):295 changed_proj_settings['sentry:scrub_ip_address'] = result['scrubIPAddresses']296 if result.get('securityToken') is not None:297 if project.update_option('sentry:token', result['securityToken']):298 changed_proj_settings['sentry:token'] = result['securityToken']299 if result.get('securityTokenHeader') is not None:300 if project.update_option('sentry:token_header', result['securityTokenHeader']):301 changed_proj_settings['sentry:token_header'] = result['securityTokenHeader']302 if result.get('verifySSL') is not None:303 if project.update_option('sentry:verify_ssl', result['verifySSL']):304 changed_proj_settings['sentry:verify_ssl'] = result['verifySSL']305 if result.get('dataScrubber') is not None:306 if project.update_option('sentry:scrub_data', result['dataScrubber']):307 changed_proj_settings['sentry:scrub_data'] = result['dataScrubber']308 if result.get('dataScrubberDefaults') is not None:309 if project.update_option('sentry:scrub_defaults', result['dataScrubberDefaults']):310 changed_proj_settings['sentry:scrub_defaults'] = result['dataScrubberDefaults']311 if result.get('sensitiveFields') is not None:312 if project.update_option('sentry:sensitive_fields', result['sensitiveFields']):313 changed_proj_settings['sentry:sensitive_fields'] = result['sensitiveFields']314 if result.get('safeFields') is not None:315 if project.update_option('sentry:safe_fields', result['safeFields']):316 changed_proj_settings['sentry:safe_fields'] = result['safeFields']317 if result.get('storeCrashReports') is not None:318 if project.update_option('sentry:store_crash_reports', result['storeCrashReports']):319 changed_proj_settings['sentry:store_crash_reports'] = result['storeCrashReports']320 if result.get('relayPiiConfig') is not None:321 if project.update_option('sentry:relay_pii_config', result['relayPiiConfig']):322 changed_proj_settings['sentry:relay_pii_config'] = result['relayPiiConfig'].strip(323 ) or None324 if 'defaultEnvironment' in result:325 if result['defaultEnvironment'] is None:326 project.delete_option('sentry:default_environment')327 else:328 project.update_option('sentry:default_environment', result['defaultEnvironment'])329 # resolveAge can be None330 if 'resolveAge' in result:331 if project.update_option(332 'sentry:resolve_age',333 0 if result.get('resolveAge') is None else int(334 result['resolveAge'])):335 changed_proj_settings['sentry:resolve_age'] = result['resolveAge']336 if result.get('scrapeJavaScript') is not None:337 if project.update_option('sentry:scrape_javascript', result['scrapeJavaScript']):338 changed_proj_settings['sentry:scrape_javascript'] = result['scrapeJavaScript']339 if result.get('allowedDomains'):340 if project.update_option('sentry:origins', result['allowedDomains']):341 changed_proj_settings['sentry:origins'] = result['allowedDomains']342 if result.get('isSubscribed'):343 UserOption.objects.set_value(344 user=request.user, key='mail:alert', value=1, project=project345 )346 elif result.get('isSubscribed') is False:347 UserOption.objects.set_value(348 user=request.user, key='mail:alert', value=0, project=project349 )350 # TODO(dcramer): rewrite options to use standard API config351 if has_project_write:352 options = request.DATA.get('options', {})353 if 'sentry:origins' in options:354 project.update_option(355 'sentry:origins', clean_newline_inputs(356 options['sentry:origins'])357 )358 if 'sentry:resolve_age' in options:359 project.update_option('sentry:resolve_age', int(360 options['sentry:resolve_age']))361 if 'sentry:scrub_data' in options:362 project.update_option('sentry:scrub_data', bool(363 options['sentry:scrub_data']))364 if 'sentry:scrub_defaults' in options:365 project.update_option(366 'sentry:scrub_defaults', bool(367 options['sentry:scrub_defaults'])368 )369 if 'sentry:safe_fields' in options:370 project.update_option(371 'sentry:safe_fields',372 [s.strip().lower() for s in options['sentry:safe_fields']]373 )374 if 'sentry:store_crash_reports' in options:375 project.update_option('sentry:store_crash_reports', bool(376 options['sentry:store_crash_reports']))377 if 'sentry:relay_pii_config' in options:378 project.update_option('sentry:relay_pii_config',379 options['sentry:relay_pii_config'].strip() or None)380 if 'sentry:sensitive_fields' in options:381 project.update_option(382 'sentry:sensitive_fields',383 [s.strip().lower()384 for s in options['sentry:sensitive_fields']]385 )386 if 'sentry:scrub_ip_address' in options:387 project.update_option(388 'sentry:scrub_ip_address',389 bool(options['sentry:scrub_ip_address']),390 )391 if 'mail:subject_prefix' in options:392 project.update_option(393 'mail:subject_prefix',394 options['mail:subject_prefix'],395 )396 if 'sentry:default_environment' in options:397 project.update_option(398 'sentry:default_environment',399 options['sentry:default_environment'],400 )401 if 'sentry:csp_ignored_sources_defaults' in options:402 project.update_option(403 'sentry:csp_ignored_sources_defaults',404 bool(options['sentry:csp_ignored_sources_defaults'])405 )406 if 'sentry:csp_ignored_sources' in options:407 project.update_option(408 'sentry:csp_ignored_sources',409 clean_newline_inputs(options['sentry:csp_ignored_sources'])410 )411 if 'sentry:blacklisted_ips' in options:412 project.update_option(413 'sentry:blacklisted_ips',414 clean_newline_inputs(options['sentry:blacklisted_ips']),415 )416 if 'feedback:branding' in options:417 project.update_option(418 'feedback:branding', '1' if options['feedback:branding'] else '0'419 )420 if 'sentry:reprocessing_active' in options:421 project.update_option(422 'sentry:reprocessing_active', bool(423 options['sentry:reprocessing_active'])424 )425 if 'filters:blacklisted_ips' in options:426 project.update_option(427 'sentry:blacklisted_ips',428 clean_newline_inputs(options['filters:blacklisted_ips'])429 )430 if u'filters:{}'.format(FilterTypes.RELEASES) in options:431 if features.has('projects:custom-inbound-filters', project, actor=request.user):432 project.update_option(433 u'sentry:{}'.format(FilterTypes.RELEASES),434 clean_newline_inputs(435 options[u'filters:{}'.format(FilterTypes.RELEASES)])436 )437 else:438 return Response(439 {440 'detail': ['You do not have that feature enabled']441 }, status=400442 )443 if u'filters:{}'.format(FilterTypes.ERROR_MESSAGES) in options:444 if features.has('projects:custom-inbound-filters', project, actor=request.user):445 project.update_option(446 u'sentry:{}'.format(FilterTypes.ERROR_MESSAGES),447 clean_newline_inputs(448 options[u'filters:{}'.format(449 FilterTypes.ERROR_MESSAGES)],450 case_insensitive=False451 )452 )453 else:454 return Response(455 {456 'detail': ['You do not have that feature enabled']457 }, status=400458 )459 self.create_audit_entry(...

Full Screen

Full Screen

test_getters.py

Source:test_getters.py Github

copy

Full Screen

1# Copyright 2018 Samuel Payne sam_payne@byu.edu2# Licensed under the Apache License, Version 2.0 (the "License");3# you may not use this file except in compliance with the License.4# You may obtain a copy of the License at5# http://www.apache.org/licenses/LICENSE-2.06# Unless required by applicable law or agreed to in writing, software7# distributed under the License is distributed on an "AS IS" BASIS,8# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.9# See the License for the specific language governing permissions and10# limitations under the License.11import covid19pandas as cod12import covid19pandas.exceptions as codex13import pytest14import pandas as pd15import numpy as np16import datetime17formats = ["long", "wide"]18jhu_data_types = ["all", "cases", "deaths", "recovered"]19jhu_regions = ["global", "us"]20update_options = [True, False]21nyt_data_types = ["all", "cases", "deaths"]22nyt_county_options = [True, False]23class TestGetters:24 def test_get_data_jhu(self):25 for format in formats:26 for data_type in jhu_data_types:27 for region in jhu_regions:28 for update_option in update_options:29 # Check that logic errors get caught30 if region == "us" and data_type == "recovered":31 with pytest.raises(codex.ParameterError) as excinfo:32 cod.get_data_jhu(format=format, data_type=data_type, region=region, update=update_option)33 assert str(excinfo.value) == "JHU does not provide recovery data for US states/counties."34 elif format == "wide" and data_type == "all":35 with pytest.raises(codex.ParameterError) as excinfo:36 cod.get_data_jhu(format=format, data_type=data_type, region=region, update=update_option)37 assert str(excinfo.value) == "'wide' table format only allows one data type. You requested 'all'. Please pass 'cases', 'deaths', or 'recovered'."38 else:39 if not update_option:40 with pytest.warns(codex.FileNotUpdatedWarning):41 df = cod.get_data_jhu(format=format, data_type=data_type, region=region, update=update_option)42 else:43 df = cod.get_data_jhu(format=format, data_type=data_type, region=region, update=update_option)44 _check_gotten(df, format)45 def test_get_data_nyt(self):46 for format in formats:47 for data_type in nyt_data_types:48 for county_option in nyt_county_options:49 for update_option in update_options:50 # Check that logic errors get caught51 if format == "wide" and data_type == "all":52 with pytest.raises(codex.ParameterError) as excinfo:53 cod.get_data_nyt(format=format, data_type=data_type, counties=county_option, update=update_option)54 assert str(excinfo.value) == "'wide' table format only allows one data type. You requested 'all'. Please pass 'cases', 'deaths', or 'recovered'."55 else:56 if not update_option:57 with pytest.warns(codex.FileNotUpdatedWarning):58 df = cod.get_data_nyt(format=format, data_type=data_type, counties=county_option, update=update_option)59 else:60 df = cod.get_data_nyt(format=format, data_type=data_type, counties=county_option, update=update_option)61 _check_gotten(df, format)62 def test_deprecated_getters(self):63 with pytest.warns(codex.DeprecatedWarning):64 df = cod.get_cases()65 assert df.shape[0] > 0 and df.shape[1] > 066 with pytest.warns(codex.DeprecatedWarning):67 df = cod.get_deaths()68 assert df.shape[0] > 0 and df.shape[1] > 069 with pytest.warns(codex.DeprecatedWarning):70 df = cod.get_recovered()71 assert df.shape[0] > 0 and df.shape[1] > 072# Help functions73def _check_gotten(df, format, group_cols=None, allow_negs=False):74 """Standard checks to verify integrity of gotten table."""75 # Check dimensions76 assert df.shape[0] > 0 and df.shape[1] > 077 if group_cols is None:78 # Search for defined id cols (based on data source and region)79 if {"Combined_Key"}.issubset(df.columns): # JHU table80 group_cols = ["Combined_Key"]81 elif {"county", "state"}.issubset(df.columns): # NYT USA state and county table82 group_cols = ["county", "state"]83 elif {"state"}.issubset(df.columns): # NYT USA state only table. Note that this column also exists in the state/county table, so we do the check after we've determined it's not that table.84 group_cols = ["state"]85 else:86 raise Exception("The dataframe you passed does not contain any of the standard location grouping columns. Must contain one of these sets of columns: \n\n{'Combined_Key'}\n{'county', 'state'}\n{'state'}\n\n" + f"Your dataframe's columns are:\n{df.columns}")87 if format == "long":88 group_cols = ["date"] + group_cols89 if "UID" in df.columns:90 if format == "long":91 assert not df.duplicated(subset=["date", "UID"]).any()92 else:93 assert not df.duplicated(subset="UID").any()94 # Check that there aren't duplicates95 assert not df.duplicated(subset=group_cols).any()96 # Check for proper date types97 if format == "long":98 assert df["date"].dtype == np.dtype('datetime64[ns]')99 elif format == "wide":100 assert df.columns.map(lambda x: issubclass(type(x), datetime.date)).any()101 if not allow_negs:102 # Check that there aren't negative counts103 for col in df.columns[~df.columns.isin(["Lat", "Long"])]:104 if np.issubdtype(df[col].dtype, np.number):...

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