test: fix remaining paver tests

They haven't been run in CI in years, and had gradually become broken
This commit is contained in:
Kyle D. McCormick
2024-05-21 11:10:18 -04:00
committed by Kyle McCormick
parent c4a1f800e9
commit e64becbdf0
8 changed files with 13 additions and 61 deletions

View File

@@ -7,12 +7,11 @@ import os
import re
import sys
from paver.easy import cmdopts, needs, task
from paver.easy import cmdopts, needs, sh, task
from pavelib.utils.envs import Env
from pavelib.utils.test.suites import JestSnapshotTestSuite, JsTestSuite
from pavelib.utils.timer import timed
from paver.easy import cmdopts, needs, sh, task
try:
from pygments.console import colorize

View File

@@ -110,7 +110,7 @@ class TestDeprecatedPaverAssets(TestCase):
"NODE_ENV=production " +
"STATIC_ROOT_LMS=/fake/lms/staticfiles " +
"STATIC_ROOT_CMS=/fake/cms/staticfiles " +
'JS_ENV_EXTRA_CONFIG=' + +
'JS_ENV_EXTRA_CONFIG=' +
'"{\\"key1\\": [true, false], \\"key2\\": {\\"key2.1\\": 1369, \\"key2.2\\": \\"1369\\"}}" ' +
"npm run webpack"
),

View File

@@ -18,7 +18,6 @@ class TestPaverJavaScriptTestTasks(PaverTestCase):
"""
EXPECTED_DELETE_JAVASCRIPT_REPORT_COMMAND = 'find {platform_root}/reports/javascript -type f -delete'
EXPECTED_INSTALL_NPM_ASSETS_COMMAND = 'install npm_assets'
EXPECTED_KARMA_OPTIONS = (
"{config_file} "
"--single-run={single_run} "
@@ -116,7 +115,6 @@ class TestPaverJavaScriptTestTasks(PaverTestCase):
expected_messages.append(self.EXPECTED_DELETE_JAVASCRIPT_REPORT_COMMAND.format(
platform_root=self.platform_root
))
expected_messages.append(self.EXPECTED_INSTALL_NPM_ASSETS_COMMAND)
command_template = (
'node --max_old_space_size=4096 node_modules/.bin/karma start {options}'

View File

@@ -7,7 +7,6 @@ import tempfile
import unittest
from unittest.mock import patch
import pytest
from path import Path as path
from paver.easy import call_task, BuildFailure
@@ -62,9 +61,15 @@ class TestPaverPIICheck(unittest.TestCase):
])
mock_needs.return_value = 0
with pytest.raises(SystemExit):
call_task('pavelib.quality.run_pii_check', options={"report_dir": str(self.report_dir)})
self.assertRaises(BuildFailure)
try:
with self.assertRaises(BuildFailure):
call_task('pavelib.quality.run_pii_check', options={"report_dir": str(self.report_dir)})
except SystemExit:
# Sometimes the BuildFailure raises a SystemExit, sometimes it doesn't, not sure why.
# As a hack, we just wrap it in try-except.
# This is not good, but these tests weren't even running for years, and we're removing this whole test
# suite soon anyway.
pass
mock_calls = [str(call) for call in mock_paver_sh.mock_calls]
assert len(mock_calls) == 2
assert any('lms.envs.test' in call for call in mock_calls)

View File

@@ -1,48 +0,0 @@
"""
Tests for pavelib/utils/test/utils
"""
import unittest
from unittest.mock import patch
import pytest
from pavelib.utils.envs import Env
from pavelib.utils.test.utils import MINIMUM_FIREFOX_VERSION, check_firefox_version
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 pytest.raises(Exception):
check_firefox_version()
@patch('subprocess.check_output')
def test_firefox_version_not_detected(self, _mock_subprocesss):
_mock_subprocesss.return_value = "Mozilla Firefox"
with pytest.raises(Exception):
check_firefox_version()
@patch('subprocess.check_output')
def test_firefox_version_bad(self, _mock_subprocesss):
_mock_subprocesss.return_value = "garbage"
with pytest.raises(Exception):
check_firefox_version()

View File

@@ -8,7 +8,7 @@ import os
import re
import subprocess
import sys
from distutils import sysconfig
from distutils import sysconfig # pylint: disable=deprecated-module
from paver.easy import sh, task # lint-amnesty, pylint: disable=unused-import
@@ -169,7 +169,7 @@ def python_prereqs_installation():
Installs Python prerequisites
"""
# edx-platform installs some Python projects from within the edx-platform repo itself.
sh(f"pip install -e .")
sh("pip install -e .")
for req_file in PYTHON_REQ_FILES:
pip_install_req_file(req_file)

View File

@@ -7,7 +7,6 @@ import os
import sys
from time import sleep
import memcache
from lazy import lazy
from path import Path as path
from paver.easy import BuildFailure, sh

View File

@@ -5,7 +5,6 @@ Javascript test tasks
from paver import tasks
from pavelib import assets
from pavelib.utils.envs import Env
from pavelib.utils.test import utils as test_utils
from pavelib.utils.test.suites.suite import TestSuite