def test_existing_dependency_decorator(self): dep = CommandDependency('ls') @require(dep) def test(x, y): return x + y self.assertEqual(test(1, 2), 3)
def test_dependency_status_message_package_why(self, util): util.command_exists.return_value = False dep = CommandDependency('ls', package="core-utils", why="listing files") self.assertFalse(dep.is_available) expected = "MISSING ls needed for listing files, part of the core-utils package" self.assertEqual(dep.printable_status.strip(), expected)
def test_missing_dependency_decorator(self): dep = CommandDependency('lsxxxx') @require(dep) def test(x, y): return x + y self.assertRaises(CommandNotFoundError, test) @require(dep, none_on_failure=True) def test2(x, y): return x + y self.assertEqual(None, test2(1, 2))
def test_dependency_status_message(self, util): util.command_exists.return_value = False dep = CommandDependency('ls') self.assertFalse(dep.is_available) self.assertEqual(dep.printable_status.strip(), "MISSING ls")
def test_mocked_dependency(self, util): util.command_exists.return_value = True dep = CommandDependency('lsxxxx') self.assertTrue(dep.is_available) self.assertEqual(dep.printable_status, "INSTALLED lsxxxx")
def test_missing_dependency(self): dep = CommandDependency('lsxxxx') self.assertFalse(dep.is_available) self.assertRaises(CommandNotFoundError, dep.require)
def test_existing_dependency(self): dep = CommandDependency('ls') self.assertTrue(dep.is_available) dep.require()
def test_existing_dependency(self): dep = CommandDependency('ls') self.assertTrue(dep.is_available) dep.require()
def test_missing_dependency(self): dep = CommandDependency('lsxxxx') self.assertFalse(dep.is_available)