Beispiel #1
0
 def test_empty_run(self):
     module = FakeModule()
     changed, output = nclu.run_nclu(module, None, None, False, False,
                                     False, "")
     self.assertEqual(module.command_history,
                      ['/usr/bin/net pending', '/usr/bin/net pending'])
     self.assertEqual(module.fail_code, {})
     self.assertEqual(changed, False)
Beispiel #2
0
    def test_commit_ignored(self):
        module = FakeModule()
        changed, output = nclu.run_nclu(module, None, None, True, False, False,
                                        "ignore me")

        self.assertEqual(module.command_history, [
            '/usr/bin/net pending', '/usr/bin/net pending',
            "/usr/bin/net commit description 'ignore me'", '/usr/bin/net abort'
        ])
        self.assertEqual(len(module.pending), 0)
        self.assertEqual(module.fail_code, {})
        self.assertEqual(changed, False)
Beispiel #3
0
    def test_command_list(self):
        module = FakeModule()
        changed, output = nclu.run_nclu(module,
                                        ['add int swp1', 'add int swp2'], None,
                                        False, False, False, "")

        self.assertEqual(module.command_history, [
            '/usr/bin/net pending', '/usr/bin/net add int swp1',
            '/usr/bin/net add int swp2', '/usr/bin/net pending'
        ])
        self.assertNotEqual(len(module.pending), 0)
        self.assertEqual(module.fail_code, {})
        self.assertEqual(changed, True)
Beispiel #4
0
    def test_command_template_commit(self):
        module = FakeModule()
        changed, output = nclu.run_nclu(module, None,
                                        "    add int swp1\n    add int swp2",
                                        True, False, False, "committed")

        self.assertEqual(module.command_history, [
            '/usr/bin/net pending', '/usr/bin/net add int swp1',
            '/usr/bin/net add int swp2', '/usr/bin/net pending',
            "/usr/bin/net commit description 'committed'",
            '/usr/bin/net show commit last'
        ])
        self.assertEqual(len(module.pending), 0)
        self.assertEqual(module.fail_code, {})
        self.assertEqual(changed, True)
Beispiel #5
0
    def test_command_atomic(self):
        module = FakeModule()
        changed, output = nclu.run_nclu(module,
                                        ['add int swp1', 'add int swp2'], None,
                                        False, True, False, "atomically")

        self.assertEqual(module.command_history, [
            '/usr/bin/net abort', '/usr/bin/net pending',
            '/usr/bin/net add int swp1', '/usr/bin/net add int swp2',
            '/usr/bin/net pending',
            "/usr/bin/net commit description 'atomically'",
            '/usr/bin/net show commit last'
        ])
        self.assertEqual(len(module.pending), 0)
        self.assertEqual(module.fail_code, {})
        self.assertEqual(changed, True)
Beispiel #6
0
    def test_command_abort_first(self):
        module = FakeModule()
        module.pending = "dirty"
        nclu.run_nclu(module, None, None, False, False, True, "")

        self.assertEqual(len(module.pending), 0)