How to use usable_by method in autotest

Best Python code snippet using autotest_python

coupon.py

Source:coupon.py Github

copy

Full Screen

...1027 :type: CouponTieredPercentOffSubtotal1028 """1029 self._tiered_percent_off_subtotal = tiered_percent_off_subtotal1030 @property1031 def usable_by(self):1032 """1033 Gets the usable_by of this Coupon.1034 Who may use this coupon.1035 :return: The usable_by of this Coupon.1036 :rtype: str1037 """1038 return self._usable_by1039 @usable_by.setter1040 def usable_by(self, usable_by):1041 """1042 Sets the usable_by of this Coupon.1043 Who may use this coupon.1044 :param usable_by: The usable_by of this Coupon.1045 :type: str1046 """1047 if usable_by is not None and len(usable_by) > 50:1048 raise ValueError("Invalid value for `usable_by`, length must be less than or equal to `50`")1049 self._usable_by = usable_by1050 def to_dict(self):1051 """1052 Returns the model properties as a dict1053 """1054 result = {}...

Full Screen

Full Screen

coupon_editor_values.py

Source:coupon_editor_values.py Github

copy

Full Screen

...205 :type: list[SimpleValue]206 """207 self._storefronts = storefronts208 @property209 def usable_by(self):210 """Gets the usable_by of this CouponEditorValues. # noqa: E501211 usable_by # noqa: E501212 :return: The usable_by of this CouponEditorValues. # noqa: E501213 :rtype: list[SimpleValue]214 """215 return self._usable_by216 @usable_by.setter217 def usable_by(self, usable_by):218 """Sets the usable_by of this CouponEditorValues.219 usable_by # noqa: E501220 :param usable_by: The usable_by of this CouponEditorValues. # noqa: E501221 :type: list[SimpleValue]222 """223 self._usable_by = usable_by224 @property225 def valid_with_other_coupons(self):226 """Gets the valid_with_other_coupons of this CouponEditorValues. # noqa: E501227 valid_with_other_coupons # noqa: E501228 :return: The valid_with_other_coupons of this CouponEditorValues. # noqa: E501229 :rtype: list[str]230 """231 return self._valid_with_other_coupons...

Full Screen

Full Screen

config_test.py

Source:config_test.py Github

copy

Full Screen

1#!/usr/bin/env python2# Copyright 2016 The LUCI Authors. All rights reserved.3# Use of this source code is governed under the Apache License, Version 2.04# that can be found in the LICENSE file.5import logging6import sys7import unittest8import test_env9test_env.setup_test_env()10from components.config import validation11from components import utils12from test_support import test_case13from proto import config_pb214from server import config15# pylint: disable=W0212,W061216class ConfigTest(test_case.TestCase):17 def setUp(self):18 super(ConfigTest, self).setUp()19 utils.clear_cache(config.settings)20 def validator_test(self, validator, cfg, messages):21 ctx = validation.Context()22 validator(cfg, ctx)23 self.assertEquals(ctx.result().messages, [24 validation.Message(severity=logging.ERROR, text=m)25 for m in messages26 ])27 def test_validate_isolate_settings(self):28 self.validator_test(29 config._validate_isolate_settings,30 config_pb2.IsolateSettings(31 default_server='https://isolateserver.appspot.com'),32 [33 'either specify both default_server and default_namespace or '34 'none',35 ])36 self.validator_test(37 config._validate_isolate_settings,38 config_pb2.IsolateSettings(39 default_server='isolateserver.appspot.com',40 default_namespace='abc',41 ),42 [43 'default_server must start with "https://" or "http://localhost"',44 ])45 self.validator_test(46 config._validate_isolate_settings,47 config_pb2.IsolateSettings(48 default_server='https://isolateserver.appspot.com',49 default_namespace='abc',50 ),51 [])52 self.validator_test(53 config._validate_isolate_settings,54 config_pb2.IsolateSettings(),55 [])56 def test_validate_cipd_settings(self):57 self.validator_test(58 config._validate_cipd_settings,59 config_pb2.CipdSettings(),60 [61 'default_server is not set',62 'default_client_package: invalid package_name ""',63 'default_client_package: invalid version ""',64 ])65 self.validator_test(66 config._validate_cipd_settings,67 config_pb2.CipdSettings(68 default_server='chrome-infra-packages.appspot.com',69 default_client_package=config_pb2.CipdPackage(70 package_name='infra/tools/cipd/windows-i386',71 version='git_revision:deadbeef'),72 ),73 [74 'default_server must start with "https://" or "http://localhost"',75 ])76 self.validator_test(77 config._validate_cipd_settings,78 config_pb2.CipdSettings(79 default_server='https://chrome-infra-packages.appspot.com',80 default_client_package=config_pb2.CipdPackage(81 package_name='infra/tools/cipd/${platform}',82 version='git_revision:deadbeef'),83 ),84 [])85 def test_validate_dimension_acls(self):86 entry = config_pb2.DimensionACLs.Entry87 self.validator_test(88 config._validate_dimension_acls,89 config_pb2.DimensionACLs(entry=[]),90 [])91 self.validator_test(92 config._validate_dimension_acls,93 config_pb2.DimensionACLs(entry=[94 entry(dimension=['pool:default'], usable_by='all'),95 entry(dimension=['stuff:*'], usable_by='all'),96 ]),97 [])98 self.validator_test(99 config._validate_dimension_acls,100 config_pb2.DimensionACLs(entry=[entry()]),101 [102 'entry #1: at least one dimension is required',103 'entry #1: "usable_by" is required',104 ])105 self.validator_test(106 config._validate_dimension_acls,107 config_pb2.DimensionACLs(entry=[108 entry(dimension=['not_kv_pair'], usable_by='all'),109 ]),110 [u'entry #1: dimension "not_kv_pair": not a valid dimension'])111 self.validator_test(112 config._validate_dimension_acls,113 config_pb2.DimensionACLs(entry=[114 entry(dimension=['@@@@:abc'], usable_by='all'),115 ]),116 [u'entry #1: dimension "@@@@:abc": not a valid dimension'])117 self.validator_test(118 config._validate_dimension_acls,119 config_pb2.DimensionACLs(entry=[120 entry(dimension=['pool:*'], usable_by='all'),121 entry(dimension=['pool:*'], usable_by='all'),122 entry(dimension=['pool:*'], usable_by='all'),123 ]),124 ['entry #1: dimension "pool:*": was specified multiple times'])125 self.validator_test(126 config._validate_dimension_acls,127 config_pb2.DimensionACLs(entry=[128 entry(dimension=['pool:abc'], usable_by='all'),129 entry(dimension=['pool:abc'], usable_by='all'),130 ]),131 ['entry #2: dimension "pool:abc": was already specified'])132 self.validator_test(133 config._validate_dimension_acls,134 config_pb2.DimensionACLs(entry=[135 entry(dimension=['pool:*'], usable_by='all'),136 entry(dimension=['pool:abc'], usable_by='all'),137 ]),138 ['entry #2: dimension "pool:abc": was already specified via "pool:*"'])139 self.validator_test(140 config._validate_dimension_acls,141 config_pb2.DimensionACLs(entry=[142 entry(dimension=['pool:abc'], usable_by='@@@badgroup@@@'),143 ]),144 ['entry #1: "usable_by" specifies invalid group name "@@@badgroup@@@"'])145 def test_validate_settings(self):146 self.validator_test(147 config._validate_settings,148 config_pb2.SettingsCfg(149 bot_death_timeout_secs=-1,150 reusable_task_age_secs=-1),151 [152 'bot_death_timeout_secs cannot be negative',153 'reusable_task_age_secs cannot be negative',154 ])155 self.validator_test(156 config._validate_settings,157 config_pb2.SettingsCfg(158 bot_death_timeout_secs=config._SECONDS_IN_YEAR + 1,159 reusable_task_age_secs=config._SECONDS_IN_YEAR + 1),160 [161 'bot_death_timeout_secs cannot be more than a year',162 'reusable_task_age_secs cannot be more than a year',163 ])164 self.validator_test(config._validate_settings, config_pb2.SettingsCfg(), [])165 self.validator_test(166 config._validate_settings,167 config_pb2.SettingsCfg(168 mp=config_pb2.MachineProviderSettings(server='http://url')),169 [170 'mp.server must start with "https://" or "http://localhost"',171 ])172 self.validator_test(173 config._validate_settings,174 config_pb2.SettingsCfg(175 mp=config_pb2.MachineProviderSettings(server='url')),176 [177 'mp.server must start with "https://" or "http://localhost"',178 ])179 def test_get_settings_with_defaults_from_none(self):180 """Make sure defaults are applied even if raw config is None."""181 self.mock(config, '_get_settings', lambda: (None, None))182 _, cfg = config._get_settings_with_defaults()183 self.assertEqual(cfg.reusable_task_age_secs, 7*24*60*60)184 self.assertEqual(cfg.bot_death_timeout_secs, 10*60)185 self.assertEqual(cfg.auth.admins_group, 'administrators')186 self.assertEqual(cfg.auth.bot_bootstrap_group, 'administrators')187 self.assertEqual(cfg.auth.privileged_users_group, 'administrators')188 self.assertEqual(cfg.auth.users_group, 'administrators')189if __name__ == '__main__':190 if '-v' in sys.argv:191 unittest.TestCase.maxDiff = None192 logging.basicConfig(193 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL)...

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