diff --git a/src/postorius/tests/fixtures/vcr_cassettes/DomainCreationTest.test_only_redirect_if_domain_creation_is_successful.yaml b/src/postorius/tests/fixtures/vcr_cassettes/DomainCreationTest.test_only_redirect_if_domain_creation_is_successful.yaml new file mode 100644 index 0000000..d0aaa2b --- /dev/null +++ b/src/postorius/tests/fixtures/vcr_cassettes/DomainCreationTest.test_only_redirect_if_domain_creation_is_successful.yaml @@ -0,0 +1,125 @@ +interactions: +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/users/su@example.com + response: + body: {string: !!python/unicode 404 Not Found} + headers: + content-length: ['13'] + content-type: [application/json; charset=UTF-8] + status: {code: 404, message: Not Found} +- request: + body: base_url=http%3A%2F%2Fexample.com&description=A+new+Domain.&mail_host=example.com&owner=su%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/domains + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + content-type: [application/json; charset=UTF-8] + location: ['http://localhost:9001/3.0/domains/example.com'] + status: {code: 201, message: Created} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/users/su@example.com + response: + body: {string: !!python/unicode '{"created_on": "2005-08-01T07:49:23", "http_etag": + "\"f5fdcfb3183052b27f01c2242df9b6004fd145f9\"", "is_server_owner": false, + "self_link": "http://localhost:9001/3.0/users/2839", "user_id": 2839}'} + headers: + content-length: ['194'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/users/2839/addresses + response: + body: {string: !!python/unicode '{"entries": [{"email": "su@example.com", "http_etag": + "\"10b3a65090b9bdc5d284eec69c79f09cf571c7ab\"", "original_email": "su@example.com", + "registered_on": "2005-08-01T07:49:23", "self_link": "http://localhost:9001/3.0/addresses/su@example.com", + "user": "http://localhost:9001/3.0/users/2839"}], "http_etag": "\"ed3742102d66d365550f4b0f8e9cf3aa98a08833\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['384'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: base_url=http%3A%2F%2Fexample.com&description=A+new+Domain.&mail_host=example.com&owner=su%40example.com + headers: + accept-encoding: ['gzip, deflate'] + !!python/unicode content-type: [!!python/unicode application/x-www-form-urlencoded] + method: !!python/unicode POST + uri: http://localhost:9001/3.0/domains + response: + body: {string: !!python/unicode 'Duplicate email host: example.com'} + headers: + content-length: ['33'] + content-type: [application/json; charset=UTF-8] + status: {code: 400, message: Bad Request} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/domains + response: + body: {string: !!python/unicode '{"entries": [{"base_url": "http://example.com", + "description": "A new Domain.", "http_etag": "\"f574263235a622b271bd1115317117aee0e171f0\"", + "mail_host": "example.com", "self_link": "http://localhost:9001/3.0/domains/example.com", + "url_host": "example.com"}], "http_etag": "\"38f84ff58faee37a60c2f95a37be70303d2cfb59\"", + "start": 0, "total_size": 1}'} + headers: + content-length: ['349'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode DELETE + uri: http://localhost:9001/3.0/domains/example.com + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode GET + uri: http://localhost:9001/3.0/users + response: + body: {string: !!python/unicode '{"entries": [{"created_on": "2005-08-01T07:49:23", + "http_etag": "\"f5fdcfb3183052b27f01c2242df9b6004fd145f9\"", "is_server_owner": + false, "self_link": "http://localhost:9001/3.0/users/2839", "user_id": 2839}], + "http_etag": "\"4a073dc24ef419faf7f15af630340a6b535c5cfd\"", "start": 0, "total_size": + 1}'} + headers: + content-length: ['299'] + content-type: [application/json; charset=UTF-8] + status: {code: 200, message: OK} +- request: + body: null + headers: + accept-encoding: ['gzip, deflate'] + method: !!python/unicode DELETE + uri: http://localhost:9001/3.0/users/2839 + response: + body: {string: !!python/unicode ''} + headers: + content-length: ['0'] + status: {code: 204, message: No Content} +version: 1 diff --git a/src/postorius/tests/mailman_api_tests/test_domain_new.py b/src/postorius/tests/mailman_api_tests/test_domain_new.py index 314ee9d..d33652d 100644 --- a/src/postorius/tests/mailman_api_tests/test_domain_new.py +++ b/src/postorius/tests/mailman_api_tests/test_domain_new.py @@ -71,3 +71,15 @@ self.assertContains(response, 'Please enter a valid domain name') # self.assertHasErrorMessage(response) self.assertEquals(response.status_code, 200) + + def test_only_redirect_if_domain_creation_is_successful(self): + self.client.login(username='su', password='pwd') + post_data = {'mail_host': 'example.com', + 'site': '1', + 'description': 'A new Domain.'} + response = self.client.post(reverse('domain_new'), post_data) + self.assertEquals(response.status_code, 302) + self.assertHasSuccessMessage(response) + response = self.client.post(reverse('domain_new'), post_data) + self.assertEquals(response.status_code, 200) + self.assertIsNotNone(response.context['form'].errors)