diff --git a/dyndns/tests/test_dyndns.py b/dyndns/tests/test_dyndns.py index 237379f..f68a1cf 100644 --- a/dyndns/tests/test_dyndns.py +++ b/dyndns/tests/test_dyndns.py @@ -14,7 +14,6 @@ class TestDomainDynDNS(TestCase): def setUp(self): self.domain = 'livius.co' self.expected_settings = { - 'domain': 'livius.co', 'provider_name': '1and1', 'url_api': 'https://api.domainconnect.1and1.com' } @@ -23,26 +22,22 @@ def tearDown(self): if os.path.exists('settings.txt'): os.remove('settings.txt') - def _setup_domain(self, domain, host, code): + def _setup_domain(self, domain, code): with patch('builtins.input', side_effect=code): - domain_setup.main(self.domain, host) + domain_setup.main(domain) def test_setup_one_domain(self): - host = 'host' code = 'test-code' - self._setup_domain(self.domain, host, [code,]) + self._setup_domain(self.domain, [code,]) assert (os.path.exists('settings.txt')), 'Settings file missing' with open('settings.txt', 'r') as file: - full_name = host + "." + self.domain - context = json.load(file) - assert (full_name in context), 'Domain not found in settings' + assert (self.domain in context), 'Domain not found in settings' - config = context[full_name] + config = context[self.domain] expected_config = self.expected_settings expected_config['code'] = code - expected_config['host'] = host assert (len(config.keys()) == len(expected_config.keys())), 'Config size incorrect' for key in expected_config.keys(): @@ -50,23 +45,21 @@ def test_setup_one_domain(self): 'Key `{}` found: {} expected: {}'.format(key, config[key], expected_config[key]) def test_setup_two_domains(self): - host_1 = 'host1' - host_2 = 'host2' + domain_1 = 'host1.' + self.domain + domain_2 = 'host2.' + self.domain code = 'test-code' - self._setup_domain(self.domain, host_1, [code,]) - self._setup_domain(self.domain, host_2, [code,]) + self._setup_domain(domain_1, [code,]) + self._setup_domain(domain_2, [code,]) assert (os.path.exists('settings.txt')), 'Settings file missing' with open('settings.txt', 'r') as file: context = json.load(file) - for host in [host_1, host_2]: - full_name = host + "." + self.domain - assert (full_name in context), 'Domain not found in settings' + for domain in [domain_1, domain_2]: + assert (domain in context), 'Domain not found in settings' - config = context[full_name] + config = context[domain] expected_config = self.expected_settings expected_config['code'] = code - expected_config['host'] = host assert (len(config.keys()) == len(expected_config.keys())), 'Config size incorrect' for key in expected_config.keys(): @@ -74,16 +67,14 @@ def test_setup_two_domains(self): 'Key `{}` found: {} expected: {}'.format(key, config[key], expected_config[key]) def test_setup_max_retries(self): - host = 'host' - self._setup_domain(self.domain, host, ['', '', '', '']) + self._setup_domain(self.domain, ['', '', '', '']) assert (not os.path.exists('settings.txt')), 'Settings file exists' @skip def test_update_domain(self): - host = 'host' - domain_setup.main(self.domain, host) + domain_setup.main(self.domain) assert (os.path.exists('settings.txt')), 'Settings file missing' - result = domain_update.main(self.domain, host) + result = domain_update.main(self.domain) assert (result == 'DNS record succesfully updated.'), result