/opt/imh-python/lib/python3.9/site-packages/libcloud/test/dns
NameSizeModeActions
fixtures/-0755rm
__pycache__/-0755rm
test_auroradns.py128490644editdlrm
test_base.py49890644editdlrm
test_buddyns.py62940644editdlrm
test_cloudflare.py150930644editdlrm
test_digitalocean.py71150644editdlrm
test_dnsimple.py118140644editdlrm
test_dnspod.py108040644editdlrm
test_durabledns.py278270644editdlrm
test_gandi.py120190644editdlrm
test_gandi_live.py171550644editdlrm
test_godaddy.py72600644editdlrm
test_google.py77320644editdlrm
test_hostvirtual.py107280644editdlrm
test_linode.py139950644editdlrm
test_liquidweb.py140790644editdlrm
test_luadns.py121530644editdlrm
test_nfsn.py60180644editdlrm
test_nsone.py103090644editdlrm
test_onapp.py95380644editdlrm
test_pointdns.py335260644editdlrm
test_powerdns.py77640644editdlrm
test_rackspace.py257930644editdlrm
test_rcodezero.py85650644editdlrm
test_route53.py142130644editdlrm
test_softlayer.py98170644editdlrm
test_vultr.py128480644editdlrm
test_worldwidedns.py203830644editdlrm
test_zerigo.py145870644editdlrm
test_zonomi.py161130644editdlrm
__init__.py00644editdlrm
Edit: /opt/imh-python/lib/python3.9/site-packages/libcloud/test/dns/test_nfsn.py (6018B)
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and import sys import unittest from libcloud.utils.py3 import httplib from libcloud.dns.base import Record, Zone from libcloud.dns.drivers.nfsn import NFSNDNSDriver from libcloud.dns.types import RecordType, ZoneDoesNotExistError from libcloud.dns.types import RecordDoesNotExistError from libcloud.test import LibcloudTestCase, MockHttp from libcloud.test.file_fixtures import DNSFileFixtures class NFSNTestCase(LibcloudTestCase): def setUp(self): NFSNDNSDriver.connectionCls.conn_class = NFSNMockHttp NFSNMockHttp.type = None self.driver = NFSNDNSDriver('testid', 'testsecret') self.test_zone = Zone(id='example.com', domain='example.com', driver=self.driver, type='master', ttl=None, extra={}) self.test_record = Record(id=None, name='', data='192.0.2.1', type=RecordType.A, zone=self.test_zone, driver=self.driver, extra={}) def test_list_zones(self): with self.assertRaises(NotImplementedError): self.driver.list_zones() def test_create_zone(self): with self.assertRaises(NotImplementedError): self.driver.create_zone('example.com') def test_get_zone(self): zone = self.driver.get_zone('example.com') self.assertEqual(zone.id, None) self.assertEqual(zone.domain, 'example.com') def test_delete_zone(self): with self.assertRaises(NotImplementedError): self.driver.delete_zone(self.test_zone) def test_create_record(self): NFSNMockHttp.type = 'CREATED' record = self.test_zone.create_record(name='newrecord', type=RecordType.A, data='127.0.0.1', extra={'ttl': 900}) self.assertEqual(record.id, None) self.assertEqual(record.name, 'newrecord') self.assertEqual(record.data, '127.0.0.1') self.assertEqual(record.type, RecordType.A) self.assertEqual(record.ttl, 900) def test_get_record(self): with self.assertRaises(NotImplementedError): self.driver.get_record('example.com', '12345') def test_delete_record(self): self.assertTrue(self.test_record.delete()) def test_list_records(self): records = self.driver.list_records(self.test_zone) self.assertEqual(len(records), 2) def test_ex_get_records_by(self): NFSNMockHttp.type = 'ONE_RECORD' records = self.driver.ex_get_records_by(self.test_zone, type=RecordType.A) self.assertEqual(len(records), 1) record = records[0] self.assertEqual(record.name, '') self.assertEqual(record.data, '192.0.2.1') self.assertEqual(record.type, RecordType.A) self.assertEqual(record.ttl, 3600) def test_get_zone_not_found(self): NFSNMockHttp.type = 'NOT_FOUND' with self.assertRaises(ZoneDoesNotExistError): self.driver.get_zone('example.com') def test_delete_record_not_found(self): NFSNMockHttp.type = 'NOT_FOUND' with self.assertRaises(RecordDoesNotExistError): self.assertTrue(self.test_record.delete()) class NFSNMockHttp(MockHttp): fixtures = DNSFileFixtures('nfsn') base_headers = {'content-type': 'application/x-nfsn-api'} def _dns_example_com_addRR_CREATED(self, method, url, body, headers): return (httplib.OK, '', self.base_headers, httplib.responses[httplib.OK]) def _dns_example_com_listRRs(self, method, url, body, headers): body = self.fixtures.load('list_records.json') return (httplib.OK, body, self.base_headers, httplib.responses[httplib.OK]) def _dns_example_com_listRRs_CREATED(self, method, url, body, headers): body = self.fixtures.load('list_records_created.json') return (httplib.OK, body, self.base_headers, httplib.responses[httplib.OK]) def _dns_example_com_removeRR(self, method, url, body, headers): return (httplib.OK, '', self.base_headers, httplib.responses[httplib.OK]) def _dns_example_com_serial(self, method, url, body, headers): return (httplib.OK, '12345', self.base_headers, httplib.responses[httplib.OK]) def _dns_example_com_listRRs_ONE_RECORD(self, method, url, body, headers): body = self.fixtures.load('list_one_record.json') return (httplib.OK, body, self.base_headers, httplib.responses[httplib.OK]) def _dns_example_com_serial_NOT_FOUND(self, method, url, body, headers): body = self.fixtures.load('zone_not_found.json') return (httplib.NOT_FOUND, body, self.base_headers, httplib.responses[httplib.NOT_FOUND]) def _dns_example_com_removeRR_NOT_FOUND(self, method, url, body, headers): body = self.fixtures.load('record_not_removed.json') return (httplib.NOT_FOUND, body, self.base_headers, httplib.responses[httplib.NOT_FOUND]) if __name__ == '__main__': sys.exit(unittest.main())