def test_empty_domain(self): duckdns_client = DuckDNSClient(TEST_DUCKDNS_TOKEN) with self.assertRaises(AssertionError): duckdns_client.set_txt_record("", "simple text") with self.assertRaises(AssertionError): duckdns_client.clear_txt_record("")
def test_invalid_domain(self): duckdns_client = DuckDNSClient(TEST_DUCKDNS_TOKEN) with self.assertRaises(TXTUpdateError): duckdns_client.set_txt_record("thisdomainsisnotvalid", "simple text") with self.assertRaises(TXTUpdateError): duckdns_client.clear_txt_record("thisdomainsisnotvalid")
def test_wrong_domain(self): duckdns_client = DuckDNSClient(TEST_DUCKDNS_TOKEN) with self.subTest(): with self.assertRaises(TXTUpdateError): duckdns_client.set_txt_record("thisdomainsiswrong", "simple text") with self.subTest(): with self.assertRaises(TXTUpdateError): duckdns_client.clear_txt_record("thisdomainsiswrong")
def test_empty_domain(self): assert DOMAIN is not None and len(DOMAIN) > 0 assert DUCKDNS_TOKEN is not None and len(DUCKDNS_TOKEN) > 0 duckdns_client = DuckDNSClient(DUCKDNS_TOKEN) with self.assertRaises(AssertionError): duckdns_client.set_txt_record("", "simple text") with self.assertRaises(AssertionError): duckdns_client.clear_txt_record("")
def test_invalid_domain(self): assert DOMAIN is not None and len(DOMAIN) > 0 assert DUCKDNS_TOKEN is not None and len(DUCKDNS_TOKEN) > 0 duckdns_client = DuckDNSClient(DUCKDNS_TOKEN) with self.assertRaises(TXTUpdateError): duckdns_client.set_txt_record("thisdomainsisnotvalid", "simple text") with self.assertRaises(TXTUpdateError): duckdns_client.clear_txt_record("thisdomainsisnotvalid")
def test_invalid_token(self): duckdns_client = DuckDNSClient("42") with self.subTest(): # test set txt record with self.assertRaises(TXTUpdateError): duckdns_client.set_txt_record(TEST_DOMAIN, "simple text") with self.subTest(): # test clear txt record with self.assertRaises(TXTUpdateError): duckdns_client.clear_txt_record(TEST_DOMAIN)
def test_none_token(self): duckdns_client = DuckDNSClient(None) # test set txt record txt_set_error = False try: duckdns_client.set_txt_record(TEST_DOMAIN, "simple text") except AssertionError: txt_set_error = True self.assertEqual(True, txt_set_error) # test clear txt record txt_clear_error = False try: duckdns_client.clear_txt_record(TEST_DOMAIN) except AssertionError: txt_clear_error = True self.assertEqual(True, txt_clear_error)
def test_invalid_token(self): duckdns_client = DuckDNSClient("42") # test set txt record txt_set_error = False try: duckdns_client.set_txt_record(TEST_DOMAIN, "simple text") except TXTUpdateError: txt_set_error = True self.assertEqual(True, txt_set_error) # test clear txt record txt_clear_error = False try: duckdns_client.clear_txt_record(TEST_DOMAIN) except TXTUpdateError: txt_clear_error = True self.assertEqual(True, txt_clear_error)
def test_none_token(self): with self.subTest(): with self.assertRaises(NotValidDuckdnsTokenError): duckdns_client = DuckDNSClient(None) # explicitly set the token to None duckdns_client = DuckDNSClient("test") duckdns_client._token = None with self.subTest(): # test set txt record with self.assertRaises(TXTUpdateError): duckdns_client.set_txt_record(TEST_DOMAIN, "simple text") with self.subTest(): # test clear txt record with self.assertRaises(TXTUpdateError): duckdns_client.clear_txt_record(TEST_DOMAIN)
def test_clear_txt(self): assert DOMAIN is not None and len(DOMAIN) > 0 assert DUCKDNS_TOKEN is not None and len(DUCKDNS_TOKEN) > 0 duckdns_client = DuckDNSClient(DUCKDNS_TOKEN) txt_record_text = "simple text" duckdns_client.set_txt_record(DOMAIN, txt_record_text) # wait sometime for propagation of the txt update print("wait for the txt record update to propagate...") time.sleep(DEFAULT_PROPAGATION_SECONDS) duckdns_client.get_txt_record(DOMAIN) duckdns_client.clear_txt_record(DOMAIN) # wait sometime for propagation of the txt update print("wait for the txt record update to propagate...") time.sleep(DEFAULT_PROPAGATION_SECONDS) txt_value = duckdns_client.get_txt_record(DOMAIN) self.assertEqual("", txt_value)
def test_none_token(self): assert DOMAIN is not None and len(DOMAIN) > 0 assert DUCKDNS_TOKEN is not None and len(DUCKDNS_TOKEN) > 0 duckdns_client = DuckDNSClient(None) # test set txt record txt_set_error = False try: duckdns_client.set_txt_record(DOMAIN, "simple text") except AssertionError: txt_set_error = True self.assertEqual(True, txt_set_error) # test clear txt record txt_clear_error = False try: duckdns_client.clear_txt_record(DOMAIN) except AssertionError: txt_clear_error = True self.assertEqual(True, txt_clear_error)
def test_clear_txt(self): duckdns_client = DuckDNSClient(TEST_DUCKDNS_TOKEN) txt_record_text = "simple text" duckdns_client.set_txt_record(TEST_DOMAIN, txt_record_text) # wait sometime for propagation of the txt update print("wait for the txt record update to propagate...") time.sleep(DEFAULT_PROPAGATION_SECONDS) duckdns_client.clear_txt_record(TEST_DOMAIN) # wait sometime for propagation of the txt update print("wait for the txt record update to propagate...") time.sleep(DEFAULT_PROPAGATION_SECONDS) # get the cleared txt record from the specified nameserver custom_resolver = resolver.Resolver() custom_resolver.nameservers = NAMESERVER txt_value = custom_resolver.resolve(TEST_DOMAIN, "TXT").response.answer[0][0].strings[0].decode("utf-8") self.assertEqual("", txt_value)