<s> import sys <EOL> import unittest <EOL> from mock import MagicMock <EOL> from libcloud . dns . base import Record , Zone <EOL> from libcloud . dns . types import RecordType <EOL> from libcloud . dns . types import ZoneDoesNotExistError , ZoneAlreadyExistsError <EOL> from libcloud . dns . types import RecordDoesNotExistError <EOL> from libcloud . test import LibcloudTestCase , MockHttpTestCase <EOL> from libcloud . test . file_fixtures import DNSFileFixtures <EOL> from libcloud . test . secrets import DNS_PARAMS_DURABLEDNS <EOL> from libcloud . utils . py3 import httplib <EOL> from libcloud . dns . drivers . durabledns import DurableDNSDriver <EOL> from libcloud . dns . drivers . durabledns import ZONE_EXTRA_PARAMS_DEFAULT_VALUES <EOL> from libcloud . dns . drivers . durabledns import DEFAULT_TTL <EOL> from libcloud . dns . drivers . durabledns import RECORD_EXTRA_PARAMS_DEFAULT_VALUES <EOL> class DurableDNSTests ( LibcloudTestCase ) : <EOL> def setUp ( self ) : <EOL> DurableDNSDriver . connectionCls . conn_classes = ( None , DurableDNSMockHttp ) <EOL> DurableDNSMockHttp . type = None <EOL> self . driver = DurableDNSDriver ( * DNS_PARAMS_DURABLEDNS ) <EOL> def assertHasKeys ( self , dictionary , keys ) : <EOL> for key in keys : <EOL> self . assertTrue ( key in dictionary , '<STR_LIT>' % <EOL> ( key ) ) <EOL> def test_list_record_types ( self ) : <EOL> record_types = self . driver . list_record_types ( ) <EOL> self . assertEqual ( len ( record_types ) , <NUM_LIT:10> ) <EOL> self . assertTrue ( RecordType . A in record_types ) <EOL> self . assertTrue ( RecordType . AAAA in record_types ) <EOL> self . assertTrue ( RecordType . CNAME in record_types ) <EOL> self . assertTrue ( RecordType . HINFO in record_types ) <EOL> self . assertTrue ( RecordType . MX in record_types ) <EOL> self . assertTrue ( RecordType . NS in record_types ) <EOL> self . assertTrue ( RecordType . PTR in record_types ) <EOL> self . assertTrue ( RecordType . RP in record_types ) <EOL> self . assertTrue ( RecordType . SRV in record_types ) <EOL> self . assertTrue ( RecordType . TXT in record_types ) <EOL> def test_list_zones ( self ) : <EOL> extra = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : '<STR_LIT:127.0.0.1>' , <EOL> '<STR_LIT>' : '<STR_LIT:127.0.0.1>' } <EOL> zone = Zone ( id = '<STR_LIT>' , domain = '<STR_LIT>' , type = '<STR_LIT>' , <EOL> ttl = <NUM_LIT> , driver = self . driver , extra = extra ) <EOL> self . driver . get_zone = MagicMock ( return_value = zone ) <EOL> zones = self . driver . list_zones ( ) <EOL> self . assertEqual ( len ( zones ) , <NUM_LIT:2> ) <EOL> zone = zones [ <NUM_LIT:0> ] <EOL> self . assertEqual ( zone . id , '<STR_LIT>' ) <EOL> self . assertEqual ( zone . domain , '<STR_LIT>' ) <EOL> self . assertEqual ( zone . ttl , <NUM_LIT> ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , '<STR_LIT:127.0.0.1>' ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , '<STR_LIT:127.0.0.1>' ) <EOL> self . assertEqual ( len ( zone . extra . keys ( ) ) , <NUM_LIT:9> ) <EOL> def test_list_records ( self ) : <EOL> z_extra = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : '<STR_LIT:127.0.0.1>' , <EOL> '<STR_LIT>' : '<STR_LIT:127.0.0.1>' } <EOL> zone = Zone ( id = '<STR_LIT>' , domain = '<STR_LIT>' , type = '<STR_LIT>' , <EOL> ttl = <NUM_LIT> , driver = self . driver , extra = z_extra ) <EOL> extra = { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT> } <EOL> record = Record ( id = '<STR_LIT>' , type = '<STR_LIT:A>' , zone = zone , <EOL> name = '<STR_LIT>' , data = '<STR_LIT>' , <EOL> driver = self , extra = extra ) <EOL> self . driver . get_record = MagicMock ( return_value = record ) <EOL> records = self . driver . list_records ( zone = zone ) <EOL> self . assertEqual ( len ( records ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( record . id , '<STR_LIT>' ) <EOL> self . assertEqual ( record . name , '<STR_LIT>' ) <EOL> self . assertEqual ( record . type , '<STR_LIT:A>' ) <EOL> self . assertEqual ( record . data , '<STR_LIT>' ) <EOL> self . assertEqual ( record . zone , zone ) <EOL> self . assertEqual ( record . extra [ '<STR_LIT>' ] , <NUM_LIT:1> ) <EOL> self . assertEqual ( record . extra [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> def test_list_records_zone_does_not_exist ( self ) : <EOL> z_extra = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : '<STR_LIT:127.0.0.1>' , <EOL> '<STR_LIT>' : '<STR_LIT:127.0.0.1>' } <EOL> zone = Zone ( id = '<STR_LIT>' , domain = '<STR_LIT>' , type = '<STR_LIT>' , <EOL> ttl = <NUM_LIT> , driver = self . driver , extra = z_extra ) <EOL> DurableDNSMockHttp . type = '<STR_LIT>' <EOL> try : <EOL> self . driver . list_records ( zone = zone ) <EOL> except ZoneDoesNotExistError : <EOL> e = sys . exc_info ( ) [ <NUM_LIT:1> ] <EOL> self . assertEqual ( e . zone_id , zone . id ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_get_zone ( self ) : <EOL> zone = self . driver . get_zone ( zone_id = '<STR_LIT>' ) <EOL> self . assertEqual ( zone . id , '<STR_LIT>' ) <EOL> self . assertEqual ( zone . domain , '<STR_LIT>' ) <EOL> self . assertEqual ( zone . ttl , <NUM_LIT> ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( len ( zone . extra . keys ( ) ) , <NUM_LIT:9> ) <EOL> def test_get_zone_does_not_exist ( self ) : <EOL> DurableDNSMockHttp . type = '<STR_LIT>' <EOL> try : <EOL> self . driver . get_zone ( zone_id = '<STR_LIT>' ) <EOL> except ZoneDoesNotExistError : <EOL> e = sys . exc_info ( ) [ <NUM_LIT:1> ] <EOL> self . assertEqual ( e . zone_id , '<STR_LIT>' ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_get_record ( self ) : <EOL> record = self . driver . get_record ( zone_id = '<STR_LIT>' , <EOL> record_id = '<STR_LIT>' ) <EOL> self . assertEqual ( record . id , '<STR_LIT>' ) <EOL> self . assertEqual ( record . name , '<STR_LIT>' ) <EOL> self . assertEqual ( record . type , '<STR_LIT:A>' ) <EOL> self . assertEqual ( record . data , '<STR_LIT>' ) <EOL> self . assertEqual ( record . extra [ '<STR_LIT>' ] , <NUM_LIT:1> ) <EOL> self . assertEqual ( record . extra [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> def test_get_record_zone_does_not_exist ( self ) : <EOL> DurableDNSMockHttp . type = '<STR_LIT>' <EOL> try : <EOL> self . driver . get_record ( zone_id = '<STR_LIT>' , <EOL> record_id = '<STR_LIT>' ) <EOL> except ZoneDoesNotExistError : <EOL> pass <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_get_record_record_does_not_exist ( self ) : <EOL> DurableDNSMockHttp . type = '<STR_LIT>' <EOL> try : <EOL> self . driver . get_record ( zone_id = '<STR_LIT>' , record_id = '<STR_LIT>' ) <EOL> except RecordDoesNotExistError : <EOL> pass <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_create_zone_with_extra_param ( self ) : <EOL> DurableDNSMockHttp . type = '<STR_LIT>' <EOL> zone = self . driver . create_zone ( domain = '<STR_LIT>' , ttl = <NUM_LIT> , <EOL> extra = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> } ) <EOL> extra = ZONE_EXTRA_PARAMS_DEFAULT_VALUES <EOL> self . assertEqual ( zone . id , '<STR_LIT>' ) <EOL> self . assertEqual ( zone . domain , '<STR_LIT>' ) <EOL> self . assertEqual ( zone . ttl , <NUM_LIT> ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , extra [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , extra [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , extra [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , extra [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , extra [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , extra [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( len ( zone . extra . keys ( ) ) , <NUM_LIT:9> ) <EOL> def test_create_zone_no_extra_param ( self ) : <EOL> DurableDNSMockHttp . type = '<STR_LIT>' <EOL> zone = self . driver . create_zone ( domain = '<STR_LIT>' ) <EOL> extra = ZONE_EXTRA_PARAMS_DEFAULT_VALUES <EOL> self . assertEqual ( zone . id , '<STR_LIT>' ) <EOL> self . assertEqual ( zone . domain , '<STR_LIT>' ) <EOL> self . assertEqual ( zone . ttl , DEFAULT_TTL ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , extra [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , extra [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , extra [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , extra [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , extra [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , extra [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , extra [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( zone . extra [ '<STR_LIT>' ] , extra [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( len ( zone . extra . keys ( ) ) , <NUM_LIT:9> ) <EOL> def test_create_zone_zone_already_exist ( self ) : <EOL> DurableDNSMockHttp . type = '<STR_LIT>' <EOL> try : <EOL> self . driver . create_zone ( domain = '<STR_LIT>' ) <EOL> except ZoneAlreadyExistsError : <EOL> pass <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_create_record_no_extra_param ( self ) : <EOL> zone = self . driver . list_zones ( ) [ <NUM_LIT:0> ] <EOL> DurableDNSMockHttp . type = '<STR_LIT>' <EOL> record = self . driver . create_record ( name = '<STR_LIT>' , zone = zone , <EOL> type = RecordType . A , data = '<STR_LIT>' ) <EOL> self . assertEqual ( record . id , '<STR_LIT>' ) <EOL> self . assertEqual ( record . name , '<STR_LIT>' ) <EOL> self . assertEqual ( record . zone , zone ) <EOL> self . assertEqual ( record . type , RecordType . A ) <EOL> self . assertEqual ( record . data , '<STR_LIT>' ) <EOL> self . assertEqual ( record . extra . get ( '<STR_LIT>' ) , <EOL> RECORD_EXTRA_PARAMS_DEFAULT_VALUES . get ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( record . extra . get ( '<STR_LIT>' ) , <EOL> RECORD_EXTRA_PARAMS_DEFAULT_VALUES . get ( '<STR_LIT>' ) ) <EOL> def test_create_record_with_extra_param ( self ) : <EOL> zone = self . driver . list_zones ( ) [ <NUM_LIT:0> ] <EOL> DurableDNSMockHttp . type = '<STR_LIT>' <EOL> record = self . driver . create_record ( name = '<STR_LIT>' , zone = zone , <EOL> type = RecordType . A , data = '<STR_LIT>' , <EOL> extra = { '<STR_LIT>' : <NUM_LIT> } ) <EOL> self . assertEqual ( record . id , '<STR_LIT>' ) <EOL> self . assertEqual ( record . name , '<STR_LIT>' ) <EOL> self . assertEqual ( record . zone , zone ) <EOL> self . assertEqual ( record . type , RecordType . A ) <EOL> self . assertEqual ( record . data , '<STR_LIT>' ) <EOL> self . assertEqual ( record . extra . get ( '<STR_LIT>' ) , <EOL> RECORD_EXTRA_PARAMS_DEFAULT_VALUES . get ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( record . extra . get ( '<STR_LIT>' ) , <NUM_LIT> ) <EOL> def test_create_record_zone_does_not_exist ( self ) : <EOL> DurableDNSMockHttp . type = '<STR_LIT>' <EOL> z_extra = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : '<STR_LIT:127.0.0.1>' , <EOL> '<STR_LIT>' : '<STR_LIT:127.0.0.1>' } <EOL> zone = Zone ( id = '<STR_LIT>' , domain = '<STR_LIT>' , <EOL> type = '<STR_LIT>' , ttl = <NUM_LIT> , driver = self . driver , extra = z_extra ) <EOL> try : <EOL> self . driver . create_record ( name = '<STR_LIT>' , zone = zone , <EOL> type = RecordType . A , data = '<STR_LIT>' ) <EOL> except ZoneDoesNotExistError : <EOL> pass <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_update_zone ( self ) : <EOL> DurableDNSMockHttp . type = '<STR_LIT>' <EOL> z_extra = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : '<STR_LIT:127.0.0.1>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:127.0.0.1>' } <EOL> zone = Zone ( id = '<STR_LIT>' , domain = '<STR_LIT>' , <EOL> type = '<STR_LIT>' , ttl = <NUM_LIT> , driver = self . driver , extra = z_extra ) <EOL> new_extra = { '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> } <EOL> updated_zone = self . driver . update_zone ( zone , zone . domain , <EOL> type = zone . type , ttl = <NUM_LIT> , <EOL> extra = new_extra ) <EOL> self . assertEqual ( updated_zone . id , '<STR_LIT>' ) <EOL> self . assertEqual ( updated_zone . domain , '<STR_LIT>' ) <EOL> self . assertEqual ( updated_zone . ttl , <NUM_LIT> ) <EOL> self . assertEqual ( updated_zone . extra [ '<STR_LIT>' ] , z_extra [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( updated_zone . extra [ '<STR_LIT>' ] , z_extra [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( updated_zone . extra [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( updated_zone . extra [ '<STR_LIT>' ] , z_extra [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( updated_zone . extra [ '<STR_LIT>' ] , z_extra [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( updated_zone . extra [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> self . assertEqual ( updated_zone . extra [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> self . assertEqual ( updated_zone . extra [ '<STR_LIT>' ] , z_extra [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( updated_zone . extra [ '<STR_LIT>' ] , <EOL> z_extra [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( len ( updated_zone . extra . keys ( ) ) , <NUM_LIT:9> ) <EOL> def test_update_zone_zone_does_not_exist ( self ) : <EOL> DurableDNSMockHttp . type = '<STR_LIT>' <EOL> z_extra = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : '<STR_LIT:127.0.0.1>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:127.0.0.1>' } <EOL> zone = Zone ( id = '<STR_LIT>' , domain = '<STR_LIT>' , <EOL> type = '<STR_LIT>' , ttl = <NUM_LIT> , driver = self . driver , extra = z_extra ) <EOL> try : <EOL> self . driver . update_zone ( zone , zone . domain ) <EOL> except ZoneDoesNotExistError : <EOL> pass <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_update_record ( self ) : <EOL> z_extra = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : '<STR_LIT:127.0.0.1>' , <EOL> '<STR_LIT>' : '<STR_LIT:127.0.0.1>' } <EOL> zone = Zone ( id = '<STR_LIT>' , domain = '<STR_LIT>' , type = '<STR_LIT>' , <EOL> ttl = <NUM_LIT> , driver = self . driver , extra = z_extra ) <EOL> extra = { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT> } <EOL> record = Record ( id = '<STR_LIT>' , type = '<STR_LIT:A>' , zone = zone , <EOL> name = '<STR_LIT>' , data = '<STR_LIT>' , <EOL> driver = self , extra = extra ) <EOL> new_extra = { '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT> } <EOL> updated_record = self . driver . update_record ( record , record . name , <EOL> record . type , record . data , <EOL> extra = new_extra ) <EOL> self . assertEqual ( updated_record . data , '<STR_LIT>' ) <EOL> self . assertEqual ( updated_record . id , '<STR_LIT>' ) <EOL> self . assertEqual ( updated_record . name , '<STR_LIT>' ) <EOL> self . assertEqual ( updated_record . zone , record . zone ) <EOL> self . assertEqual ( updated_record . type , RecordType . A ) <EOL> self . assertEqual ( updated_record . extra . get ( '<STR_LIT>' ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( updated_record . extra . get ( '<STR_LIT>' ) , <NUM_LIT> ) <EOL> def test_update_record_zone_does_not_exist ( self ) : <EOL> z_extra = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : '<STR_LIT:127.0.0.1>' , <EOL> '<STR_LIT>' : '<STR_LIT:127.0.0.1>' } <EOL> zone = Zone ( id = '<STR_LIT>' , domain = '<STR_LIT>' , type = '<STR_LIT>' , <EOL> ttl = <NUM_LIT> , driver = self . driver , extra = z_extra ) <EOL> extra = { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT> } <EOL> record = Record ( id = '<STR_LIT>' , type = '<STR_LIT:A>' , zone = zone , <EOL> name = '<STR_LIT>' , data = '<STR_LIT>' , <EOL> driver = self , extra = extra ) <EOL> DurableDNSMockHttp . type = '<STR_LIT>' <EOL> try : <EOL> self . driver . update_record ( record , record . name , record . type , <EOL> record . data ) <EOL> except ZoneDoesNotExistError : <EOL> pass <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_delete_zone ( self ) : <EOL> z_extra = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : '<STR_LIT:127.0.0.1>' , <EOL> '<STR_LIT>' : '<STR_LIT:127.0.0.1>' } <EOL> zone = Zone ( id = '<STR_LIT>' , domain = '<STR_LIT>' , type = '<STR_LIT>' , <EOL> ttl = <NUM_LIT> , driver = self . driver , extra = z_extra ) <EOL> status = self . driver . delete_zone ( zone = zone ) <EOL> self . assertTrue ( status ) <EOL> def test_delete_zone_zone_does_not_exist ( self ) : <EOL> z_extra = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : '<STR_LIT:127.0.0.1>' , <EOL> '<STR_LIT>' : '<STR_LIT:127.0.0.1>' } <EOL> zone = Zone ( id = '<STR_LIT>' , domain = '<STR_LIT>' , type = '<STR_LIT>' , <EOL> ttl = <NUM_LIT> , driver = self . driver , extra = z_extra ) <EOL> DurableDNSMockHttp . type = '<STR_LIT>' <EOL> try : <EOL> self . driver . delete_zone ( zone = zone ) <EOL> except ZoneDoesNotExistError : <EOL> pass <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_delete_record ( self ) : <EOL> z_extra = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : '<STR_LIT:127.0.0.1>' , <EOL> '<STR_LIT>' : '<STR_LIT:127.0.0.1>' } <EOL> zone = Zone ( id = '<STR_LIT>' , domain = '<STR_LIT>' , type = '<STR_LIT>' , <EOL> ttl = <NUM_LIT> , driver = self . driver , extra = z_extra ) <EOL> extra = { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT> } <EOL> record = Record ( id = '<STR_LIT>' , type = '<STR_LIT:A>' , zone = zone , <EOL> name = '<STR_LIT>' , data = '<STR_LIT>' , <EOL> driver = self , extra = extra ) <EOL> status = self . driver . delete_record ( record = record ) <EOL> self . assertTrue ( status ) <EOL> def test_delete_record_record_does_not_exist ( self ) : <EOL> z_extra = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : '<STR_LIT:127.0.0.1>' , <EOL> '<STR_LIT>' : '<STR_LIT:127.0.0.1>' } <EOL> zone = Zone ( id = '<STR_LIT>' , domain = '<STR_LIT>' , type = '<STR_LIT>' , <EOL> ttl = <NUM_LIT> , driver = self . driver , extra = z_extra ) <EOL> extra = { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT> } <EOL> record = Record ( id = '<STR_LIT>' , type = '<STR_LIT:A>' , zone = zone , <EOL> name = '<STR_LIT>' , data = '<STR_LIT>' , <EOL> driver = self , extra = extra ) <EOL> DurableDNSMockHttp . type = '<STR_LIT>' <EOL> try : <EOL> self . driver . delete_record ( record = record ) <EOL> except RecordDoesNotExistError : <EOL> pass <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_delete_record_zone_does_not_exist ( self ) : <EOL> zone = self . driver . list_zones ( ) [ <NUM_LIT:0> ] <EOL> record = self . driver . list_records ( zone = zone ) [ <NUM_LIT:0> ] <EOL> DurableDNSMockHttp . type = '<STR_LIT>' <EOL> try : <EOL> self . driver . delete_record ( record = record ) <EOL> except ZoneDoesNotExistError : <EOL> pass <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> class DurableDNSMockHttp ( MockHttpTestCase ) : <EOL> fixtures = DNSFileFixtures ( '<STR_LIT>' ) <EOL> def _services_dns_listZones_php ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_listRecords_php ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_listRecords_php_ZONE_DOES_NOT_EXIST ( self , method , url , <EOL> body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_getZone_php ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_getZone_php_ZONE_DOES_NOT_EXIST ( self , method , url , <EOL> body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_getRecord_php ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_getRecord_php_ZONE_DOES_NOT_EXIST ( self , method , url , <EOL> body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_getRecord_php_RECORD_DOES_NOT_EXIST ( self , method , url , <EOL> body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_createZone_php_WITH_EXTRA_PARAMS ( self , method , url , body , <EOL> headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_getZone_php_WITH_EXTRA_PARAMS ( self , method , url , body , <EOL> headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_createZone_php_NO_EXTRA_PARAMS ( self , method , url , body , <EOL> headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_getZone_php_NO_EXTRA_PARAMS ( self , method , url , body , <EOL> headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_createZone_php_ZONE_ALREADY_EXIST ( self , method , url , <EOL> body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_createRecord_php_NO_EXTRA_PARAMS ( self , method , url , body , <EOL> headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_createRecord_php_WITH_EXTRA_PARAMS ( self , method , url , <EOL> body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_createRecord_php_ZONE_DOES_NOT_EXIST ( self , method , url , <EOL> body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_updateZone_php_UPDATE_ZONE ( self , method , url , <EOL> body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_getZone_php_UPDATE_ZONE ( self , method , url , <EOL> body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_updateZone_php_ZONE_DOES_NOT_EXIST ( self , method , url , <EOL> body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_updateRecord_php ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_updateRecord_php_ZONE_DOES_NOT_EXIST ( self , method , url , <EOL> body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_deleteZone_php ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_deleteZone_php_ZONE_DOES_NOT_EXIST ( self , method , url , <EOL> body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_deleteRecord_php ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_deleteRecord_php_RECORD_DOES_NOT_EXIST ( self , method , url , <EOL> body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _services_dns_deleteRecord_php_ZONE_DOES_NOT_EXIST ( self , method , url , <EOL> body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> sys . exit ( unittest . main ( ) ) </s>
