Merge lp:~jose/charms/precise/mailman/add-tests into lp:charms/mailman

Proposed by José Antonio Rey
Status: Merged
Merged at revision: 35
Proposed branch: lp:~jose/charms/precise/mailman/add-tests
Merge into: lp:charms/mailman
Diff against target: 105 lines (+95/-0)
2 files modified
tests/00-setup (+7/-0)
tests/10-deploy (+88/-0)
To merge this branch: bzr merge lp:~jose/charms/precise/mailman/add-tests
Reviewer Review Type Date Requested Status
Tim Van Steenburgh (community) Approve
Review Queue (community) automated testing Needs Fixing
Review via email: mp+241169@code.launchpad.net

Description of the change

Tests for Mailman were added. These tests, written with Amulet, will verify that:

 * Mailman is up and running on the web side (both the homepage and admin interface)
 * Mailman is able to create a mailing list

To post a comment you must log in.
Revision history for this message
Review Queue (review-queue) wrote :

This items has failed automated testing! Results available here http://reports.vapour.ws/charm-tests/charm-bundle-test-10346-results

review: Needs Fixing (automated testing)
Revision history for this message
Tim Van Steenburgh (tvansteenburgh) wrote :

+1 LGTM, nice, thanks José!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'tests'
2=== added file 'tests/00-setup'
3--- tests/00-setup 1970-01-01 00:00:00 +0000
4+++ tests/00-setup 2014-11-08 05:24:17 +0000
5@@ -0,0 +1,7 @@
6+#!/bin/bash
7+
8+set -ex
9+
10+sudo add-apt-repository ppa:juju/stable -y
11+sudo apt-get update
12+sudo apt-get install amulet python3-requests git -y
13
14=== added file 'tests/10-deploy'
15--- tests/10-deploy 1970-01-01 00:00:00 +0000
16+++ tests/10-deploy 2014-11-08 05:24:17 +0000
17@@ -0,0 +1,88 @@
18+#!/usr/bin/env python3
19+
20+import amulet
21+import requests
22+import unittest
23+
24+class TestDeployment(unittest.TestCase):
25+ @classmethod
26+ def setUpClass(cls):
27+ cls.deployment = amulet.Deployment()
28+
29+ cls.deployment.add('mailman')
30+ cls.password = 'juju'
31+ cls.deployment.configure('mailman', {'password': cls.password})
32+ cls.deployment.expose('mailman')
33+
34+ try:
35+ cls.deployment.setup(timeout=900)
36+ cls.deployment.sentry.wait()
37+ except amulet.helpers.TimeoutError:
38+ amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up"
39+ "in time")
40+ except:
41+ raise
42+ cls.unit = cls.deployment.sentry.unit['mailman/0']
43+ cls.ipaddr = cls.unit.info['public-address']
44+ cls.deployment.configure('mailman', {'domain': cls.ipaddr})
45+ cls.base_url = 'http://%s/cgi-bin/mailman' % cls.ipaddr
46+ cls.listname = 'Jujutestlist'
47+
48+ def test_1_verify_homepage(self):
49+ url = '%s/listinfo/' % self.base_url
50+ response = requests.get(url)
51+ response.raise_for_status()
52+
53+ text = response.text.find('Mailing Lists')
54+ found_text = text != -1
55+
56+ if found_text:
57+ print ('Mailman is running on %s' % self.ipaddr)
58+ else:
59+ message = 'Mailman is not running on %s' % self.ipaddr
60+ amulet.raise_status(amulet.FAIL, msg=message)
61+
62+ def test_2_verify_admin(self):
63+ url = '%s/admin/' % self.base_url
64+ response = requests.get(url)
65+ response.raise_for_status()
66+
67+ text = response.text.find('Admin Links')
68+ found_text = response != -1
69+
70+ if found_text:
71+ print('Admin page was found, Mailman is indeed running correctly on'
72+ ' %s' % self.ipaddr)
73+ else:
74+ message = 'Admin links were not found, something is going on here. \
75+ Mailman not available on %s' % self.ipaddr
76+ amulet.raise_status(amulet.FAIL, msg=message)
77+
78+ def test_3_create_list(self):
79+ url = '%s/create/' % self.base_url
80+ listvalues = {'listname': self.listname, 'owner': 'test@example.com',
81+ 'autogen': '0', 'langs': 'en', 'notify': '1', 'password':
82+ self.password, 'confirm': self.password, 'moderate': '0',
83+ 'auth': self.password, 'doit': 'Create List'}
84+ submit_list = requests.post(url, data=listvalues)
85+ print(submit_list.text)
86+
87+
88+ def test_4_list_creation(self):
89+ url = '%s/listinfo/' % self.base_url
90+
91+ response = requests.get(url)
92+ response.raise_for_status()
93+
94+ text = response.text.find(self.listname)
95+ found_text = text != -1
96+
97+ if found_text:
98+ print('Mailing list was successfully created on %s!' % self.ipaddr)
99+ else:
100+ message = ('Test was not able to create mailing list on %s' %
101+ self.ipaddr)
102+ amulet.raise_status(amulet.FAIL, msg=message)
103+
104+if __name__ == '__main__':
105+ unittest.main()

Subscribers

People subscribed via source and target branches

to all changes: