def test_remove_custom(self):
     helper_remove = AddRemoveHelper(DEBUG_BUILD_CONFIG, 'remove')
     __search = helper_remove.search("ruby")
     # Test Remove
     helper_remove.run_commands(container=[__search], install=False)
     updated_state = read_state(DEBUG_BUILD_CONFIG)
     self.assertTrue("ruby" not in updated_state.installed)
示例#2
0
 def test_run_commands_invalid(self):
     helper_invalid = AddRemoveHelper(DEBUG_BUILD_CONFIG, '__remove')
     try:
         helper_invalid.run_commands(container=[
             (True, TMuxKeyword(DEBUG_BUILD_CONFIG))
         ],
                                     install=True)
     except AttributeError:
         pass
     else:
         self.assertTrue(False)
示例#3
0
    def test_search_fail(self):
        """
        Test the search function for installed custom keywords (the file should not be found)
        """

        helper = AddRemoveHelper(DEBUG_BUILD_CONFIG, 'searcher')
        resultant = helper.search('jareddyreson')
        self.assertTrue(isinstance(resultant, tuple))
        status, class_instance = resultant
        self.assertTrue(
            isinstance(status, bool) and (status == False)
            and isinstance(class_instance, type(None)))
示例#4
0
    def test_init_valid(self):
        """
        Test a valid constructor of AddRemoveHelper
        """

        try:
            _ = AddRemoveHelper(DEBUG_BUILD_CONFIG, 'add')
        except ValueError:
            self.assertTrue(False)
示例#5
0
    def test_search_success(self):
        """
        Test the search function for installed custom keywords (the file should be found)
        """

        payload = {
            "name": "osc",
            "instructor": "William McCarthy",
            "packages": ["cowsay", "vim"]
        }

        payload_path = pathlib.Path("/tmp/tuffix/json_payloads/osc.json")

        with open(payload_path, "w") as fp:
            json.dump(payload, fp)

        helper = AddRemoveHelper(DEBUG_BUILD_CONFIG, 'searcher')
        resultant = helper.search('osc')
        self.assertTrue(isinstance(resultant, tuple))
        status, class_instance = resultant
        self.assertTrue(
            isinstance(status, bool) and (status)
            and isinstance(class_instance, AbstractKeyword))
        payload_path.unlink()
示例#6
0
    def test_run_commands_remove(self):
        helper_remove = AddRemoveHelper(DEBUG_BUILD_CONFIG, 'remove')
        # Test Remove
        helper_remove.run_commands(container=[
            (True, TMuxKeyword(DEBUG_BUILD_CONFIG))
        ],
                                   install=False)
        updated_state = read_state(DEBUG_BUILD_CONFIG)
        self.assertTrue("tmux" not in updated_state.installed)

        try:
            helper_remove.run_commands(
                [(True, AllKeyword(DEBUG_BUILD_CONFIG))], install=False)
        except UsageError:
            pass
        else:
            self.assertTrue(False)
示例#7
0
    def test_run_commands_install(self):
        helper_add = AddRemoveHelper(DEBUG_BUILD_CONFIG, 'add')
        # Test install
        helper_add.run_commands(container=[(True,
                                            TMuxKeyword(DEBUG_BUILD_CONFIG))],
                                install=True)
        updated_state = read_state(DEBUG_BUILD_CONFIG)  # note the state
        self.assertTrue("tmux" in updated_state.installed)

        # Test reinstall
        try:
            helper_add.run_commands(container=[
                (True, TMuxKeyword(DEBUG_BUILD_CONFIG))
            ],
                                    install=True)
        except UsageError:
            pass
        else:
            self.assertTrue(False)
示例#8
0
    def test_rewrite_state_install(self):
        """
        Test if the program can update the state
        """

        original_state = read_state(DEBUG_BUILD_CONFIG)

        helper = AddRemoveHelper(DEBUG_BUILD_CONFIG, 'rewriter')
        example_keyword = TMuxKeyword(DEBUG_BUILD_CONFIG)

        helper.rewrite_state(keyword=example_keyword,
                             install=True)  # install the keyword

        updated_state = read_state(DEBUG_BUILD_CONFIG)  # note the state

        helper.rewrite_state(keyword=example_keyword,
                             install=False)  # remove the keyword

        reverted_state = read_state(DEBUG_BUILD_CONFIG)  # note the state again

        # check if the new state is equal to the snap shot
        self.assertTrue(original_state == reverted_state)
        """