-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from roaldnefs/develop
- Loading branch information
Showing
21 changed files
with
653 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
include COPYING COPYING.LESSER README.md | ||
include tox.ini | ||
recursive-include requirements * | ||
recursive-include docs *.py *.rst user/*rst Makefile make.bat | ||
recursive-include docs *.py *.rst user/*rst Makefile make.bat | ||
recursive-include tests/fixtures *.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[ | ||
{ | ||
"method": "POST", | ||
"url": "https://api.transip.nl/v6/auth", | ||
"json": { | ||
"token": "ACCESS_TOKEN" | ||
}, | ||
"status": 200, | ||
"content_type": "application/json" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ | |
"url": "https://api.transip.nl/v6/domains", | ||
"status": 201, | ||
"content_type": "application/json", | ||
"match_json": { | ||
"match_json_params": { | ||
"domainName": "example.com", | ||
"contacts": [ | ||
{ | ||
|
@@ -94,7 +94,7 @@ | |
"url": "https://api.transip.nl/v6/domains", | ||
"status": 201, | ||
"content_type": "application/json", | ||
"match_json": { | ||
"match_json_params": { | ||
"domainName": "example.com", | ||
"authCode": "CYPMaVH+9MRjXGBc3InzHs7vNSUBPOjwpZm3GO+iDLHnFLtiP7sOKqW5JD1WeUpevZM6q1qS5YH9dGSp", | ||
"contacts": [ | ||
|
@@ -137,7 +137,7 @@ | |
"url": "https://api.transip.nl/v6/domains/example.com", | ||
"status": 204, | ||
"content_type": "application/json", | ||
"match_json": { | ||
"match_json_params": { | ||
"domain": { | ||
"name": "example.com", | ||
"authCode": "kJqfuOXNOYQKqh/jO4bYSn54YDqgAt1ksCe+ZG4Ud4nfpzw8qBsfR2JqAj7Ce12SxKcGD09v+yXd6lrm", | ||
|
@@ -160,7 +160,7 @@ | |
"url": "https://api.transip.nl/v6/domains/example.com", | ||
"status": 204, | ||
"content_type": "application/json", | ||
"match_json": { | ||
"match_json_params": { | ||
"endTime": "end" | ||
} | ||
}, | ||
|
@@ -186,7 +186,7 @@ | |
"url": "https://api.transip.nl/v6/domains/example.com/branding", | ||
"status": 204, | ||
"content_type": "application/json", | ||
"match_json": { | ||
"match_json_params": { | ||
"branding": { | ||
"companyName": "Example B.V.", | ||
"supportEmail": "[email protected]", | ||
|
@@ -229,7 +229,7 @@ | |
"url": "https://api.transip.nl/v6/domains/example.com/contacts", | ||
"status": 204, | ||
"content_type": "application/json", | ||
"match_json": { | ||
"match_json_params": { | ||
"contacts": [ | ||
{ | ||
"type": "registrant", | ||
|
@@ -271,7 +271,7 @@ | |
"url": "https://api.transip.nl/v6/domains/example.com/dns", | ||
"status": 201, | ||
"content_type": "application/json", | ||
"match_json": { | ||
"match_json_params": { | ||
"dnsEntry": { | ||
"name": "www", | ||
"expire": 86400, | ||
|
@@ -300,7 +300,7 @@ | |
"url": "https://api.transip.nl/v6/domains/example.com/nameservers", | ||
"status": 204, | ||
"content_type": "application/json", | ||
"match_json": { | ||
"match_json_params": { | ||
"nameservers": [ | ||
{ | ||
"hostname": "ns0.transip.nl", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,75 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (C) 2020 Roald Nefs <[email protected]> | ||
# Copyright (C) 2020, 2012 Roald Nefs <[email protected]> | ||
# | ||
# This file is part of python-transip. | ||
|
||
# | ||
# python-transip is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Lesser General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
|
||
# | ||
# python-transip is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
|
||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# along with python-transip. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
import responses # type: ignore | ||
import unittest | ||
import pytest | ||
|
||
from typing import Type, List, Dict, Any, Union | ||
from typing import List, Dict, Any, Union | ||
|
||
from transip import TransIP | ||
from transip.v6.objects import Domain, WhoisContact, Nameserver, DnsEntry | ||
from tests.utils import load_responses_fixture | ||
from tests.utils import load_responses_fixtures | ||
|
||
|
||
@pytest.mark.usefixtures("minimal_client_class") | ||
class DomainsTest(unittest.TestCase): | ||
"""Test the DomainService.""" | ||
|
||
client: Type[TransIP] | ||
client: TransIP | ||
|
||
@classmethod | ||
def setUpClass(cls) -> None: | ||
"""Set up a minimal TransIP client for using the domain services.""" | ||
cls.client = TransIP(access_token='ACCESS_TOKEN') | ||
|
||
def setUp(self): | ||
# Setup mocked responses for the /domains endpoint | ||
load_responses_fixture("domains.json") | ||
def setUp(self) -> None: | ||
"""Setup mocked responses for the '/domains' endpoint.""" | ||
load_responses_fixtures("domains.json") | ||
|
||
@responses.activate | ||
def test_get(self) -> None: | ||
domain: Type[Domain] = self.client.domains.get("example.com") | ||
domain: Domain = self.client.domains.get("example.com") | ||
|
||
assert domain.get_id() == "example.com" # type: ignore | ||
|
||
@responses.activate | ||
def test_contacts_list(self) -> None: | ||
domain: Type[Domain] = self.client.domains.get("example.com") | ||
contacts: List[Type[Domain]] = domain.contacts.list() # type: ignore | ||
contact: Type[Domain] = contacts[0] | ||
domain: Domain = self.client.domains.get("example.com") | ||
contacts: List[Domain] = domain.contacts.list() # type: ignore | ||
contact: Domain = contacts[0] | ||
|
||
assert len(contacts) == 1 | ||
assert contact.companyName == "Example B.V." # type: ignore | ||
|
||
@responses.activate | ||
def test_nameservers_list(self) -> None: | ||
domain: Type[Domain] = self.client.domains.get("example.com") | ||
nameservers: List[Type[Nameserver]] = domain.nameservers.list() # type: ignore | ||
nameserver: Type[Nameserver] = nameservers[0] | ||
domain: Domain = self.client.domains.get("example.com") | ||
nameservers: List[Nameserver] = domain.nameservers.list() # type: ignore | ||
nameserver: Nameserver = nameservers[0] | ||
|
||
assert len(nameservers) == 1 | ||
assert nameserver.get_id() == "ns0.transip.nl" # type: ignore | ||
|
||
@responses.activate | ||
def test_dns_list(self) -> None: | ||
domain: Type[Domain] = self.client.domains.get("example.com") | ||
entries: List[Type[DnsEntry]] = domain.dns.list() # type: ignore | ||
entry: Type[DnsEntry] = entries[0] | ||
domain: Domain = self.client.domains.get("example.com") | ||
entries: List[DnsEntry] = domain.dns.list() # type: ignore | ||
entry: DnsEntry = entries[0] | ||
|
||
assert len(entries) == 1 | ||
assert entry.name == "www" # type: ignore | ||
|
@@ -79,7 +82,7 @@ def test_dns_create(self) -> None: | |
"type": "A", | ||
"content": "127.0.0.1" | ||
} | ||
domain: Type[Domain] = self.client.domains.get("example.com") | ||
domain: Domain = self.client.domains.get("example.com") | ||
domain.dns.create(dns_entry_data) # type: ignore | ||
|
||
assert len(responses.calls) == 2 |
Oops, something went wrong.