mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-17 15:04:11 +02:00
deleted and updated list not correct, needs fixing
This commit is contained in:
parent
1c6b1b0e2a
commit
9841100a8d
2 changed files with 37 additions and 15 deletions
|
@ -242,7 +242,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
# ignored because uncertain if we will even have a way to display mult.
|
# ignored because uncertain if we will even have a way to display mult.
|
||||||
# and adresses can be a list of mult address
|
# and adresses can be a list of mult address
|
||||||
|
|
||||||
hostList.append((host["name"],))
|
hostList.append((host["name"],host["addrs"]))
|
||||||
|
|
||||||
return hostList
|
return hostList
|
||||||
|
|
||||||
|
@ -298,22 +298,36 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
oldNameservers=self.nameservers
|
oldNameservers=self.nameservers
|
||||||
|
|
||||||
previousHostDict = {tup[0]: tup[1:] for tup in oldNameservers}
|
previousHostDict = {tup[0]: tup[1:] for tup in oldNameservers}
|
||||||
newHostDict = {tup[0]: tup[1:] for tup in hosts}
|
print(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
|
||||||
|
print(f" new host dict {newHostDict}")
|
||||||
deleted_values = []
|
deleted_values = []
|
||||||
updated_values = []
|
updated_values = []
|
||||||
new_values = []
|
new_values = []
|
||||||
|
|
||||||
for key in previousHostDict:
|
for prevHost in previousHostDict:
|
||||||
if key not in newHostDict:
|
addrs=previousHostDict[prevHost]
|
||||||
deleted_values.append(previousHostDict[key])
|
# get deleted values-which are values in previous nameserver list
|
||||||
elif newHostDict[key] != previousHostDict[key]:
|
# but are not in the list of new host values
|
||||||
updated_values.append(newHostDict[key])
|
if prevHost not in newHostDict:
|
||||||
|
deleted_values.append((prevHost,addrs))
|
||||||
|
#if the host exists in both, check if the addresses changed
|
||||||
|
else:
|
||||||
|
print(f"value in newHostDict[prevHost]{newHostDict[prevHost]}")
|
||||||
|
print(f"prevhost {prevHost}")
|
||||||
|
#not right updated_values: [(), (['1.2.4'],)]
|
||||||
|
|
||||||
for key in newHostDict:
|
if newHostDict[prevHost] != addrs:
|
||||||
if key not in previousHostDict:
|
updated_values.append((prevHost,newHostDict[prevHost]))
|
||||||
new_values.append(newHostDict[key])
|
|
||||||
|
|
||||||
|
|
||||||
|
#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)
|
||||||
return (deleted_values,updated_values,new_values, oldNameservers)
|
return (deleted_values,updated_values,new_values, oldNameservers)
|
||||||
|
|
||||||
@nameservers.setter # type: ignore
|
@nameservers.setter # type: ignore
|
||||||
|
|
|
@ -547,9 +547,17 @@ 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",)]
|
||||||
retTuple=self.domain.getNameserverChanges(newChanges)
|
deleted_values,updated_values,new_values, oldNameservers=self.domain.getNameserverChanges(newChanges)
|
||||||
print(retTuple)
|
print(f"deleted: {deleted_values}\n")
|
||||||
|
print(f"updated_values: {updated_values}\n") #has an extra, why?
|
||||||
|
print(f"new_values: {new_values}\n")# good
|
||||||
|
print(f"oldNameservers: {oldNameservers}\n") #good
|
||||||
|
#expecting:
|
||||||
|
# updated_values==1 -- which is "ns3.example.com"
|
||||||
|
# newvalues==1 -- which is "ns4.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