Beispiel #1
0
    def setUpClass(cls, *args, **kwargs):
        """
        Create the computers and setup a codes
        """
        super(TestVerdiCodeCommands, cls).setUpClass()

        # Setup computer #1
        from aiida.cmdline.commands.computer import Computer
        cmd_comp = Computer()
        with mock.patch('__builtin__.raw_input',
                        side_effect=computer_setup_input_1):
            with Capturing():
                cmd_comp.computer_setup()

        # Setup a code for computer #1
        from aiida.cmdline.commands.code import Code
        code_cmd = Code()
        with mock.patch('__builtin__.raw_input',
                        side_effect=code_setup_input_1):
            with Capturing():
                cls.code1 = code_cmd.code_setup()

        # Setup computer #2
        with mock.patch('__builtin__.raw_input',
                        side_effect=computer_setup_input_2):
            with Capturing():
                cmd_comp.computer_setup()

        # Setup a code for computer #2
        with mock.patch('__builtin__.raw_input',
                        side_effect=code_setup_input_2):
            with Capturing():
                cls.code2 = code_cmd.code_setup()
Beispiel #2
0
    def test_code_list(self):
        """
        Do some code listing test to ensure the correct behaviour of
        verdi code list
        """
        from aiida.cmdline.commands.code import Code
        code_cmd = Code()

        # Run a simple verdi code list, capture the output and check the result
        with Capturing() as output:
            code_cmd.code_list()
        out_str_1 = ''.join(output)
        self.assertTrue(
            computer_name_1 in out_str_1,
            "The computer 1 name should be included into "
            "this list")
        self.assertTrue(code_name_1 in out_str_1,
                        "The code 1 name should be included into this list")
        self.assertTrue(
            computer_name_2 in out_str_1,
            "The computer 2 name should be included into "
            "this list")
        self.assertTrue(code_name_2 in out_str_1,
                        "The code 2 name should be included into this list")

        # Run a verdi code list -a, capture the output and check if the result
        # is the same as the previous one
        with Capturing() as output:
            code_cmd.code_list(*['-a'])
        out_str_2 = ''.join(output)
        self.assertEqual(
            out_str_1, out_str_2,
            "verdi code list & verdi code list -a should provide "
            "the same output in this experiment.")

        # Run a verdi code list -c, capture the output and check the result
        with Capturing() as output:
            code_cmd.code_list(*['-c', computer_name_1])
        out_str = ''.join(output)
        self.assertTrue(
            computer_name_1 in out_str,
            "The computer 1 name should be included into "
            "this list")
        self.assertFalse(
            computer_name_2 in out_str,
            "The computer 2 name should not be included into "
            "this list")