예제 #1
0
    def test_cli_export_snippet_020(snippy):
        """Export defined snippet with content data.

        Export defined snippet based on content data. File name is defined in
        command line as json 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.json'])  # pylint: disable=line-too-long
            assert cause == Cause.ALL_OK
            Content.assert_json(json, mock_file, 'defined-snippet.json',
                                content)
    def test_cli_export_snippet_008(snippy):
        """Export defined snippets.

        Export defined snippet based on message digest. File name is defined
        in command line as json 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.json'])
            assert cause == Cause.ALL_OK
            Content.assert_json(json, mock_file, 'defined-snippet.json', content)
    def test_cli_export_snippet_013(snippy):
        """Export defined snippets.

        Export defined snippet based on search keyword. File name is defined
        in command line as json 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.json'])
            assert cause == Cause.ALL_OK
            Content.assert_json(json, mock_file, 'defined-snippet.json', content)
    def test_cli_export_reference_006(snippy):
        """Export all references.

        Export defined reference based on message digest. File name is defined
        in command line as json 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.json'
            ])
            assert cause == Cause.ALL_OK
            Content.assert_json(json, mock_file, 'defined-reference.json',
                                content)
예제 #5
0
    def test_cli_export_solution_013(snippy):
        """Export defined solution with digest.

        Export defined solution based on message digest to json 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.json'
            ])
            assert cause == Cause.ALL_OK
            Content.assert_json(json, mock_file, './defined-solution.json',
                                content)
예제 #6
0
    def test_cli_export_solution_024(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 json format defined by the command line
        option.
        """

        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.json'
            ])
            assert cause == Cause.ALL_OK
            Content.assert_json(json, mock_file, './defined-solution.json',
                                content)
예제 #7
0
    def test_cli_export_solution_012(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 json.
        """

        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.json'
            ])
            assert cause == Cause.ALL_OK
            Content.assert_json(json, mock_file, './defined-solution.json',
                                content)
예제 #8
0
    def test_cli_export_solution_003(snippy):
        """Export all solutions.

        Export all solutions into defined json 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.json'
            ])
            assert cause == Cause.ALL_OK
            Content.assert_json(json, mock_file, './all-solutions.json',
                                content)