def test_subprocess_called_with_correct_list(self, mock_sub):
        source = "test/source"
        list_cmd = "ssh " + dls_list_modules.vcs_git.GIT_ROOT + " expand controls"

        dls_list_modules.print_module_list(source)

        mock_sub.assert_called_once_with(list_cmd.split())
    def test_given_invalid_source_then_print_not_called(self, _1):
        source = "test/not_source"

        with patch.object(builtins, 'print') as mock_print:
            dls_list_modules.print_module_list(source)

        # Check that only called once (twice if source valid)
        self.assertFalse(mock_print.call_count)
    def test_given_valid_source_then_print_called(self, _1):
        source = "test/source"

        with patch.object(builtins, 'print') as mock_print:
            dls_list_modules.print_module_list(source)

        call_args = mock_print.call_args_list
        self.assertEqual(call_args[0][0][0], 'module')
        # Check that module2 from source2 is not printed
        self.assertEqual(len(call_args), 1)