Commit 7b36645e by Christine Lytwynec

Merge pull request #6024 from edx/clytwynec/fix_no_prereq_install

fix NO_PREREQ_INSTALL
parents 73dd6fe2 e9e59574
import os
import unittest
from pavelib.prereqs import no_prereq_install
class TestPaverPrereqInstall(unittest.TestCase):
def check_val(self, set_val, expected_val):
_orig_environ = dict(os.environ)
os.environ['NO_PREREQ_INSTALL'] = set_val
self.assertEqual(
no_prereq_install(),
expected_val,
'NO_PREREQ_INSTALL is set to {}, but we read it as {}'.format(
set_val, expected_val),
)
# Reset Environment back to original state
os.environ.clear()
os.environ.update(_orig_environ)
def test_no_prereq_install_true(self):
self.check_val('true', True)
def test_no_prereq_install_false(self):
self.check_val('false', False)
def test_no_prereq_install_True(self):
self.check_val('True', True)
def test_no_prereq_install_False(self):
self.check_val('False', False)
def test_no_prereq_install_0(self):
self.check_val('0', False)
def test_no_prereq_install_1(self):
self.check_val('1', True)
......@@ -26,6 +26,25 @@ if os.path.exists(PRIVATE_REQS):
PYTHON_REQ_FILES.append(PRIVATE_REQS)
def no_prereq_install():
"""
Determine if NO_PREREQ_INSTALL should be truthy or falsy.
"""
vals = {
'0': False,
'1': True,
'true': True,
'false': False,
}
val = os.environ.get("NO_PREREQ_INSTALL", 'False').lower()
try:
return vals[val]
except:
return False
def compute_fingerprint(path_list):
"""
Hash the contents of all the files and directories in `path_list`.
......@@ -123,7 +142,7 @@ def install_ruby_prereqs():
"""
Installs Ruby prereqs
"""
if os.environ.get("NO_PREREQ_INSTALL", False):
if no_prereq_install():
return
prereq_cache("Ruby prereqs", ["Gemfile"], ruby_prereqs_installation)
......@@ -134,7 +153,7 @@ def install_node_prereqs():
"""
Installs Node prerequisites
"""
if os.environ.get("NO_PREREQ_INSTALL", False):
if no_prereq_install():
return
prereq_cache("Node prereqs", ["package.json"], node_prereqs_installation)
......@@ -145,7 +164,7 @@ def install_python_prereqs():
"""
Installs Python prerequisites
"""
if os.environ.get("NO_PREREQ_INSTALL", False):
if no_prereq_install():
return
prereq_cache("Python prereqs", PYTHON_REQ_FILES + [sysconfig.get_python_lib()], python_prereqs_installation)
......@@ -156,7 +175,7 @@ def install_prereqs():
"""
Installs Ruby, Node and Python prerequisites
"""
if os.environ.get("NO_PREREQ_INSTALL", False):
if no_prereq_install():
return
install_ruby_prereqs()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment