mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-16 06:24:12 +02:00
fixed getNameserverChanges
This commit is contained in:
parent
9841100a8d
commit
46f6042bf7
2 changed files with 19 additions and 15 deletions
|
@ -286,6 +286,15 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
except RegistryError as e:
|
except RegistryError as e:
|
||||||
logger.error("Error _create_host, code was %s error was %s" % (e.code, e))
|
logger.error("Error _create_host, code was %s error was %s" % (e.code, e))
|
||||||
return e.code
|
return e.code
|
||||||
|
def _convert_list_to_dict(self, listToConvert: list[tuple[str]]):
|
||||||
|
newDict={}
|
||||||
|
for tup in listToConvert:
|
||||||
|
if len(tup) == 1:
|
||||||
|
newDict[tup[0]] = None
|
||||||
|
else:
|
||||||
|
newDict[tup[0]] = tup[1]
|
||||||
|
return newDict
|
||||||
|
|
||||||
def getNameserverChanges(self, hosts:list[tuple[str]]):
|
def getNameserverChanges(self, hosts:list[tuple[str]]):
|
||||||
"""
|
"""
|
||||||
calls self.nameserver, it should pull from cache but may result
|
calls self.nameserver, it should pull from cache but may result
|
||||||
|
@ -297,10 +306,10 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
oldNameservers:"""
|
oldNameservers:"""
|
||||||
oldNameservers=self.nameservers
|
oldNameservers=self.nameservers
|
||||||
|
|
||||||
previousHostDict = {tup[0]: tup[1:] for tup in oldNameservers}
|
previousHostDict = self._convert_list_to_dict(oldNameservers)
|
||||||
print(previousHostDict)
|
print("previousHostDict {previousHostDict}")
|
||||||
#when slicing the tuple at tup[1:] it is causing it to be a tuple instead of a list
|
|
||||||
newHostDict = {tup[0]: tup[1:] for tup in hosts} #TODO-when slicing for addresses it should be a list or None
|
newHostDict = self._convert_list_to_dict(hosts)
|
||||||
print(f" new host dict {newHostDict}")
|
print(f" new host dict {newHostDict}")
|
||||||
deleted_values = []
|
deleted_values = []
|
||||||
updated_values = []
|
updated_values = []
|
||||||
|
@ -321,12 +330,6 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
if newHostDict[prevHost] != addrs:
|
if newHostDict[prevHost] != addrs:
|
||||||
updated_values.append((prevHost,newHostDict[prevHost]))
|
updated_values.append((prevHost,newHostDict[prevHost]))
|
||||||
|
|
||||||
|
|
||||||
#new value is one that is not in the previous dict
|
|
||||||
# for key in newHostDict:
|
|
||||||
# if key not in previousHostDict:
|
|
||||||
# new_values.append(newHostDict[key])
|
|
||||||
|
|
||||||
new_values=set(newHostDict)-set(previousHostDict)
|
new_values=set(newHostDict)-set(previousHostDict)
|
||||||
return (deleted_values,updated_values,new_values, oldNameservers)
|
return (deleted_values,updated_values,new_values, oldNameservers)
|
||||||
|
|
||||||
|
|
|
@ -549,15 +549,16 @@ class TestRegistrantNameservers(MockEppLib):
|
||||||
newChanges=[("ns1.example.com",),("ns3.example.com",["1.2.4"]),("ns4.example.com",)]
|
newChanges=[("ns1.example.com",),("ns3.example.com",["1.2.4"]),("ns4.example.com",)]
|
||||||
deleted_values,updated_values,new_values, oldNameservers=self.domain.getNameserverChanges(newChanges)
|
deleted_values,updated_values,new_values, oldNameservers=self.domain.getNameserverChanges(newChanges)
|
||||||
print(f"deleted: {deleted_values}\n")
|
print(f"deleted: {deleted_values}\n")
|
||||||
print(f"updated_values: {updated_values}\n") #has an extra, why?
|
print(f"updated_values: {updated_values}\n")
|
||||||
print(f"new_values: {new_values}\n")# good
|
print(f"new_values: {new_values}\n")
|
||||||
print(f"oldNameservers: {oldNameservers}\n") #good
|
print(f"oldNameservers: {oldNameservers}\n")
|
||||||
|
print("CHANGE")
|
||||||
|
print(self.domain._convert_list_to_dict(newChanges))
|
||||||
#expecting:
|
#expecting:
|
||||||
# updated_values==1 -- which is "ns3.example.com"
|
# updated_values==1 -- which is "ns3.example.com"
|
||||||
# newvalues==1 -- which is "ns4.example.com"
|
# newvalues==1 -- which is "ns4.example.com"
|
||||||
# deleted==1 --which is "ns2.example.com"
|
# deleted==1 --which is "ns2.example.com"
|
||||||
|
|
||||||
# self.assertTrue()
|
|
||||||
def test_user_adds_one_nameserver(self):
|
def test_user_adds_one_nameserver(self):
|
||||||
"""
|
"""
|
||||||
Scenario: Registrant adds a single nameserver
|
Scenario: Registrant adds a single nameserver
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue