Esempio n. 1
0
    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)
Esempio n. 3
0
    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))
Esempio n. 4
0
 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")
Esempio n. 5
0
 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")
Esempio n. 6
0
 def test_missing_dependency(self):
     dep = CommandDependency('lsxxxx')
     self.assertFalse(dep.is_available)
     self.assertRaises(CommandNotFoundError, dep.require)
Esempio n. 7
0
 def test_existing_dependency(self):
     dep = CommandDependency('ls')
     self.assertTrue(dep.is_available)
     dep.require()
Esempio n. 8
0
 def test_existing_dependency(self):
     dep = CommandDependency('ls')
     self.assertTrue(dep.is_available)
     dep.require()
Esempio n. 9
0
 def test_missing_dependency(self):
     dep = CommandDependency('lsxxxx')
     self.assertFalse(dep.is_available)