11# -*- coding: utf-8 -*-
22#
3- # Copyright (C) 2020 Roald Nefs <info@roaldnefs.com>
3+ # Copyright (C) 2020, 2012 Roald Nefs <info@roaldnefs.com>
44#
55# This file is part of python-transip.
6-
6+ #
77# python-transip is free software: you can redistribute it and/or modify
88# it under the terms of the GNU Lesser General Public License as published by
99# the Free Software Foundation, either version 3 of the License, or
1010# (at your option) any later version.
11-
11+ #
1212# python-transip is distributed in the hope that it will be useful,
1313# but WITHOUT ANY WARRANTY; without even the implied warranty of
1414# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1515# GNU Lesser General Public License for more details.
16-
16+ #
1717# You should have received a copy of the GNU Lesser General Public License
1818# along with python-transip. If not, see <https://www.gnu.org/licenses/>.
1919
2020import responses # type: ignore
2121import unittest
22- import pytest
2322
24- from typing import Type , List , Dict , Any , Union
23+ from typing import List , Dict , Any , Union
2524
2625from transip import TransIP
2726from transip .v6 .objects import Domain , WhoisContact , Nameserver , DnsEntry
28- from tests .utils import load_responses_fixture
27+ from tests .utils import load_responses_fixtures
2928
3029
31- @pytest .mark .usefixtures ("minimal_client_class" )
3230class DomainsTest (unittest .TestCase ):
3331 """Test the DomainService."""
3432
35- client : Type [TransIP ]
33+ client : TransIP
34+
35+ @classmethod
36+ def setUpClass (cls ) -> None :
37+ """Set up a minimal TransIP client for using the domain services."""
38+ cls .client = TransIP (access_token = 'ACCESS_TOKEN' )
3639
37- def setUp (self ):
38- # Setup mocked responses for the /domains endpoint
39- load_responses_fixture ("domains.json" )
40+ def setUp (self ) -> None :
41+ """ Setup mocked responses for the ' /domains' endpoint."""
42+ load_responses_fixtures ("domains.json" )
4043
4144 @responses .activate
4245 def test_get (self ) -> None :
43- domain : Type [ Domain ] = self .client .domains .get ("example.com" )
46+ domain : Domain = self .client .domains .get ("example.com" )
4447
4548 assert domain .get_id () == "example.com" # type: ignore
4649
4750 @responses .activate
4851 def test_contacts_list (self ) -> None :
49- domain : Type [ Domain ] = self .client .domains .get ("example.com" )
50- contacts : List [Type [ Domain ] ] = domain .contacts .list () # type: ignore
51- contact : Type [ Domain ] = contacts [0 ]
52+ domain : Domain = self .client .domains .get ("example.com" )
53+ contacts : List [Domain ] = domain .contacts .list () # type: ignore
54+ contact : Domain = contacts [0 ]
5255
5356 assert len (contacts ) == 1
5457 assert contact .companyName == "Example B.V." # type: ignore
5558
5659 @responses .activate
5760 def test_nameservers_list (self ) -> None :
58- domain : Type [ Domain ] = self .client .domains .get ("example.com" )
59- nameservers : List [Type [ Nameserver ] ] = domain .nameservers .list () # type: ignore
60- nameserver : Type [ Nameserver ] = nameservers [0 ]
61+ domain : Domain = self .client .domains .get ("example.com" )
62+ nameservers : List [Nameserver ] = domain .nameservers .list () # type: ignore
63+ nameserver : Nameserver = nameservers [0 ]
6164
6265 assert len (nameservers ) == 1
6366 assert nameserver .get_id () == "ns0.transip.nl" # type: ignore
6467
6568 @responses .activate
6669 def test_dns_list (self ) -> None :
67- domain : Type [ Domain ] = self .client .domains .get ("example.com" )
68- entries : List [Type [ DnsEntry ] ] = domain .dns .list () # type: ignore
69- entry : Type [ DnsEntry ] = entries [0 ]
70+ domain : Domain = self .client .domains .get ("example.com" )
71+ entries : List [DnsEntry ] = domain .dns .list () # type: ignore
72+ entry : DnsEntry = entries [0 ]
7073
7174 assert len (entries ) == 1
7275 assert entry .name == "www" # type: ignore
@@ -79,7 +82,7 @@ def test_dns_create(self) -> None:
7982 "type" : "A" ,
8083 "content" : "127.0.0.1"
8184 }
82- domain : Type [ Domain ] = self .client .domains .get ("example.com" )
85+ domain : Domain = self .client .domains .get ("example.com" )
8386 domain .dns .create (dns_entry_data ) # type: ignore
8487
8588 assert len (responses .calls ) == 2
0 commit comments