41
42
with transaction():
42
43
self._mlist = create_list('test@example.com')
45
def test_create_domains(self):
46
# Create a domain with owners.
48
mail_host='example.org',
49
description='Example domain',
50
base_url='http://example.org',
51
owner=['someone@example.com', 'secondowner@example.com'],
53
content, response = call_api(
54
'http://localhost:9001/3.0/domains', data, method="POST")
55
self.assertEqual(response.status, 201)
44
57
def test_bogus_endpoint_extension(self):
45
58
# /domains/<domain>/lists/<anything> is not a valid endpoint.
46
59
with self.assertRaises(HTTPError) as cm:
87
100
call_api('http://localhost:9001/3.0/domains/example.com',
89
102
self.assertEqual(cm.exception.code, 404)
106
class TestDomainOwners(unittest.TestCase):
109
def test_get_missing_domain_owners(self):
110
# Try to get the owners of a missing domain.
111
with self.assertRaises(HTTPError) as cm:
112
call_api('http://localhost:9001/3.0/domains/example.net/owners')
113
self.assertEqual(cm.exception.code, 404)
115
def test_post_to_missing_domain_owners(self):
116
# Try to add owners to a missing domain.
117
with self.assertRaises(HTTPError) as cm:
118
call_api('http://localhost:9001/3.0/domains/example.net/owners', (
119
('owner', 'dave@example.com'), ('owner', 'elle@example.com'),
121
self.assertEqual(cm.exception.code, 404)
123
def test_delete_missing_domain_owners(self):
124
# Try to delete the owners of a missing domain.
125
with self.assertRaises(HTTPError) as cm:
126
call_api('http://localhost:9001/3.0/domains/example.net/owners',
128
self.assertEqual(cm.exception.code, 404)
130
def test_bad_post(self):
131
# Send POST data with an invalid attribute.
132
with self.assertRaises(HTTPError) as cm:
133
call_api('http://localhost:9001/3.0/domains/example.com/owners', (
134
('guy', 'dave@example.com'), ('gal', 'elle@example.com'),
136
self.assertEqual(cm.exception.code, 400)
138
def test_bad_delete(self):
139
# Send DELETE with any data.
140
with self.assertRaises(HTTPError) as cm:
141
call_api('http://localhost:9001/3.0/domains/example.com/owners', {
142
'owner': 'dave@example.com',
144
self.assertEqual(cm.exception.code, 400)