def test_cli_export_reference_020(snippy):
        """Export defaults with ``scat`` option.

        Export snippet, solution and reference defaults with category
        set to ``all`` and so that the defauls will be updated. This must
        store the content from each category to own file that stores the
        default content.
        """

        content = {
            'meta': Content.get_cli_meta(),
            'data': [Snippet.REMOVE, Solution.BEATS, Reference.GITLOG]
        }
        with mock.patch('snippy.content.migrate.open',
                        mock.mock_open(),
                        create=True) as mock_file:
            cause = snippy.run(
                ['snippy', 'export', '--defaults', '--scat', 'all'])
            assert cause == Cause.ALL_OK
            defaults_snippets = pkg_resources.resource_filename(
                'snippy', 'data/defaults/snippets.yaml')
            defaults_solutions = pkg_resources.resource_filename(
                'snippy', 'data/defaults/solutions.yaml')
            defaults_references = pkg_resources.resource_filename(
                'snippy', 'data/defaults/references.yaml')
            Content.assert_yaml(
                yaml, mock_file,
                [defaults_snippets, defaults_solutions, defaults_references],
                content)
    def test_cli_export_reference_016(snippy):
        """Export defined reference with content data.

        Export defined reference based on content data. File name is defined in
        command line as yaml file.
        """

        content = {'meta': Content.get_cli_meta(), 'data': [Reference.GITLOG]}
        with mock.patch('snippy.content.migrate.open',
                        mock.mock_open(),
                        create=True) as mock_file:
            cause = snippy.run(['snippy', 'export', '-c', 'https://chris.beams.io/posts/git-commit/', '-f', 'defined-reference.yaml', '--scat', 'reference'])  # pylint: disable=line-too-long
            assert cause == Cause.ALL_OK
            Content.assert_yaml(yaml, mock_file, 'defined-reference.yaml',
                                content)
Пример #3
0
    def test_cli_export_snippet_019(snippy):
        """Export defined snippet with content data.

        Export defined snippet based on content data. File name is defined in
        command line as yaml file.
        """

        content = {'meta': Content.get_cli_meta(), 'data': [Snippet.REMOVE]}
        with mock.patch('snippy.content.migrate.open',
                        mock.mock_open(),
                        create=True) as mock_file:
            cause = snippy.run(['snippy', 'export', '-c', 'docker rm --volumes $(docker ps --all --quiet)', '-f', 'defined-snippet.yaml'])  # pylint: disable=line-too-long
            assert cause == Cause.ALL_OK
            Content.assert_yaml(yaml, mock_file, 'defined-snippet.yaml',
                                content)
    def test_cli_export_snippet_007(snippy):
        """Export defined snippets.

        Export defined snippet based on message digest. File name is defined
        in command line as yaml file.
        """

        content = {
            'meta': Content.get_cli_meta(),
            'data': [
                Snippet.FORCED
            ]
        }
        with mock.patch('snippy.content.migrate.open', mock.mock_open(), create=True) as mock_file:
            cause = snippy.run(['snippy', 'export', '-d', '53908d68425c61dc', '-f', 'defined-snippet.yaml'])
            assert cause == Cause.ALL_OK
            Content.assert_yaml(yaml, mock_file, 'defined-snippet.yaml', content)
    def test_cli_export_snippet_012(snippy):
        """Export defined snippets.

        Export defined snippet based on search keyword. File name is defined
        in command line as yaml file.
        """

        content = {
            'meta': Content.get_cli_meta(),
            'data': [
                Snippet.FORCED
            ]
        }
        with mock.patch('snippy.content.migrate.open', mock.mock_open(), create=True) as mock_file:
            cause = snippy.run(['snippy', 'export', '--sall', 'force', '-f', 'defined-snippet.yaml'])
            assert cause == Cause.ALL_OK
            Content.assert_yaml(yaml, mock_file, 'defined-snippet.yaml', content)
    def test_cli_export_snippet_003(snippy):
        """Export all snippets.

        Export all snippets into yaml file defined from command line.
        """

        content = {
            'meta': Content.get_cli_meta(),
            'data': [
                Snippet.REMOVE,
                Snippet.FORCED
            ]
        }
        with mock.patch('snippy.content.migrate.open', mock.mock_open(), create=True) as mock_file:
            cause = snippy.run(['snippy', 'export', '-f', './defined-snippets.yaml'])
            assert cause == Cause.ALL_OK
            Content.assert_yaml(yaml, mock_file, './defined-snippets.yaml', content)
    def test_cli_export_reference_025(snippy):
        """Exporting defaults while using search category.

        Export default content by selecting single category with the --scat
        option.
        """

        content = {'meta': Content.get_cli_meta(), 'data': [Reference.GITLOG]}
        with mock.patch('snippy.content.migrate.open',
                        mock.mock_open(),
                        create=True) as mock_file:
            cause = snippy.run(
                ['snippy', 'export', '--scat', 'reference', '--default'])
            assert cause == Cause.ALL_OK
            defaults_references = pkg_resources.resource_filename(
                'snippy', 'data/defaults/references.yaml')
            Content.assert_yaml(yaml, mock_file, defaults_references, content)
Пример #8
0
    def test_cli_export_solution_011(snippy):
        """Export defined solution with digest.

        Export defined solution based on message digest to yaml file without
        specifying the content category explicitly.
        """

        content = {'meta': Content.get_cli_meta(), 'data': [Solution.BEATS]}
        with mock.patch('snippy.content.migrate.open',
                        mock.mock_open(),
                        create=True) as mock_file:
            cause = snippy.run([
                'snippy', 'export', '-d', '4346ba4c79247430', '-f',
                './defined-solution.yml'
            ])
            assert cause == Cause.ALL_OK
            Content.assert_yaml(yaml, mock_file, './defined-solution.yml',
                                content)
    def test_cli_export_reference_005(snippy):
        """Export all references.

        Export defined reference based on message digest. File name is defined
        in command line as yaml file.
        """

        content = {'meta': Content.get_cli_meta(), 'data': [Reference.REGEXP]}
        with mock.patch('snippy.content.migrate.open',
                        mock.mock_open(),
                        create=True) as mock_file:
            cause = snippy.run([
                'snippy', 'export', '-d', 'cb9225a81eab8ced', '-f',
                'defined-reference.yml'
            ])
            assert cause == Cause.ALL_OK
            Content.assert_yaml(yaml, mock_file, 'defined-reference.yml',
                                content)
Пример #10
0
    def test_cli_export_snippet_024(snippy):
        """Export snippet defaults.

        Export snippet defaults. All snippets should be exported into
        predefined file location under tool data folder in yaml format.
        """

        content = {
            'meta': Content.get_cli_meta(),
            'data': [Snippet.REMOVE, Snippet.FORCED]
        }
        with mock.patch('snippy.content.migrate.open',
                        mock.mock_open(),
                        create=True) as mock_file:
            cause = snippy.run(['snippy', 'export', '--defaults'])
            assert cause == Cause.ALL_OK
            defaults_snippets = pkg_resources.resource_filename(
                'snippy', 'data/defaults/snippets.yaml')
            Content.assert_yaml(yaml, mock_file, defaults_snippets, content)
Пример #11
0
    def test_cli_export_solution_023(snippy):
        """Export solution with search keyword.

        Export defined solution based on search keyword. File name is defined
        in solution metadata and in command line -f|--file option. This should
        result the file name and yaml format defined by the command line
        option because the search result is a single content.
        """

        content = {'meta': Content.get_cli_meta(), 'data': [Solution.BEATS]}
        with mock.patch('snippy.content.migrate.open',
                        mock.mock_open(),
                        create=True) as mock_file:
            cause = snippy.run([
                'snippy', 'export', '--scat', 'solution', '--sall', 'beats',
                '-f', './defined-solution.yaml'
            ])
            assert cause == Cause.ALL_OK
            Content.assert_yaml(yaml, mock_file, './defined-solution.yaml',
                                content)
Пример #12
0
    def test_cli_export_solution_010(snippy):
        """Export defined solution with digest.

        Export defined solution based on message digest. File name is defined
        in solution metadata and in command line -f|--file option. This should
        result the file name and format defined by the command line option.
        In this case the created file format is yaml.
        """

        content = {'meta': Content.get_cli_meta(), 'data': [Solution.BEATS]}
        with mock.patch('snippy.content.migrate.open',
                        mock.mock_open(),
                        create=True) as mock_file:
            cause = snippy.run([
                'snippy', 'export', '--scat', 'solution', '-d',
                '4346ba4c79247430', '-f', './defined-solution.yaml'
            ])
            assert cause == Cause.ALL_OK
            Content.assert_yaml(yaml, mock_file, './defined-solution.yaml',
                                content)
Пример #13
0
    def test_cli_export_solution_029(snippy):
        """Export solution defaults.

        Export solution defaults. All solutions should be exported into
        predefined file location under tool data folder in yaml format.
        """

        content = {
            'meta': Content.get_cli_meta(),
            'data': [Solution.BEATS, Solution.NGINX]
        }
        with mock.patch('snippy.content.migrate.open',
                        mock.mock_open(),
                        create=True) as mock_file:
            cause = snippy.run(
                ['snippy', 'export', '--scat', 'solution', '--defaults'])
            assert cause == Cause.ALL_OK
            defaults_solutions = pkg_resources.resource_filename(
                'snippy', 'data/defaults/solutions.yaml')
            Content.assert_yaml(yaml, mock_file, defaults_solutions, content)
    def test_cli_export_reference_018(snippy):
        """Export reference defaults.

        Export reference defaults. All references should be exported into
        predefined file location under tool data folder in yaml format.
        """

        content = {
            'meta': Content.get_cli_meta(),
            'data': [Reference.GITLOG, Reference.REGEXP]
        }
        with mock.patch('snippy.content.migrate.open',
                        mock.mock_open(),
                        create=True) as mock_file:
            cause = snippy.run(
                ['snippy', 'export', '--defaults', '--scat', 'reference'])
            assert cause == Cause.ALL_OK
            defaults_references = pkg_resources.resource_filename(
                'snippy', 'data/defaults/references.yaml')
            Content.assert_yaml(yaml, mock_file, defaults_references, content)
Пример #15
0
    def test_cli_export_solution_002(snippy):
        """Export all solutions.

        Export all solutions into defined yaml file. File name and format are
        defined in command line.
        """

        content = {
            'meta': Content.get_cli_meta(),
            'data': [Solution.BEATS, Solution.NGINX]
        }
        with mock.patch('snippy.content.migrate.open',
                        mock.mock_open(),
                        create=True) as mock_file:
            cause = snippy.run([
                'snippy', 'export', '--scat', 'solution', '-f',
                './all-solutions.yaml'
            ])
            assert cause == Cause.ALL_OK
            Content.assert_yaml(yaml, mock_file, './all-solutions.yaml',
                                content)
    def test_cli_export_reference_002(snippy):
        """Export all references.

        Export all references into yaml formatted file as  defined in command
        line option. In this case the reference category is explicitly defined.
        """

        content = {
            'meta': Content.get_cli_meta(),
            'data': [Reference.GITLOG, Reference.REGEXP]
        }
        with mock.patch('snippy.content.migrate.open',
                        mock.mock_open(),
                        create=True) as mock_file:
            cause = snippy.run([
                'snippy', 'export', '-f', './defined-references.yaml',
                '--scat', 'reference'
            ])
            assert cause == Cause.ALL_OK
            Content.assert_yaml(yaml, mock_file, './defined-references.yaml',
                                content)
    def test_cli_export_reference_024(snippy):
        """Export content with search keyword.

        Export content from two category with search keyword. In this case
        -f|--file option is used and the content must be stored into a file
        defined by user.
        """

        content = {
            'meta': Content.get_cli_meta(),
            'data': [Reference.GITLOG, Snippet.REMOVE]
        }
        with mock.patch('snippy.content.migrate.open',
                        mock.mock_open(),
                        create=True) as mock_file:
            cause = snippy.run([
                'snippy', 'export', '--scat', 'reference,snippet', '--sall',
                'volumes,git', '-f', 'defined-content.yaml'
            ])
            assert cause == Cause.ALL_OK
            Content.assert_yaml(yaml, mock_file, 'defined-content.yaml',
                                content)