Example #1
0
    def test_absolute_args_no_box(self):
        """
        When invoked as `build-vagrant-box`, specifying a box is required.
        """
        path = FilePath(self.mktemp())
        path.createDirectory()
        base_path = path.descendant(['bin', 'build-vagrant-box'])

        options = BuildOptions(base_path=base_path, top_level=path)

        self.assertRaises(UsageError, options.parseOptions, [])
Example #2
0
    def test_relative_args_with_box(self):
        """
        When invoked as `build`, no box can be specified.
        """
        path = FilePath(self.mktemp())
        path.createDirectory()
        base_path = path.descendant(['somewhere', 'box-name', 'build'])

        options = BuildOptions(base_path=base_path, top_level=path)

        self.assertRaises(UsageError, options.parseOptions, ['--box', 'box'])
Example #3
0
    def test_absolute_args(self):
        """
        When invoked as `build-vagrant-box`, :class:`BuildOption` takes the
        path relative to the top-level, and the box name from the passed
        argument.
        """
        path = FilePath(self.mktemp())
        path.createDirectory()
        base_path = path.descendant(['bin', 'build-vagrant-box'])

        options = BuildOptions(base_path=base_path, top_level=path)

        options.parseOptions(['--box', 'box-name'])

        self.assertEqual(options, {
            'box': 'box-name',
            'path': path.descendant(['vagrant', 'box-name']),
            'build-server': 'http://build.clusterhq.com/',
            'branch': None,
            'flocker-version': flocker_version,
        })
Example #4
0
    def test_relative_args(self):
        """
        When invoked as `build`, no box can be specified. BuildOption takes the
        path from the parent of :file:`build`, and the box name from the name
        of
        that directory.
        """
        path = FilePath(self.mktemp())
        path.createDirectory()
        base_path = path.descendant(['somewhere', 'box-name', 'build'])

        options = BuildOptions(base_path=base_path, top_level=path)

        options.parseOptions([])

        self.assertEqual(options, {
            'box': 'box-name',
            'path': path.descendant(['somewhere', 'box-name']),
            'build-server': 'http://build.clusterhq.com/',
            'branch': None,
            'flocker-version': flocker_version,
        })
Example #5
0
    def test_absolute_args(self):
        """
        When invoked as `build-vagrant-box`, :class:`BuildOption` takes the
        path relative to the top-level, and the box name from the passed
        argument.
        """
        path = FilePath(self.mktemp())
        path.createDirectory()
        base_path = path.descendant(['bin', 'build-vagrant-box'])

        options = BuildOptions(base_path=base_path, top_level=path)

        options.parseOptions(['--box', 'box-name'])

        self.assertEqual(
            options, {
                'box': 'box-name',
                'path': path.descendant(['vagrant', 'box-name']),
                'build-server': 'http://build.clusterhq.com/',
                'branch': None,
                'flocker-version': flocker_version,
            })
Example #6
0
    def test_relative_args(self):
        """
        When invoked as `build`, no box can be specified. BuildOption takes the
        path from the parent of :file:`build`, and the box name from the name
        of
        that directory.
        """
        path = FilePath(self.mktemp())
        path.createDirectory()
        base_path = path.descendant(['somewhere', 'box-name', 'build'])

        options = BuildOptions(base_path=base_path, top_level=path)

        options.parseOptions([])

        self.assertEqual(
            options, {
                'box': 'box-name',
                'path': path.descendant(['somewhere', 'box-name']),
                'build-server': 'http://build.clusterhq.com/',
                'branch': None,
                'flocker-version': flocker_version,
            })