Best Python code snippet using localstack_python
__init__.py
Source:__init__.py
1from sqlalchemy import engine_from_config2from apex_route53.models import initialize_sql3from apex_route53.views import (domain_add,4 delete,5 delete_rs,6 dns_list,7 edit,8 edit_rs,9 index,10 ips,11 ips_edit,12 ips_delete,13 profiles,14 profile_edit,15 profile_delete,16 registrars,17 webhosts,18 webhosts_edit,19 webhosts_delete,20 )21def includeme(config):22 settings = config.registry.settings23 initialize_sql(engine_from_config(settings, 'sqlalchemy.'), settings)24 config.add_translation_dirs('apex:locale/')25 config.add_static_view('apex_route53/static', 'apex_route53:static')26 if not settings.get('mako.directories'):27 config.add_settings({'mako.directories': ['apex_route53:templates']})28 """29 render_template = settings['apex.apex_render_template'30 ] = settings.get('apex.apex_r53_template',31 'apex_route53:templates/apex_r53_template.mako')32 """33 config.add_route('apex_route53_index', '/')34 config.add_view(index, route_name='apex_route53_index',35 renderer='apex_route53:templates/apex_r53_index.mako',36 permission='authenticated')37 config.add_route('apex_route53_dns_list', '/dns_list')38 config.add_view(dns_list, route_name='apex_route53_dns_list',39 renderer='apex_route53:templates/apex_r53_dns_list.mako',40 permission='authenticated')41 config.add_route('apex_route53_domain_add', '/domain/add')42 config.add_view(domain_add, route_name='apex_route53_domain_add',43 renderer='apex_route53:templates/apex_r53_domain_add.mako',44 permission='authenticated')45 config.add_route('apex_route53_edit', '/edit/:id')46 config.add_view(edit, route_name='apex_route53_edit',47 renderer='apex_route53:templates/apex_r53_edit.mako',48 permission='authenticated')49 config.add_route('apex_route53_edit_rs', '/edit/:id/:recordset_id')50 config.add_view(edit_rs, route_name='apex_route53_edit_rs',51 renderer='apex_route53:templates/apex_r53_edit_rs.mako',52 permission='authenticated')53 config.add_route('apex_route53_delete', '/delete/:id')54 config.add_view(delete, route_name='apex_route53_delete',55 renderer='apex_route53:templates/apex_r53_delete.mako',56 permission='authenticated')57 config.add_route('apex_route53_delete_rs', '/delete/:id/:recordset_id')58 config.add_view(delete_rs, route_name='apex_route53_delete_rs',59 renderer='apex_route53:templates/apex_r53_delete_rs.mako',60 permission='authenticated')61 config.add_route('apex_route53_profiles', '/profiles')62 config.add_view(profiles, route_name='apex_route53_profiles',63 renderer='apex_route53:templates/apex_r53_profiles.mako',64 permission='authenticated')65 config.add_route('apex_route53_profile_edit', '/profiles/:id')66 config.add_view(profile_edit, route_name='apex_route53_profile_edit',67 renderer='apex_route53:templates/apex_r53_profile_edit.mako',68 permission='authenticated')69 config.add_route('apex_route53_profile_edit_record', 70 '/profiles/:id/:record_id')71 config.add_view(profile_edit, 72 route_name='apex_route53_profile_edit_record',73 renderer='apex_route53:templates/apex_r53_profile_edit.mako',74 permission='authenticated')75 config.add_route('apex_route53_profile_delete', 76 '/profiles/:id/delete')77 config.add_view(profile_delete, route_name='apex_route53_profile_delete',78 renderer='apex_route53:templates/apex_r53_profile_delete.mako',79 permission='authenticated')80 config.add_route('apex_route53_registrars', '/registrars')81 config.add_view(registrars, route_name='apex_route53_registrars',82 renderer='apex_route53:templates/apex_r53_registrars.mako',83 permission='authenticated')84 config.add_route('apex_route53_ips', '/ips')85 config.add_view(ips, route_name='apex_route53_ips',86 renderer='apex_route53:templates/apex_r53_ips.mako',87 permission='authenticated')88 config.add_route('apex_route53_ips_edit', '/ips/:id')89 config.add_view(ips_edit, route_name='apex_route53_ips_edit',90 renderer='apex_route53:templates/apex_r53_ips_edit.mako',91 permission='authenticated')92 config.add_route('apex_route53_ips_delete', '/ips/:id/delete')93 config.add_view(ips_delete, route_name='apex_route53_ips_delete',94 renderer='apex_route53:templates/apex_r53_ips_delete.mako',95 permission='authenticated')96 config.add_route('apex_route53_webhosts', '/webhosts')97 config.add_view(webhosts, route_name='apex_route53_webhosts',98 renderer='apex_route53:templates/apex_r53_webhosts.mako',99 permission='authenticated')100 config.add_route('apex_route53_webhosts_edit', '/webhosts/:id')101 config.add_view(webhosts_edit, route_name='apex_route53_webhosts_edit',102 renderer='apex_route53:templates/apex_r53_webhosts_edit.mako',103 permission='authenticated')104 config.add_route('apex_route53_webhosts_delete', '/webhosts/:id/delete')105 config.add_view(webhosts_delete, route_name='apex_route53_webhosts_delete',106 renderer='apex_route53:templates/apex_r53_webhosts_delete.mako',...
test_disco_route53.py
Source:test_disco_route53.py
1"""Tests of disco_route53"""2from unittest import TestCase3from boto.route53.record import Record4from moto import mock_route53, mock_sns5from disco_aws_automation import DiscoRoute536TEST_DOMAIN = 'example.com.'7TEST_DOMAIN2 = 'foo.com.'8TEST_RECORD_NAME = 'subdomain.example.com.'9TEST_RECORD_NAME2 = 'subdomain.foo.com.'10TEST_RECORD_TYPE = 'CNAME'11TEST_RECORD_VALUE = 'some.value'12def _create_mock_zone_and_records(route53):13 route53.create_hosted_zone(TEST_DOMAIN)14 route53.create_hosted_zone(TEST_DOMAIN2)15 example_com = route53.get_zone(TEST_DOMAIN)16 test_com = route53.get_zone(TEST_DOMAIN2)17 record_sets = route53.get_all_rrsets(example_com.id)18 record = Record(TEST_RECORD_NAME, TEST_RECORD_TYPE)19 record.add_value(TEST_RECORD_VALUE)20 record_sets.add_change_record('CREATE', record)21 record_sets.commit()22 record_sets = route53.get_all_rrsets(test_com.id)23 record = Record(TEST_RECORD_NAME2, TEST_RECORD_TYPE)24 record.add_value(TEST_RECORD_VALUE)25 record_sets.add_change_record('CREATE', record)26 record_sets.commit()27class DiscoRoute53Tests(TestCase):28 """Test DiscoRoute53"""29 @mock_sns30 @mock_route5331 def test_list_zones(self):32 """Test listing the available hosted zones"""33 disco_route53 = DiscoRoute53()34 _create_mock_zone_and_records(disco_route53.route53)35 zones = disco_route53.list_zones()36 self.assertEquals(len(zones), 2)37 self.assertEquals(zones[0].name, TEST_DOMAIN)38 self.assertEquals(zones[1].name, TEST_DOMAIN2)39 @mock_sns40 @mock_route5341 def test_list_records(self):42 """Test listing records for a hosted zone"""43 disco_route53 = DiscoRoute53()44 _create_mock_zone_and_records(disco_route53.route53)45 records = disco_route53.list_records(TEST_DOMAIN)46 self.assertEquals(len(records), 1)47 self.assertEquals(records[0].name, TEST_RECORD_NAME)48 @mock_sns49 @mock_route5350 def test_delete_records_by_value(self):51 """Test deleting records by value"""52 disco_route53 = DiscoRoute53()53 _create_mock_zone_and_records(disco_route53.route53)54 disco_route53.delete_records_by_value(TEST_RECORD_TYPE, TEST_RECORD_VALUE)55 zone = disco_route53.route53.get_zones()[0]56 self.assertEquals(len(disco_route53.route53.get_all_rrsets(zone.id)), 0)57 @mock_sns58 @mock_route5359 def test_get_records_by_value(self):60 """Test getting records by value"""61 disco_route53 = DiscoRoute53()62 _create_mock_zone_and_records(disco_route53.route53)63 actual = disco_route53.get_records_by_value(TEST_RECORD_TYPE, TEST_RECORD_VALUE)64 expected = [{65 'zone_name': TEST_DOMAIN,66 'record_name': TEST_RECORD_NAME67 }, {68 'zone_name': TEST_DOMAIN2,69 'record_name': TEST_RECORD_NAME270 }]...
res_config.py
Source:res_config.py
1# -*- coding: utf-8 -*-2from odoo import models, fields, api3class SaasPortalConfigWizard(models.TransientModel):4 _inherit = 'saas_portal.config.settings'5 saas_route53_aws_accessid = fields.Char('AWS Access ID')6 saas_route53_aws_accesskey = fields.Char('AWS Secret Key')7 @api.model8 def get_default_saas_route53_aws_accessid(self, fields):9 saas_route53_aws_accessid = self.env["ir.config_parameter"].get_param("saas_route53.saas_route53_aws_accessid", default=None)10 return {'saas_route53_aws_accessid': saas_route53_aws_accessid or False}11 @api.multi12 def set_saas_route53_aws_accessid(self):13 config_parameters = self.env["ir.config_parameter"]14 for record in self:15 config_parameters.set_param("saas_route53.saas_route53_aws_accessid", record.saas_route53_aws_accessid or '')16 @api.model17 def get_default_saas_route53_aws_accesskey(self, fields):18 saas_route53_aws_accesskey = self.env["ir.config_parameter"].get_param("saas_route53.saas_route53_aws_accesskey", default=None)19 return {'saas_route53_aws_accesskey': saas_route53_aws_accesskey or False}20 @api.multi21 def set_saas_route53_aws_accesskey(self):22 config_parameters = self.env["ir.config_parameter"]23 for record in self:...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!