Merge lp:~brendan-donegan/checkbox/create_connection_tests into lp:checkbox

Proposed by Brendan Donegan
Status: Work in progress
Proposed branch: lp:~brendan-donegan/checkbox/create_connection_tests
Merge into: lp:checkbox
Diff against target: 109 lines (+61/-6)
2 files modified
scripts/create_connection (+5/-6)
test_scripts/tests/test_create_connection.py (+56/-0)
To merge this branch: bzr merge lp:~brendan-donegan/checkbox/create_connection_tests
Reviewer Review Type Date Requested Status
Checkbox Developers Pending
Review via email: mp+159927@code.launchpad.net

Description of the change

Tests to check create_connection script

To post a comment you must log in.

Unmerged revisions

2054. By Brendan Donegan

Added a couple of tests for create_connection script

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scripts/create_connection'
2--- scripts/create_connection 2013-04-17 20:18:21 +0000
3+++ scripts/create_connection 2013-04-20 11:15:31 +0000
4@@ -22,7 +22,7 @@
5 id=%s
6 uuid=%s
7 type=802-11-wireless
8- """ % (ssid, uuid)
9+""" % (ssid, uuid)
10
11 wireless = """
12 [802-11-wireless]
13@@ -37,15 +37,14 @@
14 wireless_security = """
15 security=802-11-wireless-security
16
17-[802-11-wireless-security]
18- """
19+[802-11-wireless-security]"""
20
21 if security.lower() == 'wpa':
22 wireless_security += """
23 key-mgmt=wpa-psk
24 auth-alg=open
25 psk=%s
26- """ % key
27+""" % key
28
29 elif security.lower() == 'wep':
30 wireless_security += """
31@@ -62,8 +61,7 @@
32 method=auto
33
34 [ipv6]
35-method=auto
36- """
37+method=auto"""
38
39 return ip
40
41@@ -186,6 +184,7 @@
42 # Don't fail the script if unblock didn't work though
43
44 wifi_connection += wifi_ip_sections()
45+ import pdb; pdb.set_trace()
46
47 # NetworkManager replaces forward-slashes in SSIDs with asterisks
48 name = args.ssid.replace('/', '*')
49
50=== added file 'test_scripts/tests/test_create_connection.py'
51--- test_scripts/tests/test_create_connection.py 1970-01-01 00:00:00 +0000
52+++ test_scripts/tests/test_create_connection.py 2013-04-20 11:15:31 +0000
53@@ -0,0 +1,56 @@
54+#
55+# This file is part of Checkbox.
56+#
57+# Copyright 2013 Canonical Ltd.
58+#
59+# Checkbox is free software: you can redistribute it and/or modify
60+# it under the terms of the GNU General Public License as published by
61+# the Free Software Foundation, either version 3 of the License, or
62+# (at your option) any later version.
63+#
64+# Checkbox is distributed in the hope that it will be useful,
65+# but WITHOUT ANY WARRANTY; without even the implied warranty of
66+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
67+# GNU General Public License for more details.
68+#
69+# You should have received a copy of the GNU General Public License
70+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
71+#
72+import imp
73+import os
74+import unittest
75+
76+imp.load_source('create_connection', os.path.join(os.path.dirname(__file__),
77+ '..', '..', 'scripts', 'create_connection'))
78+import create_connection
79+
80+class CreateConnectionTest(unittest.TestCase):
81+
82+ def test_wifi_connection_section(self):
83+ ssid = 'checkbox'
84+ uuid = '4567-a345-3235-90876'
85+ expected_section = """
86+[connection]
87+id={id}
88+uuid={uuid}
89+type=802-11-wireless
90+
91+[802-11-wireless]
92+ssid={id}
93+mode=infrastructure""".format(id=ssid, uuid=uuid)
94+ actual_section = create_connection.wifi_connection_section(ssid, uuid)
95+ self.assertEqual(expected_section, actual_section)
96+
97+ def test_wifi_security_section(self):
98+ security='wpa'
99+ key='checkbox'
100+ expected_section = """
101+security=802-11-wireless-security
102+
103+[802-11-wireless-security]
104+key-mgmt=wpa-psk
105+auth-alg=open
106+psk={key}
107+""".format(key=key)
108+ actual_section = create_connection.wifi_security_section(security, key)
109+ self.assertEqual(expected_section, actual_section)

Subscribers

People subscribed via source and target branches