-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathtest_exceptions.py
More file actions
40 lines (35 loc) · 1.6 KB
/
Copy pathtest_exceptions.py
File metadata and controls
40 lines (35 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
#
# PowerDNS web api python client and interface (python-powerdns)
#
# Copyright (C) 2018 Denis Pompilio (jawa) <denis.pompilio@gmail.com>
#
# This file is part of python-powerdns
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the MIT License.
#
# This program 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
# MIT License for more details.
#
# You should have received a copy of the MIT License along with this
# program; if not, see <https://opensource.org/licenses/MIT>.
from unittest import TestCase
from powerdns import exceptions
class TestExceptions(TestCase):
def test_exception_pdns_error(self):
exc = exceptions.PDNSError("/fake-url", 404, "Not found.")
self.assertEqual(exc.url, "/fake-url")
self.assertEqual(exc.status_code, 404)
self.assertEqual(exc.message, "Not found.")
self.assertEqual(repr(exc), 'PDNSError("/fake-url", 404, "Not found.")')
self.assertEqual(str(exc), 'code=404 /fake-url: Not found.')
def test_exception_pdns_canonical_error(self):
self.assertTrue(issubclass(exceptions.PDNSCanonicalError, SyntaxError))
exc = exceptions.PDNSCanonicalError("fake-name.tld")
self.assertEqual(repr(exc), "PDNSCanonicalError('fake-name.tld')")
self.assertEqual(str(exc), "fake-name.tld")
self.assertEqual(exc.name, "fake-name.tld")
self.assertEqual(exc.message, "'fake-name.tld' is not canonical")