Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
3ba1b20b
Commit
3ba1b20b
authored
May 12, 2016
by
Ben Patterson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12434 from edx/benp/require-firefox-42
Firefox version must meet a minimum
parents
4d08379b
62df58fa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
6 deletions
+56
-6
pavelib/paver_tests/test_utils.py
+43
-0
pavelib/utils/test/utils.py
+13
-6
No files found.
pavelib/paver_tests/test_utils.py
0 → 100644
View file @
3ba1b20b
"""
Tests for pavelib/utils/test/utils
"""
from
pavelib.utils.test.utils
import
check_firefox_version
,
MINIMUM_FIREFOX_VERSION
import
unittest
from
mock
import
patch
class
TestUtils
(
unittest
.
TestCase
):
"""
Test utils.py under pavelib/utils/test
"""
@patch
(
'subprocess.check_output'
)
def
test_firefox_version_ok
(
self
,
_mock_subprocesss
):
test_version
=
MINIMUM_FIREFOX_VERSION
_mock_subprocesss
.
return_value
=
"Mozilla Firefox {version}"
.
format
(
version
=
str
(
test_version
)
)
# No exception should be raised
check_firefox_version
()
@patch
(
'subprocess.check_output'
)
def
test_firefox_version_below_expected
(
self
,
_mock_subprocesss
):
test_version
=
MINIMUM_FIREFOX_VERSION
-
1
_mock_subprocesss
.
return_value
=
"Mozilla Firefox {version}"
.
format
(
version
=
test_version
)
with
self
.
assertRaises
(
Exception
):
check_firefox_version
()
@patch
(
'subprocess.check_output'
)
def
test_firefox_version_not_detected
(
self
,
_mock_subprocesss
):
_mock_subprocesss
.
return_value
=
"Mozilla Firefox"
with
self
.
assertRaises
(
Exception
):
check_firefox_version
()
@patch
(
'subprocess.check_output'
)
def
test_firefox_version_bad
(
self
,
_mock_subprocesss
):
_mock_subprocesss
.
return_value
=
"garbage"
with
self
.
assertRaises
(
Exception
):
check_firefox_version
()
pavelib/utils/test/utils.py
View file @
3ba1b20b
...
...
@@ -4,10 +4,12 @@ Helper functions for test tasks
from
paver.easy
import
sh
,
task
,
cmdopts
from
pavelib.utils.envs
import
Env
import
os
import
re
import
subprocess
MONGO_PORT_NUM
=
int
(
os
.
environ
.
get
(
'EDXAPP_TEST_MONGO_PORT'
,
'27017'
))
MONGO_HOST
=
os
.
environ
.
get
(
'EDXAPP_TEST_MONGO_HOST'
,
'localhost'
)
MINIMUM_FIREFOX_VERSION
=
28.0
__test__
=
False
# do not collect
...
...
@@ -69,20 +71,25 @@ def check_firefox_version():
"""
Check that firefox is the correct version.
"""
expected_firefox_ver
=
"Mozilla Firefox 28.0"
firefox_ver
=
subprocess
.
check_output
(
"firefox --version"
,
shell
=
True
)
.
strip
()
expected_firefox_ver
=
"Mozilla Firefox "
+
str
(
MINIMUM_FIREFOX_VERSION
)
firefox_ver_string
=
subprocess
.
check_output
(
"firefox --version"
,
shell
=
True
)
.
strip
()
firefox_version_regex
=
re
.
compile
(
r"Mozilla Firefox (\d+.\d+)"
)
try
:
firefox_ver
=
float
(
firefox_version_regex
.
search
(
firefox_ver_string
)
.
group
(
1
))
except
AttributeError
:
firefox_ver
=
0.0
debian_location
=
'https://s3.amazonaws.com/vagrant.testeng.edx.org/'
debian_package
=
'firefox
_28.0
%2
Bbuild2-0ubuntu0.12.04.
1_amd64.deb'
debian_package
=
'firefox
-mozilla-build_42.0-0ubuntu
1_amd64.deb'
debian_path
=
'{location}{package}'
.
format
(
location
=
debian_location
,
package
=
debian_package
)
if
firefox_ver
!=
expected_firefox_ver
:
if
firefox_ver
<
MINIMUM_FIREFOX_VERSION
:
raise
Exception
(
'Required firefox version not found.
\n
'
'Expected: {expected_version}; Actual: {actual_version}.
\n\n
'
'As the vagrant user in devstack, run the following:
\n\n
'
'
\t
$ sudo wget -O /tmp/firefox_
28
.deb {debian_path}
\n
'
'
\t
$ sudo wget -O /tmp/firefox_
42
.deb {debian_path}
\n
'
'
\t
$ sudo apt-get remove firefox
\n\n
'
'
\t
$ sudo gdebi -nq /tmp/firefox_
28
.deb
\n\n
'
'
\t
$ sudo gdebi -nq /tmp/firefox_
42
.deb
\n\n
'
'Confirm the new version:
\n
'
'
\t
$ firefox --version
\n
'
'
\t
{expected_version}'
.
format
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment