Esempio n. 1
0
 def test_should_run_runall_and_skip_play_nice(self):
     q = cmd.QuibbleCmd()
     args = cmd.parse_arguments(args=['--run', 'all', '--skip', 'phpunit'])
     stages = q.stages_to_run(args.run, args.skip, args.commands)
     expected_stages = default_stages.copy()
     expected_stages.remove('phpunit')
     self.assertEqual(expected_stages, stages,
                      '--run=all respects --skip')
Esempio n. 2
0
def test_plan(expected, args, env):

    with mock.patch.dict('os.environ', env, clear=True):
        cmd_args = cmd.parse_arguments(args)
        plan = cmd.QuibbleCmd().build_execution_plan(cmd_args)

    printable_plan = [str(command) for command in plan]

    assert printable_plan == expected
Esempio n. 3
0
 def test_build_execution_plan_adds_ZUUL_PROJECT(self, _):
     env = {'ZUUL_PROJECT': 'mediawiki/extensions/ZuulProjectEnvVar'}
     with mock.patch.dict('os.environ', env, clear=True):
         q = cmd.QuibbleCmd()
         args = cmd.parse_arguments(
             args=['--packages-source=composer'])
         with mock.patch('quibble.commands.ZuulClone') as mock_clone:
             q.build_execution_plan(args)
     self.assertEqual(
         [
             'mediawiki/core',  # must be first
             'mediawiki/extensions/ZuulProjectEnvVar',
             'mediawiki/skins/Vector',
         ],
         mock_clone.call_args[1]['projects'])
Esempio n. 4
0
    def test_build_execution_plan_does_not_duplicate_hardcoded_repos(self, _):
        hardcoded_repos = [
            'mediawiki/core',
            'mediawiki/skins/Vector',
            ]

        for repo in hardcoded_repos:
            q = cmd.QuibbleCmd()
            args = cmd.parse_arguments(
                args=['--packages-source=composer'])
            with mock.patch.dict('os.environ', {'ZUUL_PROJECT': repo},
                                 clear=True):
                with mock.patch('quibble.commands.ZuulClone') \
                        as mock_clone:
                    q.build_execution_plan(args)
            self.assertEqual(
                [
                    'mediawiki/core',  # must be first
                    'mediawiki/skins/Vector',
                ],
                mock_clone.call_args[1]['projects'])
Esempio n. 5
0
    def test_build_execution_plan(self):
        args = cmd.parse_arguments(args=[])
        plan = cmd.QuibbleCmd().build_execution_plan(args)

        self.assertIsInstance(plan[0], quibble.commands.ReportVersions)
        self.assertIsInstance(plan[1], quibble.commands.EnsureDirectory)
Esempio n. 6
0
 def test_project_branch_arg(self):
     args = cmd.parse_arguments(args=[])
     self.assertEqual([], args.project_branch)
Esempio n. 7
0
 def test_command_used_multiple_times(self):
     args = cmd.parse_arguments(args=['-c', 'true', '-c', 'false'])
     self.assertEqual(['true', 'false'], args.commands)
Esempio n. 8
0
 def test_command_does_not_shallow_next_arg(self):
     args = cmd.parse_arguments(args=['--command', '/bin/true', 'repo'])
     self.assertEqual(['/bin/true'], args.commands)
     self.assertEqual(['repo'], args.projects)
Esempio n. 9
0
 def test_skip_option_does_not_shallow_next_arg(self):
     args = cmd.parse_arguments(args=['--skip', 'phpunit', 'repo'])
     self.assertEqual(['phpunit'], args.skip)
     self.assertEqual(['repo'], args.projects)
Esempio n. 10
0
    def test_args_defaults_in_docker(self, _):
        args = cmd.parse_arguments([])

        self.assertEqual('/srv/git', args.git_cache)
        self.assertEqual('/workspace', args.workspace)
Esempio n. 11
0
 def test_command_skip_all_stages(self):
     q = cmd.QuibbleCmd()
     args = cmd.parse_arguments(args=['-c', '/bin/true'])
     stages = q.stages_to_run(args.run, args.skip, args.commands)
     self.assertEqual([], stages,
                      'User command must skip all stages')
Esempio n. 12
0
 def test_should_run_running_a_single_stage(self):
     q = cmd.QuibbleCmd()
     args = cmd.parse_arguments(args=['--run', 'phpunit'])
     stages = q.stages_to_run(args.run, args.skip, args.commands)
     self.assertEqual(['phpunit'], stages,
                      '--run runs exactly the given stage')
Esempio n. 13
0
 def test_should_run_skips_a_stage(self):
     q = cmd.QuibbleCmd()
     args = cmd.parse_arguments(args=['--skip', 'phpunit'])
     stages = q.stages_to_run(args.run, args.skip, args.commands)
     self.assertEqual(['foo'], stages,
                      '--skip skips the stage')
Esempio n. 14
0
 def test_should_run_skippall_runs_no_stage(self):
     q = cmd.QuibbleCmd()
     args = cmd.parse_arguments(args=['--skip', 'all'])
     stages = q.stages_to_run(args.run, args.skip, args.commands)
     self.assertEqual([], stages,
                      '--skip=all skips all stages')
Esempio n. 15
0
 def test_should_run_runall_accepts_all_stages(self):
     q = cmd.QuibbleCmd()
     args = cmd.parse_arguments(args=['--run', 'all'])
     stages = q.stages_to_run(args.run, args.skip, args.commands)
     self.assertEqual(default_stages, stages,
                      '--run=all runs all stages')
Esempio n. 16
0
 def test_should_run_accepts_all_stages_by_default(self):
     q = cmd.QuibbleCmd()
     args = cmd.parse_arguments(args=[])
     stages = q.stages_to_run(args.run, args.skip, args.commands)
     self.assertEqual(default_stages, stages,
                      'must runs all stages by default')
Esempio n. 17
0
 def test_skip_option_is_comma_separated(self):
     args = cmd.parse_arguments(args=['--skip=phpunit,qunit'])
     self.assertEqual(['phpunit', 'qunit'], args.skip)
Esempio n. 18
0
    def test_args_defaults(self, _):
        args = cmd.parse_arguments([])

        self.assertEqual('ref', args.git_cache)
        self.assertEqual(os.getcwd(), args.workspace)
        self.assertEqual('log', args.log_dir)