How to use renew method in lisa

Best Python code snippet using lisa_python

set_load_balancer_renewal_request.py

Source:set_load_balancer_renewal_request.py Github

copy

Full Screen

1# coding: utf-82"""3 clb4 No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E5015 OpenAPI spec version: common-version6 7 Generated by: https://github.com/swagger-api/swagger-codegen.git8"""9import pprint10import re # noqa: F40111import six12from volcenginesdkcore.configuration import Configuration13class SetLoadBalancerRenewalRequest(object):14 """NOTE: This class is auto generated by the swagger code generator program.15 Do not edit the class manually.16 """17 """18 Attributes:19 swagger_types (dict): The key is attribute name20 and the value is attribute type.21 attribute_map (dict): The key is attribute name22 and the value is json key in definition.23 """24 swagger_types = {25 'load_balancer_id': 'str',26 'remain_renew_times': 'int',27 'renew_period_times': 'int',28 'renew_type': 'int'29 }30 attribute_map = {31 'load_balancer_id': 'LoadBalancerId',32 'remain_renew_times': 'RemainRenewTimes',33 'renew_period_times': 'RenewPeriodTimes',34 'renew_type': 'RenewType'35 }36 def __init__(self, load_balancer_id=None, remain_renew_times=None, renew_period_times=None, renew_type=None, _configuration=None): # noqa: E50137 """SetLoadBalancerRenewalRequest - a model defined in Swagger""" # noqa: E50138 if _configuration is None:39 _configuration = Configuration()40 self._configuration = _configuration41 self._load_balancer_id = None42 self._remain_renew_times = None43 self._renew_period_times = None44 self._renew_type = None45 self.discriminator = None46 if load_balancer_id is not None:47 self.load_balancer_id = load_balancer_id48 if remain_renew_times is not None:49 self.remain_renew_times = remain_renew_times50 if renew_period_times is not None:51 self.renew_period_times = renew_period_times52 self.renew_type = renew_type53 @property54 def load_balancer_id(self):55 """Gets the load_balancer_id of this SetLoadBalancerRenewalRequest. # noqa: E50156 :return: The load_balancer_id of this SetLoadBalancerRenewalRequest. # noqa: E50157 :rtype: str58 """59 return self._load_balancer_id60 @load_balancer_id.setter61 def load_balancer_id(self, load_balancer_id):62 """Sets the load_balancer_id of this SetLoadBalancerRenewalRequest.63 :param load_balancer_id: The load_balancer_id of this SetLoadBalancerRenewalRequest. # noqa: E50164 :type: str65 """66 self._load_balancer_id = load_balancer_id67 @property68 def remain_renew_times(self):69 """Gets the remain_renew_times of this SetLoadBalancerRenewalRequest. # noqa: E50170 :return: The remain_renew_times of this SetLoadBalancerRenewalRequest. # noqa: E50171 :rtype: int72 """73 return self._remain_renew_times74 @remain_renew_times.setter75 def remain_renew_times(self, remain_renew_times):76 """Sets the remain_renew_times of this SetLoadBalancerRenewalRequest.77 :param remain_renew_times: The remain_renew_times of this SetLoadBalancerRenewalRequest. # noqa: E50178 :type: int79 """80 self._remain_renew_times = remain_renew_times81 @property82 def renew_period_times(self):83 """Gets the renew_period_times of this SetLoadBalancerRenewalRequest. # noqa: E50184 :return: The renew_period_times of this SetLoadBalancerRenewalRequest. # noqa: E50185 :rtype: int86 """87 return self._renew_period_times88 @renew_period_times.setter89 def renew_period_times(self, renew_period_times):90 """Sets the renew_period_times of this SetLoadBalancerRenewalRequest.91 :param renew_period_times: The renew_period_times of this SetLoadBalancerRenewalRequest. # noqa: E50192 :type: int93 """94 self._renew_period_times = renew_period_times95 @property96 def renew_type(self):97 """Gets the renew_type of this SetLoadBalancerRenewalRequest. # noqa: E50198 :return: The renew_type of this SetLoadBalancerRenewalRequest. # noqa: E50199 :rtype: int100 """101 return self._renew_type102 @renew_type.setter103 def renew_type(self, renew_type):104 """Sets the renew_type of this SetLoadBalancerRenewalRequest.105 :param renew_type: The renew_type of this SetLoadBalancerRenewalRequest. # noqa: E501106 :type: int107 """108 if self._configuration.client_side_validation and renew_type is None:109 raise ValueError("Invalid value for `renew_type`, must not be `None`") # noqa: E501110 if (self._configuration.client_side_validation and111 renew_type is not None and renew_type > 2): # noqa: E501112 raise ValueError("Invalid value for `renew_type`, must be a value less than or equal to `2`") # noqa: E501113 if (self._configuration.client_side_validation and114 renew_type is not None and renew_type < 1): # noqa: E501115 raise ValueError("Invalid value for `renew_type`, must be a value greater than or equal to `1`") # noqa: E501116 self._renew_type = renew_type117 def to_dict(self):118 """Returns the model properties as a dict"""119 result = {}120 for attr, _ in six.iteritems(self.swagger_types):121 value = getattr(self, attr)122 if isinstance(value, list):123 result[attr] = list(map(124 lambda x: x.to_dict() if hasattr(x, "to_dict") else x,125 value126 ))127 elif hasattr(value, "to_dict"):128 result[attr] = value.to_dict()129 elif isinstance(value, dict):130 result[attr] = dict(map(131 lambda item: (item[0], item[1].to_dict())132 if hasattr(item[1], "to_dict") else item,133 value.items()134 ))135 else:136 result[attr] = value137 if issubclass(SetLoadBalancerRenewalRequest, dict):138 for key, value in self.items():139 result[key] = value140 return result141 def to_str(self):142 """Returns the string representation of the model"""143 return pprint.pformat(self.to_dict())144 def __repr__(self):145 """For `print` and `pprint`"""146 return self.to_str()147 def __eq__(self, other):148 """Returns true if both objects are equal"""149 if not isinstance(other, SetLoadBalancerRenewalRequest):150 return False151 return self.to_dict() == other.to_dict()152 def __ne__(self, other):153 """Returns true if both objects are not equal"""154 if not isinstance(other, SetLoadBalancerRenewalRequest):155 return True...

Full Screen

Full Screen

test_forms.py

Source:test_forms.py Github

copy

Full Screen

1import datetime2from django.test import TestCase3from django.utils import timezone4from catalog.forms import RenewBookForm, RenewBookModelForm5class RenewBookFormTest(TestCase):6 def test_renew_form_date_field_label(self):7 form = RenewBookForm()8 field_label = form.fields['renewal_date'].label9 self.assertTrue(field_label == None or field_label == 'renewal date')10 def test_renew_form_date_field_help_text(self):11 form = RenewBookForm()12 help_text = form.fields['renewal_date'].help_text13 self.assertTrue(help_text, 'Enter a date between now and 4 weeks (default 3).')14 def test_renew_form_date_in_past(self):15 date = datetime.date.today() - datetime.timedelta(days=1)16 form = RenewBookForm(data={'renewal_date': date})17 self.assertFalse(form.is_valid())18 self.assertEqual(form.errors['renewal_date'], [u"Invalid date - renewal in past"])19 def test_renew_form_date_too_far_in_future(self):20 date = datetime.date.today() + datetime.timedelta(weeks=4) + datetime.timedelta(days=1)21 form = RenewBookForm(data={'renewal_date': date})22 self.assertFalse(form.is_valid())23 self.assertEqual(form.errors['renewal_date'], [u"Invalid date - renewal more than 4 weeks ahead"])24 def test_renew_form_date_today(self):25 date = datetime.date.today()26 form = RenewBookForm(data={'renewal_date': date})27 self.assertTrue(form.is_valid())28 def test_renew_form_date_is_within_the_allowed_range(self):29 date = timezone.now() + datetime.timedelta(weeks=4)30 form = RenewBookForm(data={'renewal_date': date})31 self.assertTrue(form.is_valid())32class RenewBookModelFormTest(TestCase):33 def test_renew_form_date_field_label(self):34 form = RenewBookModelForm()35 field_label = form.fields['renewal_date'].label36 self.assertTrue(field_label == None or field_label == 'renewal date')37 def test_renew_form_date_field_help_text(self):38 form = RenewBookModelForm()39 help_text = form.fields['renewal_date'].help_text40 self.assertTrue(help_text, 'Enter a date between now and 4 weeks (default 3).')41 def test_renew_form_date_in_past(self):42 date = datetime.date.today() - datetime.timedelta(days=1)43 form = RenewBookModelForm(data={'renewal_date': date})44 self.assertFalse(form.is_valid())45 self.assertEqual(form.errors['renewal_date'], [u"Invalid date - renewal in past"])46 def test_renew_form_date_too_far_in_future(self):47 date = datetime.date.today() + datetime.timedelta(weeks=4) + datetime.timedelta(days=1)48 form = RenewBookModelForm(data={'renewal_date': date})49 self.assertFalse(form.is_valid())50 self.assertEqual(form.errors['renewal_date'], [u"Invalid date - renewal more than 4 weeks ahead"])51 def test_renew_form_date_today(self):52 date = datetime.date.today()53 form = RenewBookModelForm(data={'renewal_date': date})54 self.assertTrue(form.is_valid())55 def test_renew_form_date_is_within_the_allowed_range(self):56 date = timezone.now() + datetime.timedelta(weeks=4)57 form = RenewBookModelForm(data={'renewal_date': date})...

Full Screen

Full Screen

manage-multi-certificates.py

Source:manage-multi-certificates.py Github

copy

Full Screen

1#!/usr/bin/env python32import os3import configparser as cp4import subprocess as sp5ini_file = os.environ['MULTI_CERTIFICATES_INI_FILE']6# check if the file exists because the config parser ignores any errors7# when opening and reading a file respectively8if not os.path.exists(ini_file):9 raise FileNotFoundError(f'{ini_file} not exists')10config_parser = cp.ConfigParser()11# prevent config parser from making strings to lowercase12config_parser.optionxform = str13config_parser.read(ini_file)14for section in config_parser.sections():15 # map ItemsView to dictionary16 opts = os.environ.copy()17 for key, val in config_parser.items(section):18 opts[key] = val19 sp.run(['./scripts/certbot-certonly.sh'], stderr=sp.STDOUT, env=opts)20 # run configure-crontab.sh if the RUN_ONCE environment variable is undefined21 if opts.get('RUN_ONCE', '') == '':22 # prepare existing renew options23 renew_opts = opts.copy()24 # if the CERT_NAME environment variable is undefined,25 # we have to set the first value in the DOMAINS environment variable as its value26 # to keep the renew individual27 if renew_opts.get('CERT_NAME', '') == '':28 renew_opts['CERT_NAME'] = renew_opts['DOMAINS'].split(',')[0]29 # collect existing renew options in a list30 # where each element is passed as argument to the renew script31 renew_opts_args = [f'--cert-name "{renew_opts["CERT_NAME"]}"']32 if renew_opts.get('QUIET', '') != '':33 renew_opts_args += ['-q']34 if renew_opts.get('PRE_HOOK_CMD', '') != '':35 renew_opts_args += [f'--pre-hook "{renew_opts["PRE_HOOK_CMD"]}"']36 if renew_opts.get('POST_HOOK_CMD', '') != '':37 renew_opts_args += [f'--post-hook "{renew_opts["POST_HOOK_CMD"]}"']38 if renew_opts.get('DEPLOY_HOOK_CMD', '') != '':39 renew_opts_args += [40 f'--deploy-hook "{renew_opts["DEPLOY_HOOK_CMD"]}"']41 if renew_opts.get('CERTBOT_RENEW_FLAGS', '') != '':42 renew_opts_args += [43 f'--certbot-renew-flags {renew_opts["CERTBOT_RENEW_FLAGS"]}']44 renew_args = ['./scripts/configure-crontab.sh']45 renew_args.extend(renew_opts_args)46 sp.run(renew_args, stderr=sp.STDOUT, env=renew_opts)47if config_parser.defaults().get('RUN_ONCE', '') == '':...

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