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
=== modified file 'scripts/create_connection'
--- scripts/create_connection 2013-04-17 20:18:21 +0000
+++ scripts/create_connection 2013-04-20 11:15:31 +0000
@@ -22,7 +22,7 @@
22id=%s22id=%s
23uuid=%s23uuid=%s
24type=802-11-wireless24type=802-11-wireless
25 """ % (ssid, uuid)25""" % (ssid, uuid)
2626
27 wireless = """27 wireless = """
28[802-11-wireless]28[802-11-wireless]
@@ -37,15 +37,14 @@
37 wireless_security = """37 wireless_security = """
38security=802-11-wireless-security38security=802-11-wireless-security
3939
40[802-11-wireless-security]40[802-11-wireless-security]"""
41 """
4241
43 if security.lower() == 'wpa':42 if security.lower() == 'wpa':
44 wireless_security += """43 wireless_security += """
45key-mgmt=wpa-psk44key-mgmt=wpa-psk
46auth-alg=open45auth-alg=open
47psk=%s46psk=%s
48 """ % key47""" % key
4948
50 elif security.lower() == 'wep':49 elif security.lower() == 'wep':
51 wireless_security += """50 wireless_security += """
@@ -62,8 +61,7 @@
62method=auto61method=auto
6362
64[ipv6]63[ipv6]
65method=auto64method=auto"""
66 """
6765
68 return ip66 return ip
6967
@@ -186,6 +184,7 @@
186 # Don't fail the script if unblock didn't work though184 # Don't fail the script if unblock didn't work though
187185
188 wifi_connection += wifi_ip_sections()186 wifi_connection += wifi_ip_sections()
187 import pdb; pdb.set_trace()
189188
190 # NetworkManager replaces forward-slashes in SSIDs with asterisks189 # NetworkManager replaces forward-slashes in SSIDs with asterisks
191 name = args.ssid.replace('/', '*')190 name = args.ssid.replace('/', '*')
192191
=== added file 'test_scripts/tests/test_create_connection.py'
--- test_scripts/tests/test_create_connection.py 1970-01-01 00:00:00 +0000
+++ test_scripts/tests/test_create_connection.py 2013-04-20 11:15:31 +0000
@@ -0,0 +1,56 @@
1#
2# This file is part of Checkbox.
3#
4# Copyright 2013 Canonical Ltd.
5#
6# Checkbox is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# Checkbox is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
18#
19import imp
20import os
21import unittest
22
23imp.load_source('create_connection', os.path.join(os.path.dirname(__file__),
24 '..', '..', 'scripts', 'create_connection'))
25import create_connection
26
27class CreateConnectionTest(unittest.TestCase):
28
29 def test_wifi_connection_section(self):
30 ssid = 'checkbox'
31 uuid = '4567-a345-3235-90876'
32 expected_section = """
33[connection]
34id={id}
35uuid={uuid}
36type=802-11-wireless
37
38[802-11-wireless]
39ssid={id}
40mode=infrastructure""".format(id=ssid, uuid=uuid)
41 actual_section = create_connection.wifi_connection_section(ssid, uuid)
42 self.assertEqual(expected_section, actual_section)
43
44 def test_wifi_security_section(self):
45 security='wpa'
46 key='checkbox'
47 expected_section = """
48security=802-11-wireless-security
49
50[802-11-wireless-security]
51key-mgmt=wpa-psk
52auth-alg=open
53psk={key}
54""".format(key=key)
55 actual_section = create_connection.wifi_security_section(security, key)
56 self.assertEqual(expected_section, actual_section)

Subscribers

People subscribed via source and target branches