2022.6 #88
@ -64,6 +64,28 @@ class InstallTestCase(unittest.TestCase):
|
||||
self.assertIn(package_name, packages)
|
||||
self.assertEqual(version, packages[package_name])
|
||||
|
||||
def test_dev_install_package(self):
|
||||
version = '1.7.3'
|
||||
package_name = 'discord.py'
|
||||
package = f'{package_name}=={version}'
|
||||
CLICommands.install(package, is_dev=True)
|
||||
settings = self._get_project_settings()
|
||||
self.assertNotEqual(settings, {})
|
||||
self.assertIn('ProjectSettings', settings)
|
||||
self.assertIn('Dependencies', settings['ProjectSettings'])
|
||||
self.assertIn('DevDependencies', settings['ProjectSettings'])
|
||||
self.assertNotIn(
|
||||
package,
|
||||
settings['ProjectSettings']['Dependencies']
|
||||
)
|
||||
self.assertIn(
|
||||
package,
|
||||
settings['ProjectSettings']['DevDependencies']
|
||||
)
|
||||
packages = self._get_installed_packages()
|
||||
self.assertIn(package_name, packages)
|
||||
self.assertEqual(version, packages[package_name])
|
||||
|
||||
def _test_install_all(self):
|
||||
version = '1.7.3'
|
||||
package_name = 'discord.py'
|
||||
@ -71,21 +93,33 @@ class InstallTestCase(unittest.TestCase):
|
||||
settings = self._get_project_settings()
|
||||
self.assertIn('ProjectSettings', settings)
|
||||
self.assertIn('Dependencies', settings['ProjectSettings'])
|
||||
self.assertIn('DevDependencies', settings['ProjectSettings'])
|
||||
self.assertNotIn(
|
||||
package,
|
||||
settings['ProjectSettings']['Dependencies']
|
||||
)
|
||||
self.assertIn('DevDependencies', settings['ProjectSettings'])
|
||||
self.assertNotIn(
|
||||
package,
|
||||
settings['ProjectSettings']['Dependencies']
|
||||
)
|
||||
settings['ProjectSettings']['Dependencies'].append(package)
|
||||
settings['ProjectSettings']['DevDependencies'].append(package)
|
||||
self._save_project_settings(settings)
|
||||
CLICommands.install()
|
||||
new_settings = self._get_project_settings()
|
||||
self.assertEqual(settings, new_settings)
|
||||
self.assertIn('ProjectSettings', new_settings)
|
||||
self.assertIn('Dependencies', new_settings['ProjectSettings'])
|
||||
self.assertIn('DevDependencies', new_settings['ProjectSettings'])
|
||||
self.assertIn(
|
||||
package,
|
||||
new_settings['ProjectSettings']['Dependencies']
|
||||
)
|
||||
self.assertIn(
|
||||
package,
|
||||
new_settings['ProjectSettings']['DevDependencies']
|
||||
)
|
||||
packages = self._get_installed_packages()
|
||||
self.assertIn(package_name, packages)
|
||||
self.assertEqual(version, packages[package_name])
|
||||
|
@ -33,7 +33,6 @@ class UninstallTestCase(unittest.TestCase):
|
||||
# create projects
|
||||
CLICommands.new('console', self._source, '--ab', '--s')
|
||||
os.chdir(os.path.join(os.getcwd(), self._source))
|
||||
CLICommands.install(self._package)
|
||||
|
||||
def cleanUp(self):
|
||||
# remove projects
|
||||
@ -47,6 +46,7 @@ class UninstallTestCase(unittest.TestCase):
|
||||
return dict([tuple(r.decode().split('==')) for r in reqs.split()])
|
||||
|
||||
def test_uninstall(self):
|
||||
CLICommands.install(self._package)
|
||||
CLICommands.uninstall(self._package)
|
||||
settings = self._get_project_settings()
|
||||
self.assertNotEqual(settings, {})
|
||||
@ -56,5 +56,28 @@ class UninstallTestCase(unittest.TestCase):
|
||||
self._package,
|
||||
settings['ProjectSettings']['Dependencies']
|
||||
)
|
||||
self.assertNotIn(
|
||||
self._package,
|
||||
settings['ProjectSettings']['DevDependencies']
|
||||
)
|
||||
packages = self._get_installed_packages()
|
||||
self.assertNotIn(self._package_name, packages)
|
||||
|
||||
def test_dev_uninstall(self):
|
||||
CLICommands.install(self._package, is_dev=True)
|
||||
CLICommands.uninstall(self._package, is_dev=True)
|
||||
settings = self._get_project_settings()
|
||||
self.assertNotEqual(settings, {})
|
||||
self.assertIn('ProjectSettings', settings)
|
||||
self.assertIn('Dependencies', settings['ProjectSettings'])
|
||||
self.assertIn('DevDependencies', settings['ProjectSettings'])
|
||||
self.assertNotIn(
|
||||
self._package,
|
||||
settings['ProjectSettings']['Dependencies']
|
||||
)
|
||||
self.assertNotIn(
|
||||
self._package,
|
||||
settings['ProjectSettings']['DevDependencies']
|
||||
)
|
||||
packages = self._get_installed_packages()
|
||||
self.assertNotIn(self._package_name, packages)
|
||||
|
@ -44,12 +44,12 @@ class CLICommands:
|
||||
cls._run('generate', schematic, name, output=output)
|
||||
|
||||
@classmethod
|
||||
def install(cls, package: str = None, output=False):
|
||||
def install(cls, package: str = None, is_dev=False, output=False):
|
||||
if package is None:
|
||||
cls._run('install', output=output)
|
||||
return
|
||||
|
||||
cls._run('install', package, output=output)
|
||||
cls._run('install', package, '--dev' if is_dev else '', output=output)
|
||||
|
||||
@classmethod
|
||||
def new(cls, project_type: str, name: str, *args, output=False):
|
||||
@ -75,8 +75,8 @@ class CLICommands:
|
||||
cls._run('start', output=output)
|
||||
|
||||
@classmethod
|
||||
def uninstall(cls, package: str, output=False):
|
||||
cls._run('uninstall', package, output=output)
|
||||
def uninstall(cls, package: str, is_dev=False, output=False):
|
||||
cls._run('uninstall', package, '--dev' if is_dev else '', output=output)
|
||||
|
||||
@classmethod
|
||||
def update(cls, output=False):
|
||||
|
Loading…
Reference in New Issue
Block a user