From c71432de3ce569d5646dfffcaa213e7fe7f6d854 Mon Sep 17 00:00:00 2001 From: saxenabhishek Date: Thu, 10 Mar 2022 23:09:53 +0530 Subject: [PATCH] test: update remove file creation check --- bench/tests/test_utils.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/bench/tests/test_utils.py b/bench/tests/test_utils.py index da52a0cf..69e959f5 100644 --- a/bench/tests/test_utils.py +++ b/bench/tests/test_utils.py @@ -1,11 +1,14 @@ import os import shutil +import subprocess import unittest +from tabnanny import check from bench.app import App from bench.bench import Bench -from bench.utils import is_valid_frappe_branch from bench.exceptions import InvalidRemoteException +from bench.utils import is_valid_frappe_branch + class TestUtils(unittest.TestCase): def test_app_utils(self): @@ -42,23 +45,27 @@ class TestUtils(unittest.TestCase): fake_bench = Bench(bench_dir) - fake_bench.apps.set_states() - self.assertTrue(hasattr(fake_bench.apps, "states")) - self.assertTrue(os.path.exists(os.path.join(sites_dir, "apps_states.json"))) - fake_bench.apps.states = {"frappe": {"resolution": None, "version": "14.0.0-dev"}} + fake_bench.apps.states = { + "frappe": {"resolution": {"branch": "develop", "commit_hash": "234rwefd"}, "version": "14.0.0-dev"} + } fake_bench.apps.update_apps_states() self.assertEqual(fake_bench.apps.states, {}) - frappe_path = os.path.join(bench_dir, "apps", "frappe", "frappe") + frappe_path = os.path.join(bench_dir, "apps", "frappe") - os.makedirs(frappe_path) + os.makedirs(os.path.join(frappe_path, "frappe")) - with open(os.path.join(frappe_path, "__init__.py"), "w+") as f: + subprocess.run(["git", "init"], cwd=frappe_path, capture_output=True, check=True) + + with open(os.path.join(frappe_path, "frappe", "__init__.py"), "w+") as f: f.write("__version__ = '11.0'") + subprocess.run(["git", "add", "."], cwd=frappe_path, capture_output=True, check=True) + subprocess.run(["git", "commit", "-m", "temp"], cwd=frappe_path, capture_output=True, check=True) + fake_bench.apps.update_apps_states("frappe") self.assertIn("frappe", fake_bench.apps.states)