Improved tests
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import time
|
||||
import unittest
|
||||
|
||||
from cpl_core.application import ApplicationABC
|
||||
|
@@ -5,7 +5,7 @@ import unittest
|
||||
|
||||
from unittests_cli.add_test_case import AddTestCase
|
||||
from unittests_cli.build_test_case import BuildTestCase
|
||||
from unittests_cli.constants import PLAYGROUND
|
||||
from unittests_cli.constants import PLAYGROUND_PATH
|
||||
from unittests_cli.generate_test_case import GenerateTestCase
|
||||
from unittests_cli.install_test_case import InstallTestCase
|
||||
from unittests_cli.new_test_case import NewTestCase
|
||||
@@ -45,19 +45,19 @@ class CLITestSuite(unittest.TestSuite):
|
||||
def _setup(self):
|
||||
print(f'Setup {__name__}')
|
||||
try:
|
||||
if os.path.exists(PLAYGROUND):
|
||||
shutil.rmtree(PLAYGROUND)
|
||||
if os.path.exists(PLAYGROUND_PATH):
|
||||
shutil.rmtree(PLAYGROUND_PATH)
|
||||
|
||||
os.mkdir(PLAYGROUND)
|
||||
os.chdir(PLAYGROUND)
|
||||
os.mkdir(PLAYGROUND_PATH)
|
||||
os.chdir(PLAYGROUND_PATH)
|
||||
except Exception as e:
|
||||
print(f'Setup of {__name__} failed: {traceback.format_exc()}')
|
||||
|
||||
def _cleanup(self):
|
||||
print(f'Cleanup {__name__}')
|
||||
try:
|
||||
if os.path.exists(PLAYGROUND):
|
||||
shutil.rmtree(PLAYGROUND)
|
||||
if os.path.exists(PLAYGROUND_PATH):
|
||||
shutil.rmtree(PLAYGROUND_PATH)
|
||||
except Exception as e:
|
||||
print(f'Cleanup of {__name__} failed: {traceback.format_exc()}')
|
||||
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
|
||||
PLAYGROUND = os.path.abspath(os.path.join(os.getcwd(), '../generated/test_cli_playground'))
|
||||
PLAYGROUND_PATH = os.path.abspath(os.path.join(os.getcwd(), '../generated/test_cli_playground'))
|
||||
CLI_PATH = os.path.abspath(os.path.join(os.getcwd(), '../../cpl_cli/main.py'))
|
||||
|
@@ -1,18 +1,15 @@
|
||||
import os.path
|
||||
import unittest
|
||||
|
||||
from unittests_cli.constants import PLAYGROUND
|
||||
from unittests_cli.constants import PLAYGROUND_PATH
|
||||
from unittests_shared.cli_commands import CLICommands
|
||||
|
||||
|
||||
class GenerateTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def _test_file(self, schematic: str, suffix: str):
|
||||
CLICommands.generate(schematic, 'GeneratedFile')
|
||||
file_path = os.path.abspath(os.path.join(PLAYGROUND, f'generated_file{suffix}.py'))
|
||||
file_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, f'generated_file{suffix}.py'))
|
||||
file_exists = os.path.exists(file_path)
|
||||
self.assertTrue(file_exists)
|
||||
os.remove(file_path)
|
||||
|
@@ -1,13 +1,15 @@
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from unittests_cli.constants import CLI_PATH
|
||||
|
||||
|
||||
class CLICommands:
|
||||
|
||||
@staticmethod
|
||||
def _run(cmd: str, *args):
|
||||
env_vars = os.environ
|
||||
command = ['python', os.path.abspath(os.path.join(os.getcwd(), '../../../cpl_cli/main.py')), cmd]
|
||||
command = ['python', CLI_PATH, cmd]
|
||||
for arg in args:
|
||||
command.append(arg)
|
||||
|
||||
|
Reference in New Issue
Block a user