<s> import sys <EOL> import unittest <EOL> from libcloud . utils . py3 import httplib <EOL> from libcloud . dns . base import Record , Zone <EOL> from libcloud . dns . drivers . nfsn import NFSNDNSDriver <EOL> from libcloud . dns . types import RecordType , ZoneDoesNotExistError <EOL> from libcloud . dns . types import RecordDoesNotExistError <EOL> from libcloud . test import LibcloudTestCase , MockHttp <EOL> from libcloud . test . file_fixtures import DNSFileFixtures <EOL> class NFSNTestCase ( LibcloudTestCase ) : <EOL> def setUp ( self ) : <EOL> NFSNDNSDriver . connectionCls . conn_classes = ( None , NFSNMockHttp ) <EOL> NFSNMockHttp . type = None <EOL> self . driver = NFSNDNSDriver ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . test_zone = Zone ( id = '<STR_LIT>' , domain = '<STR_LIT>' , <EOL> driver = self . driver , type = '<STR_LIT>' , ttl = None , <EOL> extra = { } ) <EOL> self . test_record = Record ( id = None , name = '<STR_LIT>' , data = '<STR_LIT>' , <EOL> type = RecordType . A , zone = self . test_zone , <EOL> driver = self . driver , extra = { } ) <EOL> def test_list_zones ( self ) : <EOL> with self . assertRaises ( NotImplementedError ) : <EOL> self . driver . list_zones ( ) <EOL> def test_create_zone ( self ) : <EOL> with self . assertRaises ( NotImplementedError ) : <EOL> self . driver . create_zone ( '<STR_LIT>' ) <EOL> def test_get_zone ( self ) : <EOL> zone = self . driver . get_zone ( '<STR_LIT>' ) <EOL> self . assertEquals ( zone . id , None ) <EOL> self . assertEquals ( zone . domain , '<STR_LIT>' ) <EOL> def test_delete_zone ( self ) : <EOL> with self . assertRaises ( NotImplementedError ) : <EOL> self . driver . delete_zone ( self . test_zone ) <EOL> def test_create_record ( self ) : <EOL> NFSNMockHttp . type = '<STR_LIT>' <EOL> record = self . test_zone . create_record ( name = '<STR_LIT>' , <EOL> type = RecordType . A , <EOL> data = '<STR_LIT:127.0.0.1>' , <EOL> extra = { '<STR_LIT>' : <NUM_LIT> } ) <EOL> self . assertEquals ( record . id , None ) <EOL> self . assertEquals ( record . name , '<STR_LIT>' ) <EOL> self . assertEquals ( record . data , '<STR_LIT:127.0.0.1>' ) <EOL> self . assertEquals ( record . type , RecordType . A ) <EOL> self . assertEquals ( record . ttl , <NUM_LIT> ) <EOL> def test_get_record ( self ) : <EOL> with self . assertRaises ( NotImplementedError ) : <EOL> self . driver . get_record ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_delete_record ( self ) : <EOL> self . assertTrue ( self . test_record . delete ( ) ) <EOL> def test_list_records ( self ) : <EOL> records = self . driver . list_records ( self . test_zone ) <EOL> self . assertEqual ( len ( records ) , <NUM_LIT:2> ) <EOL> def test_ex_get_records_by ( self ) : <EOL> NFSNMockHttp . type = '<STR_LIT>' <EOL> records = self . driver . ex_get_records_by ( self . test_zone , <EOL> type = RecordType . A ) <EOL> self . assertEqual ( len ( records ) , <NUM_LIT:1> ) <EOL> record = records [ <NUM_LIT:0> ] <EOL> self . assertEquals ( record . name , '<STR_LIT>' ) <EOL> self . assertEquals ( record . data , '<STR_LIT>' ) <EOL> self . assertEquals ( record . type , RecordType . A ) <EOL> self . assertEquals ( record . ttl , <NUM_LIT> ) <EOL> def test_get_zone_not_found ( self ) : <EOL> NFSNMockHttp . type = '<STR_LIT>' <EOL> with self . assertRaises ( ZoneDoesNotExistError ) : <EOL> self . driver . get_zone ( '<STR_LIT>' ) <EOL> def test_delete_record_not_found ( self ) : <EOL> NFSNMockHttp . type = '<STR_LIT>' <EOL> with self . assertRaises ( RecordDoesNotExistError ) : <EOL> self . assertTrue ( self . test_record . delete ( ) ) <EOL> class NFSNMockHttp ( MockHttp ) : <EOL> fixtures = DNSFileFixtures ( '<STR_LIT>' ) <EOL> base_headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> def _dns_example_com_addRR_CREATED ( self , method , url , body , headers ) : <EOL> return ( httplib . OK , '<STR_LIT>' , self . base_headers , <EOL> httplib . responses [ httplib . OK ] ) <EOL> def _dns_example_com_listRRs ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , self . base_headers , <EOL> httplib . responses [ httplib . OK ] ) <EOL> def _dns_example_com_listRRs_CREATED ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , self . base_headers , <EOL> httplib . responses [ httplib . OK ] ) <EOL> def _dns_example_com_removeRR ( self , method , url , body , headers ) : <EOL> return ( httplib . OK , '<STR_LIT>' , self . base_headers , <EOL> httplib . responses [ httplib . OK ] ) <EOL> def _dns_example_com_serial ( self , method , url , body , headers ) : <EOL> return ( httplib . OK , '<STR_LIT>' , self . base_headers , <EOL> httplib . responses [ httplib . OK ] ) <EOL> def _dns_example_com_listRRs_ONE_RECORD ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , self . base_headers , <EOL> httplib . responses [ httplib . OK ] ) <EOL> def _dns_example_com_serial_NOT_FOUND ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . NOT_FOUND , body , self . base_headers , <EOL> httplib . responses [ httplib . NOT_FOUND ] ) <EOL> def _dns_example_com_removeRR_NOT_FOUND ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . NOT_FOUND , body , self . base_headers , <EOL> httplib . responses [ httplib . NOT_FOUND ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> sys . exit ( unittest . main ( ) ) </s>
