0
0
mirror of https://github.com/thegeeklab/corenetworks.git synced 2024-11-28 05:00:35 +00:00

fix formatting and tests

This commit is contained in:
Robert Kaussow 2020-05-11 22:50:12 +02:00
parent a332423c45
commit 6393f7a4c7
2 changed files with 13 additions and 2 deletions

View File

@ -211,13 +211,20 @@ class CoreNetworks():
records = self.records(zone, params={"name": params["name"]})
for r in records:
if params["type"] == "CNAME" or r["type"] == "CNAME":
if params["type"] == "CNAME" and r["type"] != "CNAME":
raise CorenetworksError(
"A record with the same name already exist ({name}). "
"CNAME records cannot use the same name with other records.".format(
name=r["name"]
)
)
if params["type"] != "CNAME" and r["type"] == "CNAME":
raise CorenetworksError(
"A CNAME record with the same name already exist ({name}). "
"CNAME records cannot use the same name with other records.".format(
name=r["name"]
)
)
curr = copy.deepcopy(params)
curr.pop("ttl")

View File

@ -31,7 +31,11 @@ def records_get_callback(request, context):
if query_raw:
query = dict((k.replace("[]", ""), v) for k, v in query_raw.items())
res = [d for d in records if d["type"].lower() in query["type"]]
if query.get("type"):
res = [d for d in records if d["type"].lower() in query["type"]]
else:
res = []
return "{}".format(json.dumps(res))
else:
return "{}".format(json.dumps(records))