def install(packages=[]): """Install packages. """ installed = [] for package in packages: installed.append((package, install_package(package))) return installed
def install(packages=[]): """Install packages. """ installed = [] for package in packages: installed.append((package, install_package(package))) return installed
def test_install_already_installed(self): filenames, import_mock = self.create_fake_import(name=FAKE_NAME1) packages_count = FakePackage.select().count() with patch('procyon.pkg.logic.os.listdir', new=lambda ls: filenames): with patch('__builtin__.__import__', new=lambda *args: import_mock): status = install_package(FAKE_NAME1) self.assertEqual(status, InstallationStatuses.ALREADY_INSTALLED) self.assertEqual(FakePackage.select().count(), packages_count)
def test_install_already_installed(self): filenames, import_mock = self.create_fake_import(name=FAKE_NAME1) packages_count = FakePackage.select().count() with patch('procyon.pkg.logic.os.listdir', new=lambda ls: filenames): with patch('__builtin__.__import__', new=lambda *args: import_mock): status = install_package(FAKE_NAME1) self.assertEqual(status, InstallationStatuses.ALREADY_INSTALLED) self.assertEqual(FakePackage.select().count(), packages_count)
def test_install_error(self): p = FakePackage.get(name=FAKE_NAME1) p.delete_instance() filenames, import_mock = self.create_fake_import(name=FAKE_NAME1, install_status=InstallationStatuses.INSTALL_ERROR) packages_count = FakePackage.select().count() with patch('procyon.pkg.logic.os.listdir', new=lambda ls: filenames): with patch('__builtin__.__import__', new=lambda *args: import_mock): status = install_package(FAKE_NAME1) self.assertEqual(status, InstallationStatuses.INSTALL_ERROR) self.assertEqual(FakePackage.select().count(), packages_count)
def test_install_ok(self): p = FakePackage.get(name=FAKE_NAME1) p.delete_instance() filenames, import_mock = self.create_fake_import(name=FAKE_NAME1) packages_count = FakePackage.select().count() with patch('procyon.pkg.logic.os.listdir', new=lambda ls: filenames): with patch('__builtin__.__import__', new=lambda *args: import_mock): status = install_package(FAKE_NAME1) self.assertEqual(status, InstallationStatuses.INSTALL_OK) self.assertEqual(FakePackage.select().count(), packages_count + 1)