Skip to content
Extraits de code Groupes Projets
Valider 7c487075 rédigé par François De Keersmaeker's avatar François De Keersmaeker
Parcourir les fichiers

Updated unit tests

parent 07cfbcfe
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Pipeline #57295 réussi
......@@ -6,4 +6,5 @@ dist
*.egg-info
.pytest_cache
*.txt
*.json
test.py
; unbound cache dump
START_RRSET_CACHE
test.com. 300 IN A 93.184.216.34
; CNAME records
test1.local. 300 IN A 192.168.1.100
test.local. 300 IN CNAME test1.local.
END_RRSET_CACHE
EOF
......@@ -9,6 +9,7 @@ from dns_unbound_cache_reader import DnsTableKeys
self_path = os.path.abspath(__file__)
self_dir = os.path.dirname(self_path)
sample_cache_file = os.path.join(self_dir, "sample_dns_cache.txt")
sample_cache_file_update = os.path.join(self_dir, "sample_dns_cache_update.txt")
### TEST FUNCTIONS ###
......@@ -35,3 +36,18 @@ def test_read_sample_cache_file() -> None:
assert dns_table_alias["example1.local"] == "example.local"
assert dns_table_alias["server1.example.com"] == "_tcp_.matter.example.com"
assert dns_table_alias["server2.example.com"] == "_tcp_.matter.example.com"
def test_update_dns_table() -> None:
"""
Test updating an existing DNS table.
"""
dns_table = dns_reader.read_dns_cache(file=sample_cache_file)
dns_table = dns_reader.update_dns_table(dns_table, file=sample_cache_file_update)
dns_table_ip = dns_table[DnsTableKeys.IP.name]
assert dns_table_ip["93.184.216.34"] == "test.com"
assert dns_table_ip["192.168.1.100"] == "test.local"
dns_table_alias = dns_table[DnsTableKeys.ALIAS.name]
assert dns_table_alias["test1.local"] == "test.local"
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter