Merge lp:~canonical-platform-qa/snappy-ecosystem-tests/minor_tweaks into lp:snappy-ecosystem-tests

Proposed by Omer Akram
Status: Merged
Approved by: I Ahmad
Approved revision: 7
Merged at revision: 5
Proposed branch: lp:~canonical-platform-qa/snappy-ecosystem-tests/minor_tweaks
Merge into: lp:snappy-ecosystem-tests
Diff against target: 344 lines (+189/-46)
9 files modified
requirements.txt (+2/-0)
tests/__init__.py (+19/-0)
tests/helpers/__init__.py (+23/-11)
tests/helpers/ubuntu-store-tests-base.py (+19/-0)
tests/storeconfig.py (+29/-20)
tests/test-store-login.py (+33/-10)
tests/utils/__init__.py (+19/-0)
tests/utils/snapcraft.py (+26/-5)
tests/utils/snapd.py (+19/-0)
To merge this branch: bzr merge lp:~canonical-platform-qa/snappy-ecosystem-tests/minor_tweaks
Reviewer Review Type Date Requested Status
I Ahmad (community) Approve
Review via email: mp+316435@code.launchpad.net

Commit message

Minor tweaks. Add copyright headers, fix imports and some flake8 complaints

Description of the change

Minor tweaks. Add copyright headers, fix imports and some flake8 complaints

To post a comment you must log in.
Revision history for this message
I Ahmad (iahmad) wrote :

LGTM - except that either the get_store_credential should throw the exception or at least print the error message to warn the user that he/she haven't set the environment variables correctly. At the moment it become little difficult to find the the reason for test failing.

7. By Omer Akram

don't use environ.get() as that does not throw when a variable is not found

Revision history for this message
Omer Akram (om26er) wrote :

I have updated the code so that if the environment variable is not found it throws.

Revision history for this message
I Ahmad (iahmad) wrote :

LGTM - please merge

Revision history for this message
I Ahmad (iahmad) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'requirements.txt'
2--- requirements.txt 1970-01-01 00:00:00 +0000
3+++ requirements.txt 2017-02-07 11:35:58 +0000
4@@ -0,0 +1,2 @@
5+nose >= 1.3.7
6+xmlrunner >= 1.7.7
7
8=== added file 'tests/__init__.py'
9--- tests/__init__.py 1970-01-01 00:00:00 +0000
10+++ tests/__init__.py 2017-02-07 11:35:58 +0000
11@@ -0,0 +1,19 @@
12+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
13+
14+#
15+# Snappy Ecosystem Tests
16+# Copyright (C) 2017 Canonical
17+#
18+# This program is free software: you can redistribute it and/or modify
19+# it under the terms of the GNU General Public License as published by
20+# the Free Software Foundation, either version 3 of the License, or
21+# (at your option) any later version.
22+#
23+# This program is distributed in the hope that it will be useful,
24+# but WITHOUT ANY WARRANTY; without even the implied warranty of
25+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26+# GNU General Public License for more details.
27+#
28+# You should have received a copy of the GNU General Public License
29+# along with this program. If not, see <http://www.gnu.org/licenses/>.
30+#
31
32=== modified file 'tests/helpers/__init__.py'
33--- tests/helpers/__init__.py 2017-02-03 07:02:58 +0000
34+++ tests/helpers/__init__.py 2017-02-07 11:35:58 +0000
35@@ -1,11 +1,32 @@
36+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
37+
38+#
39+# Snappy Ecosystem Tests
40+# Copyright (C) 2017 Canonical
41+#
42+# This program is free software: you can redistribute it and/or modify
43+# it under the terms of the GNU General Public License as published by
44+# the Free Software Foundation, either version 3 of the License, or
45+# (at your option) any later version.
46+#
47+# This program is distributed in the hope that it will be useful,
48+# but WITHOUT ANY WARRANTY; without even the implied warranty of
49+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50+# GNU General Public License for more details.
51+#
52+# You should have received a copy of the GNU General Public License
53+# along with this program. If not, see <http://www.gnu.org/licenses/>.
54+#
55+
56 import unittest
57+
58 from selenium import webdriver
59-from selenium.webdriver.common.keys import Keys
60 from selenium.webdriver.support.ui import WebDriverWait
61 from selenium.webdriver.support import expected_conditions as EC
62 from selenium.common.exceptions import TimeoutException
63 from selenium.webdriver.common.by import By
64-import storeconfig
65+
66+from tests import storeconfig
67
68 LOGIN_EMAIL, LOGIN_PASSWORD = storeconfig.get_store_credentials()
69 STORE_URL = storeconfig.get_store_web_url()
70@@ -16,12 +37,7 @@
71
72 class UbuntuStoreWebTestsBase(unittest.TestCase):
73
74- @classmethod
75- def setUpClass(cls):
76- pass
77-
78 def setUp(self):
79- #
80 # TODO - add support for multiple type browsers including Chrome, FF and IE
81 options = webdriver.ChromeOptions()
82 options.add_argument("--start-maximized")
83@@ -122,7 +138,3 @@
84 def tearDown(self):
85 self.driver.close()
86 self.driver.quit()
87-
88- @classmethod
89- def tearDownClass(cls):
90- pass
91
92=== modified file 'tests/helpers/ubuntu-store-tests-base.py'
93--- tests/helpers/ubuntu-store-tests-base.py 2017-02-03 07:02:58 +0000
94+++ tests/helpers/ubuntu-store-tests-base.py 2017-02-07 11:35:58 +0000
95@@ -0,0 +1,19 @@
96+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
97+
98+#
99+# Snappy Ecosystem Tests
100+# Copyright (C) 2017 Canonical
101+#
102+# This program is free software: you can redistribute it and/or modify
103+# it under the terms of the GNU General Public License as published by
104+# the Free Software Foundation, either version 3 of the License, or
105+# (at your option) any later version.
106+#
107+# This program is distributed in the hope that it will be useful,
108+# but WITHOUT ANY WARRANTY; without even the implied warranty of
109+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
110+# GNU General Public License for more details.
111+#
112+# You should have received a copy of the GNU General Public License
113+# along with this program. If not, see <http://www.gnu.org/licenses/>.
114+#
115
116=== modified file 'tests/storeconfig.py'
117--- tests/storeconfig.py 2017-02-03 07:02:58 +0000
118+++ tests/storeconfig.py 2017-02-07 11:35:58 +0000
119@@ -1,35 +1,44 @@
120+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
121+
122+#
123+# Snappy Ecosystem Tests
124+# Copyright (C) 2017 Canonical
125+#
126+# This program is free software: you can redistribute it and/or modify
127+# it under the terms of the GNU General Public License as published by
128+# the Free Software Foundation, either version 3 of the License, or
129+# (at your option) any later version.
130+#
131+# This program is distributed in the hope that it will be useful,
132+# but WITHOUT ANY WARRANTY; without even the implied warranty of
133+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
134+# GNU General Public License for more details.
135+#
136+# You should have received a copy of the GNU General Public License
137+# along with this program. If not, see <http://www.gnu.org/licenses/>.
138+#
139+
140 import os
141
142+KEY_ENVIRON_STORE_LOGIN_EMAIL = 'UBUNTU_STORE_LOGIN_EMAIL'
143+KEY_ENVIRON_STORE_LOGIN_PASSWORD = 'UBUNTU_STORE_LOGIN_PASSWORD'
144+URL_WEB_STORE_PRODUCTION = 'https://myapps.developer.ubuntu.com/'
145+URL_WEB_STORE_STAGING = 'https://myapps.developer.staging.ubuntu.com/'
146+
147
148 def get_store_credentials():
149 """login credentials exported by shell environment"""
150- email=None
151- password=None
152-
153- try:
154- email=os.environ['UBUNTU_STORE_LOGIN_EMAIL']
155- password=os.environ['UBUNTU_STORE_LOGIN_PASSWORD']
156- except KeyError as err:
157- print (err.message)
158-
159- return email, password
160+ return os.environ['UBUNTU_STORE_LOGIN_EMAIL'], \
161+ os.environ['UBUNTU_STORE_LOGIN_PASSWORD']
162
163
164 def is_staging():
165 """Return False if environment variable PROD is exported"""
166- staging = True
167- try:
168- if os.environ["STAGING"] == "0":
169- staging = False
170- except KeyError:
171- pass
172-
173- return staging
174+ return os.environ.get('STAGING', "1") == "1"
175
176
177 def get_store_web_url():
178 """This will return Ubuntu Store web url from staging server,
179 if optional staging argument is false then it will return
180 production server url """
181- return "https://myapps.developer.staging.ubuntu.com/" if is_staging() \
182- else "https://myapps.developer.ubuntu.com/"
183\ No newline at end of file
184+ return URL_WEB_STORE_STAGING if is_staging() else URL_WEB_STORE_PRODUCTION
185
186=== modified file 'tests/test-store-login.py'
187--- tests/test-store-login.py 2017-02-03 07:02:58 +0000
188+++ tests/test-store-login.py 2017-02-07 11:35:58 +0000
189@@ -1,8 +1,30 @@
190+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
191+
192+#
193+# Snappy Ecosystem Tests
194+# Copyright (C) 2017 Canonical
195+#
196+# This program is free software: you can redistribute it and/or modify
197+# it under the terms of the GNU General Public License as published by
198+# the Free Software Foundation, either version 3 of the License, or
199+# (at your option) any later version.
200+#
201+# This program is distributed in the hope that it will be useful,
202+# but WITHOUT ANY WARRANTY; without even the implied warranty of
203+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
204+# GNU General Public License for more details.
205+#
206+# You should have received a copy of the GNU General Public License
207+# along with this program. If not, see <http://www.gnu.org/licenses/>.
208+#
209+
210 import unittest
211+
212 import xmlrunner
213
214-from helpers import UbuntuStoreWebTestsBase
215-from utils.snapcraft import Snapcraft
216+from tests.helpers import UbuntuStoreWebTestsBase
217+from tests.utils.snapcraft import Snapcraft
218+
219
220 class StoreLoginTests(UbuntuStoreWebTestsBase):
221
222@@ -10,7 +32,8 @@
223 super().setUp()
224
225 def test_login_logout(self):
226- """Test login and logout functionality of snapcraft, web interface and snapd"""
227+ """Test login and logout functionality of snapcraft, web interface
228+ and snapd."""
229 try:
230 sc = Snapcraft()
231 sc.login()
232@@ -20,16 +43,16 @@
233
234 self.login()
235 self.assertEqual(self.driver.title, "Your packages", "Failed to login")
236- self.logout() #TODO - fragile as there is no unique way to identify the dropdown arrow
237- self.assertEqual(self.driver.title, "Sign in to see your packages", "Failed to logout")
238-
239-
240- def tearDown(self):
241- super().tearDown()
242+ # TODO - fragile as there is no unique way to identify the dropdown arrow # NOQA
243+ self.logout()
244+ self.assertEqual(
245+ self.driver.title, "Sign in to see your packages",
246+ "Failed to logout")
247+
248
249 if __name__ == '__main__':
250 unittest.main(
251 testRunner=xmlrunner.XMLTestRunner(output='test-reports'),
252 # these make sure that some options that are not applicable
253 # remain hidden from the help menu.
254- failfast=False, buffer=False, catchbreak=False)
255\ No newline at end of file
256+ failfast=False, buffer=False, catchbreak=False)
257
258=== modified file 'tests/utils/__init__.py'
259--- tests/utils/__init__.py 2017-02-03 07:02:58 +0000
260+++ tests/utils/__init__.py 2017-02-07 11:35:58 +0000
261@@ -0,0 +1,19 @@
262+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
263+
264+#
265+# Snappy Ecosystem Tests
266+# Copyright (C) 2017 Canonical
267+#
268+# This program is free software: you can redistribute it and/or modify
269+# it under the terms of the GNU General Public License as published by
270+# the Free Software Foundation, either version 3 of the License, or
271+# (at your option) any later version.
272+#
273+# This program is distributed in the hope that it will be useful,
274+# but WITHOUT ANY WARRANTY; without even the implied warranty of
275+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
276+# GNU General Public License for more details.
277+#
278+# You should have received a copy of the GNU General Public License
279+# along with this program. If not, see <http://www.gnu.org/licenses/>.
280+#
281
282=== modified file 'tests/utils/snapcraft.py'
283--- tests/utils/snapcraft.py 2017-02-03 07:02:58 +0000
284+++ tests/utils/snapcraft.py 2017-02-07 11:35:58 +0000
285@@ -1,9 +1,30 @@
286+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
287+
288+#
289+# Snappy Ecosystem Tests
290+# Copyright (C) 2017 Canonical
291+#
292+# This program is free software: you can redistribute it and/or modify
293+# it under the terms of the GNU General Public License as published by
294+# the Free Software Foundation, either version 3 of the License, or
295+# (at your option) any later version.
296+#
297+# This program is distributed in the hope that it will be useful,
298+# but WITHOUT ANY WARRANTY; without even the implied warranty of
299+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
300+# GNU General Public License for more details.
301+#
302+# You should have received a copy of the GNU General Public License
303+# along with this program. If not, see <http://www.gnu.org/licenses/>.
304+#
305+
306+import os
307+
308 import pexpect
309-import sys
310-import os
311-import storeconfig
312-
313-#login credentials exported by shell environment
314+
315+from tests import storeconfig
316+
317+# login credentials exported by shell environment
318 LOGIN_EMAIL, LOGIN_PASSWORD = storeconfig.get_store_credentials()
319
320
321
322=== modified file 'tests/utils/snapd.py'
323--- tests/utils/snapd.py 2017-02-03 07:02:58 +0000
324+++ tests/utils/snapd.py 2017-02-07 11:35:58 +0000
325@@ -0,0 +1,19 @@
326+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
327+
328+#
329+# Snappy Ecosystem Tests
330+# Copyright (C) 2017 Canonical
331+#
332+# This program is free software: you can redistribute it and/or modify
333+# it under the terms of the GNU General Public License as published by
334+# the Free Software Foundation, either version 3 of the License, or
335+# (at your option) any later version.
336+#
337+# This program is distributed in the hope that it will be useful,
338+# but WITHOUT ANY WARRANTY; without even the implied warranty of
339+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
340+# GNU General Public License for more details.
341+#
342+# You should have received a copy of the GNU General Public License
343+# along with this program. If not, see <http://www.gnu.org/licenses/>.
344+#

Subscribers

People subscribed via source and target branches