2022.6.10 - Dev dependencies #86

Merged
edraft merged 5 commits from 2022.6.10 into 2022.6 2022-06-27 20:18:25 +02:00
3 changed files with 62 additions and 5 deletions
Showing only changes of commit e9fdd20181 - Show all commits

View File

@ -64,6 +64,28 @@ class InstallTestCase(unittest.TestCase):
self.assertIn(package_name, packages) self.assertIn(package_name, packages)
self.assertEqual(version, packages[package_name]) 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): def _test_install_all(self):
version = '1.7.3' version = '1.7.3'
package_name = 'discord.py' package_name = 'discord.py'
@ -71,21 +93,33 @@ class InstallTestCase(unittest.TestCase):
settings = self._get_project_settings() settings = self._get_project_settings()
self.assertIn('ProjectSettings', settings) self.assertIn('ProjectSettings', settings)
self.assertIn('Dependencies', settings['ProjectSettings']) self.assertIn('Dependencies', settings['ProjectSettings'])
self.assertIn('DevDependencies', settings['ProjectSettings'])
self.assertNotIn(
package,
settings['ProjectSettings']['Dependencies']
)
self.assertIn('DevDependencies', settings['ProjectSettings'])
self.assertNotIn( self.assertNotIn(
package, package,
settings['ProjectSettings']['Dependencies'] settings['ProjectSettings']['Dependencies']
) )
settings['ProjectSettings']['Dependencies'].append(package) settings['ProjectSettings']['Dependencies'].append(package)
settings['ProjectSettings']['DevDependencies'].append(package)
self._save_project_settings(settings) self._save_project_settings(settings)
CLICommands.install() CLICommands.install()
new_settings = self._get_project_settings() new_settings = self._get_project_settings()
self.assertEqual(settings, new_settings) self.assertEqual(settings, new_settings)
self.assertIn('ProjectSettings', new_settings) self.assertIn('ProjectSettings', new_settings)
self.assertIn('Dependencies', new_settings['ProjectSettings']) self.assertIn('Dependencies', new_settings['ProjectSettings'])
self.assertIn('DevDependencies', new_settings['ProjectSettings'])
self.assertIn( self.assertIn(
package, package,
new_settings['ProjectSettings']['Dependencies'] new_settings['ProjectSettings']['Dependencies']
) )
self.assertIn(
package,
new_settings['ProjectSettings']['DevDependencies']
)
packages = self._get_installed_packages() packages = self._get_installed_packages()
self.assertIn(package_name, packages) self.assertIn(package_name, packages)
self.assertEqual(version, packages[package_name]) self.assertEqual(version, packages[package_name])

View File

@ -33,7 +33,6 @@ class UninstallTestCase(unittest.TestCase):
# create projects # create projects
CLICommands.new('console', self._source, '--ab', '--s') CLICommands.new('console', self._source, '--ab', '--s')
os.chdir(os.path.join(os.getcwd(), self._source)) os.chdir(os.path.join(os.getcwd(), self._source))
CLICommands.install(self._package)
def cleanUp(self): def cleanUp(self):
# remove projects # remove projects
@ -47,6 +46,7 @@ class UninstallTestCase(unittest.TestCase):
return dict([tuple(r.decode().split('==')) for r in reqs.split()]) return dict([tuple(r.decode().split('==')) for r in reqs.split()])
def test_uninstall(self): def test_uninstall(self):
CLICommands.install(self._package)
CLICommands.uninstall(self._package) CLICommands.uninstall(self._package)
settings = self._get_project_settings() settings = self._get_project_settings()
self.assertNotEqual(settings, {}) self.assertNotEqual(settings, {})
@ -56,5 +56,28 @@ class UninstallTestCase(unittest.TestCase):
self._package, self._package,
settings['ProjectSettings']['Dependencies'] 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() packages = self._get_installed_packages()
self.assertNotIn(self._package_name, packages) self.assertNotIn(self._package_name, packages)

View File

@ -44,12 +44,12 @@ class CLICommands:
cls._run('generate', schematic, name, output=output) cls._run('generate', schematic, name, output=output)
@classmethod @classmethod
def install(cls, package: str = None, output=False): def install(cls, package: str = None, is_dev=False, output=False):
if package is None: if package is None:
cls._run('install', output=output) cls._run('install', output=output)
return return
cls._run('install', package, output=output) cls._run('install', package, '--dev' if is_dev else '', output=output)
@classmethod @classmethod
def new(cls, project_type: str, name: str, *args, output=False): def new(cls, project_type: str, name: str, *args, output=False):
@ -75,8 +75,8 @@ class CLICommands:
cls._run('start', output=output) cls._run('start', output=output)
@classmethod @classmethod
def uninstall(cls, package: str, output=False): def uninstall(cls, package: str, is_dev=False, output=False):
cls._run('uninstall', package, output=output) cls._run('uninstall', package, '--dev' if is_dev else '', output=output)
@classmethod @classmethod
def update(cls, output=False): def update(cls, output=False):