2
0
mirror of https://github.com/frappe/bench.git synced 2024-11-12 00:06:36 +00:00

Merge pull request #992 from gavindsouza/tests-update

chore(tests): drop PY2 testing for frappe > v12
This commit is contained in:
gavin 2020-05-12 13:04:52 +05:30 committed by GitHub
commit c022d7be1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 8 deletions

View File

@ -11,6 +11,14 @@ import getpass
import bench import bench
import bench.utils import bench.utils
# imports - third party imports
from six import PY2
if PY2:
FRAPPE_BRANCH = "version-12"
else:
FRAPPE_BRANCH = "develop"
class TestBenchBase(unittest.TestCase): class TestBenchBase(unittest.TestCase):
def setUp(self): def setUp(self):
@ -76,7 +84,7 @@ class TestBenchBase(unittest.TestCase):
frappe_tmp_path = "/tmp/frappe" frappe_tmp_path = "/tmp/frappe"
if not os.path.exists(frappe_tmp_path): if not os.path.exists(frappe_tmp_path):
bench.utils.exec_cmd("git clone https://github.com/frappe/frappe --depth 1 --origin upstream {location}".format(location=frappe_tmp_path)) bench.utils.exec_cmd("git clone https://github.com/frappe/frappe -b {branch} --depth 1 --origin upstream {location}".format(branch=FRAPPE_BRANCH, location=frappe_tmp_path))
kwargs.update(dict( kwargs.update(dict(
python=sys.executable, python=sys.executable,

View File

@ -11,7 +11,7 @@ import git
import bench import bench
import bench.utils import bench.utils
from bench.release import get_bumped_version from bench.release import get_bumped_version
from bench.tests.test_base import TestBenchBase from bench.tests.test_base import TestBenchBase, FRAPPE_BRANCH
class TestBenchInit(TestBenchBase): class TestBenchInit(TestBenchBase):
@ -99,7 +99,7 @@ class TestBenchInit(TestBenchBase):
self.init_bench(bench_name) self.init_bench(bench_name)
bench.utils.exec_cmd("bench setup requirements --node", cwd=bench_path) bench.utils.exec_cmd("bench setup requirements --node", cwd=bench_path)
bench.utils.exec_cmd("bench build", cwd=bench_path) bench.utils.exec_cmd("bench build", cwd=bench_path)
bench.utils.exec_cmd("bench get-app erpnext", cwd=bench_path) bench.utils.exec_cmd("bench get-app erpnext --branch {0}".format(FRAPPE_BRANCH), cwd=bench_path)
self.assertTrue(os.path.exists(os.path.join(bench_path, "apps", "erpnext"))) self.assertTrue(os.path.exists(os.path.join(bench_path, "apps", "erpnext")))
@ -109,9 +109,11 @@ class TestBenchInit(TestBenchBase):
# create and install app on site # create and install app on site
self.new_site(site_name, bench_name) self.new_site(site_name, bench_name)
bench.utils.exec_cmd("bench --site {0} install-app erpnext".format(site_name), cwd=bench_path) installed_erpnext = not bench.utils.exec_cmd("bench --site {0} install-app erpnext".format(site_name), cwd=bench_path)
app_installed_on_site = subprocess.check_output(["bench", "--site", site_name, "list-apps"], cwd=bench_path).decode('utf8') app_installed_on_site = subprocess.check_output(["bench", "--site", site_name, "list-apps"], cwd=bench_path).decode('utf8')
if installed_erpnext:
self.assertTrue("erpnext" in app_installed_on_site) self.assertTrue("erpnext" in app_installed_on_site)
@ -134,11 +136,11 @@ class TestBenchInit(TestBenchBase):
bench_path = os.path.join(self.benches_path, "test-bench") bench_path = os.path.join(self.benches_path, "test-bench")
app_path = os.path.join(bench_path, "apps", "frappe") app_path = os.path.join(bench_path, "apps", "frappe")
bench.utils.exec_cmd("bench switch-to-branch version-12 frappe", cwd=bench_path) bench.utils.exec_cmd("bench switch-to-branch version-12 frappe --upgrade", cwd=bench_path)
app_branch_after_switch = str(git.Repo(path=app_path).active_branch) app_branch_after_switch = str(git.Repo(path=app_path).active_branch)
self.assertEqual("version-12", app_branch_after_switch) self.assertEqual("version-12", app_branch_after_switch)
bench.utils.exec_cmd("bench switch-to-branch develop frappe", cwd=bench_path) bench.utils.exec_cmd("bench switch-to-branch develop frappe --upgrade", cwd=bench_path)
app_branch_after_second_switch = str(git.Repo(path=app_path).active_branch) app_branch_after_second_switch = str(git.Repo(path=app_path).active_branch)
self.assertEqual("develop", app_branch_after_second_switch) self.assertEqual("develop", app_branch_after_second_switch)

View File

@ -298,7 +298,7 @@ def exec_cmd(cmd, cwd='.'):
import shlex import shlex
print("{0}$ {1}{2}".format(color.silver, cmd, color.nc)) print("{0}$ {1}{2}".format(color.silver, cmd, color.nc))
cmd = shlex.split(cmd) cmd = shlex.split(cmd)
subprocess.call(cmd, cwd=cwd, universal_newlines=True) return subprocess.call(cmd, cwd=cwd, universal_newlines=True)
def which(executable, raise_err = False): def which(executable, raise_err = False):