2022.6 #88
@ -1,10 +1,52 @@
|
|||||||
|
import json
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from cpl_core.utils import String
|
||||||
|
|
||||||
|
from unittests_cli.constants import PLAYGROUND_PATH
|
||||||
|
from unittests_shared.cli_commands import CLICommands
|
||||||
|
|
||||||
|
|
||||||
class AddTestCase(unittest.TestCase):
|
class AddTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def __init__(self, methodName: str):
|
||||||
pass
|
unittest.TestCase.__init__(self, methodName)
|
||||||
|
self._source = 'add-test-project'
|
||||||
|
self._target = 'add-test-library'
|
||||||
|
self._project_file = f'src/{String.convert_to_snake_case(self._source)}/{self._source}.json'
|
||||||
|
|
||||||
def test_equal(self):
|
def _get_project_settings(self):
|
||||||
pass
|
with open(os.path.join(os.getcwd(), self._project_file), 'r', encoding='utf-8') as cfg:
|
||||||
|
# load json
|
||||||
|
project_json = json.load(cfg)
|
||||||
|
cfg.close()
|
||||||
|
|
||||||
|
return project_json
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
os.chdir(os.path.abspath(PLAYGROUND_PATH))
|
||||||
|
# create projects
|
||||||
|
CLICommands.new('console', self._source, '--ab', '--s')
|
||||||
|
os.chdir(os.path.join(os.getcwd(), self._source))
|
||||||
|
CLICommands.new('console', self._target, '--ab', '--s')
|
||||||
|
|
||||||
|
def cleanUp(self):
|
||||||
|
# remove projects
|
||||||
|
if not os.path.exists(os.path.abspath(os.path.join(PLAYGROUND_PATH, self._source))):
|
||||||
|
return
|
||||||
|
|
||||||
|
shutil.rmtree(os.path.abspath(os.path.join(PLAYGROUND_PATH, self._source)))
|
||||||
|
|
||||||
|
def test_add(self):
|
||||||
|
CLICommands.add(self._source, self._target)
|
||||||
|
settings = self._get_project_settings()
|
||||||
|
self.assertNotEqual(settings, {})
|
||||||
|
self.assertIn('ProjectSettings', settings)
|
||||||
|
self.assertIn('ProjectReferences', settings['BuildSettings'])
|
||||||
|
self.assertIn('BuildSettings', settings)
|
||||||
|
self.assertIn(
|
||||||
|
f'../{String.convert_to_snake_case(self._target)}/{self._target}.json',
|
||||||
|
settings['BuildSettings']['ProjectReferences']
|
||||||
|
)
|
||||||
|
@ -5,6 +5,7 @@ import unittest
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
from unittest import TestResult
|
from unittest import TestResult
|
||||||
|
|
||||||
|
from unittests_cli.add_test_case import AddTestCase
|
||||||
from unittests_cli.constants import PLAYGROUND_PATH
|
from unittests_cli.constants import PLAYGROUND_PATH
|
||||||
from unittests_cli.generate_test_case import GenerateTestCase
|
from unittests_cli.generate_test_case import GenerateTestCase
|
||||||
from unittests_cli.new_test_case import NewTestCase
|
from unittests_cli.new_test_case import NewTestCase
|
||||||
@ -32,7 +33,7 @@ class CLITestSuite(unittest.TestSuite):
|
|||||||
# self.addTests(loader.loadTestsFromTestCase(UpdateTestCase))
|
# self.addTests(loader.loadTestsFromTestCase(UpdateTestCase))
|
||||||
|
|
||||||
# workspace needed
|
# workspace needed
|
||||||
# self.addTests(loader.loadTestsFromTestCase(AddTestCase))
|
self.addTests(loader.loadTestsFromTestCase(AddTestCase))
|
||||||
# self.addTests(loader.loadTestsFromTestCase(RemoveTestCase))
|
# self.addTests(loader.loadTestsFromTestCase(RemoveTestCase))
|
||||||
|
|
||||||
def _setup(self):
|
def _setup(self):
|
||||||
|
@ -17,6 +17,10 @@ class CLICommands:
|
|||||||
|
|
||||||
subprocess.run(command, env=env_vars)
|
subprocess.run(command, env=env_vars)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def add(cls, source: str, target: str):
|
||||||
|
cls._run('add', source, target)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def generate(cls, schematic: str, name: str, output=False):
|
def generate(cls, schematic: str, name: str, output=False):
|
||||||
cls._run('generate', schematic, name, output=output)
|
cls._run('generate', schematic, name, output=output)
|
||||||
|
Loading…
Reference in New Issue
Block a user