Resolve TLD's by name
Change-Id: I52d927ab3d5328e7b38198c6cfb60fe497f811d0
This commit is contained in:
parent
970e1dcd53
commit
b13ac20e28
@ -56,6 +56,21 @@ class TestTlds(v2.APIV2TestCase, v2.CrudMixin):
|
||||
response = self.client.tlds.get(ref["id"])
|
||||
self.assertEqual(ref, response)
|
||||
|
||||
def test_get_by_name(self):
|
||||
ref = self.new_ref(name="www")
|
||||
|
||||
self.stub_entity("GET", entity=ref, id=ref["id"])
|
||||
self.stub_url("GET", parts=[self.RESOURCE], json={"tlds": [ref]})
|
||||
|
||||
response = self.client.tlds.get(ref['name'])
|
||||
|
||||
self.assertEqual("GET", self.requests.request_history[0].method)
|
||||
self.assertEqual(
|
||||
"http://127.0.0.1:9001/v2/tlds?name=www",
|
||||
self.requests.request_history[0].url)
|
||||
|
||||
self.assertEqual(ref, response)
|
||||
|
||||
def test_list(self):
|
||||
items = [
|
||||
self.new_ref(),
|
||||
|
@ -14,6 +14,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from designateclient import client
|
||||
from designateclient.v2 import utils as v2_utils
|
||||
|
||||
|
||||
class TLDController(client.Controller):
|
||||
@ -32,17 +33,17 @@ class TLDController(client.Controller):
|
||||
|
||||
return self._get(url, response_key='tlds')
|
||||
|
||||
def get(self, tld_id):
|
||||
url = '/tlds/%s' % tld_id
|
||||
def get(self, tld):
|
||||
tld = v2_utils.resolve_by_name(self.list, tld)
|
||||
|
||||
return self._get(url)
|
||||
return self._get('/tlds/%s' % tld)
|
||||
|
||||
def update(self, tld_id, values):
|
||||
url = '/tlds/%s' % tld_id
|
||||
def update(self, tld, values):
|
||||
tld = v2_utils.resolve_by_name(self.list, tld)
|
||||
|
||||
return self._patch(url, data=values)
|
||||
return self._patch('/tlds/%s' % tld, data=values)
|
||||
|
||||
def delete(self, tld_id):
|
||||
url = '/tlds/%s' % tld_id
|
||||
def delete(self, tld):
|
||||
tld = v2_utils.resolve_by_name(self.list, tld)
|
||||
|
||||
return self._delete(url)
|
||||
return self._delete('/tlds/%s' % tld)
|
||||
|
Loading…
x
Reference in New Issue
Block a user