Skip to content

Commit

Permalink
test: add test cases for comments and changelists
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickellis committed Jan 26, 2024
1 parent 911c2f1 commit cd347a7
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## v0.0.3 - 2024-01-27 - Primary Zone Creation

* Support for creation of primary zones.
Includes automatic creation of NS record set,
and SOA record for zones that do not exist.
* Support for comments, i.e. zone descriptions.

## v0.0.2 - 2023-03-16 - CAA has arrived

* Support for CAA records has been added
Expand Down
53 changes: 52 additions & 1 deletion tests/test_octodns_provider_edgedns.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from os.path import dirname, join
from unittest import TestCase
from unittest.mock import patch

from requests import HTTPError
from requests_mock import ANY
Expand Down Expand Up @@ -100,7 +101,6 @@ def test_apply(self):
"ctok",
"cid",
"gid",
"Managed by OctoDNS.",
strict_supports=False,
)

Expand Down Expand Up @@ -169,3 +169,54 @@ def test_apply(self):
except NameError as e:
expected = "contractId not specified to create zone"
self.assertEqual(str(e), expected)

def test_zone_changelist_submit_with_comment(self):
comment = "Managed by OctoDNS."
provider = AkamaiProvider(
"test",
"s",
"akam.com",
"atok",
"ctok",
"cid",
"gid",
comment,
strict_supports=False,
)

with patch.object(provider._dns_client, '_request') as mock_request:
provider._dns_client.zone_changelist_submit("foo.bar.test.com")

mock_request.assert_called_once_with(
'POST',
'changelists/foo.bar.test.com/submit',
data={},
params={"comment": comment},
)

def test_apply_method_calls_zone_changelist_submit(self):
comment = "Managed by OctoDNS."
provider = AkamaiProvider(
"test",
"s",
"akam.com",
"atok",
"ctok",
"cid",
"gid",
comment,
strict_supports=False,
)

with requests_mock() as mock:
mock.get(ANY, status_code=404)
mock.post(ANY, status_code=201)
mock.put(ANY, status_code=200)
mock.delete(ANY, status_code=204)

with patch.object(
provider._dns_client, 'zone_changelist_submit'
) as mock_zone_submit:
plan = provider.plan(self.expected)
provider._apply(plan)
mock_zone_submit.assert_called_once()

0 comments on commit cd347a7

Please sign in to comment.