Ejemplo n.º 1
0
    def test_cli_update_reference_015(snippy, edited_gitlog):
        """Update reference with editor.

        Update existing Mkdn formatted reference first in text format, then
        in Text format and then again in Markdown format without making any
        changes. The content must not change when updated between different
        formats.

        Each update must generate different timestamp in content ``updated``
        attribute. Also the last update must produce the same resource as
        the first update.

        The content in editor is explicitly defined in the test to avoid
        false positives from the test helpers that actually use the code
        itself.
        """

        content = {'data': [Content.deepcopy(Reference.GITLOG)]}
        content['data'][0]['tags'] = ('commit', )
        content['data'][0][
            'digest'] = '2dcb254063ccb5bbc27796df96033f89dae33dde53dbc038d4532e1a798c97c0'
        template = Content.dump_mkdn(content['data'][0])
        edited_gitlog.return_value = template
        cause = snippy.run([
            'snippy', 'update', '-d', '5c2071094dbfaa33', '--editor',
            '--format', 'mkdn', '--tags', 'commit'
        ])
        edited_gitlog.assert_called_with(template)
        assert cause == Cause.ALL_OK
        Content.assert_storage(content)

        content['data'][0]['tags'] = ('git', )
        content['data'][0][
            'digest'] = 'b2228e2cc6e3d7fe01257f615175a1f33e617b0cfba55199a93e7e48dcdbecf1'
        template = Content.dump_text(content['data'][0])
        edited_gitlog.return_value = template
        content['data'][0]['updated'] = '2018-07-22T13:11:13.678729+00:00'
        cause = snippy.run([
            'snippy', 'update', '-d', '2dcb254063ccb5bbc', '--editor',
            '--format', 'text', '--tags', 'git'
        ])
        edited_gitlog.assert_called_with(template)
        assert cause == Cause.ALL_OK
        Content.assert_storage(content)

        content['data'][0]['tags'] = ('commit', )
        content['data'][0][
            'digest'] = '2dcb254063ccb5bbc27796df96033f89dae33dde53dbc038d4532e1a798c97c0'
        template = Content.dump_mkdn(content['data'][0])
        edited_gitlog.return_value = template
        content['data'][0]['updated'] = '2018-08-22T13:11:13.678729+00:00'
        cause = snippy.run([
            'snippy', 'update', '-d', 'b2228e2cc6e3d7fe', '--editor',
            '--format', 'mkdn', '--tags', 'commit'
        ])
        edited_gitlog.assert_called_with(template)
        assert cause == Cause.ALL_OK
        Content.assert_storage(content)
Ejemplo n.º 2
0
    def test_cli_update_solution_016(snippy, editor_data):
        """Update Markdown native solution with editor.

        Update existing text formatted solution first in text format, then
        in Markdown format and then again in text format without making any
        changes. The content must not change when updated between different
        formats.

        Each update must generate different timestamp in content ``updated``
        attribute.
        """

        content = {'data': [Content.deepcopy(Solution.KAFKA_MKDN)]}
        content['data'][0]['brief'] = 'Testing docker log drivers again'
        content['data'][0][
            'digest'] = 'b5e5242d971f561675558981b4f25d1e822db282145c4246e3bd50111146096c'
        template = Content.dump_text(content['data'][0])
        editor_data.return_value = template
        content['data'][0]['updated'] = '2017-10-20T06:16:27.000001+00:00'
        cause = snippy.run([
            'snippy', 'update', '-d', 'c54c8a896b94ea35e', '--format', 'text',
            '--brief', 'Testing docker log drivers again'
        ])
        editor_data.assert_called_with(template)
        assert cause == Cause.ALL_OK
        Content.assert_storage(content)

        content['data'][0][
            'brief'] = 'Testing docker log drivers again in mkdn'
        content['data'][0][
            'digest'] = '243e51c8b99c80fb73c30b8d72618f8c3bc094df04184da8209f147138067083'
        template = Content.dump_mkdn(content['data'][0])
        editor_data.return_value = template
        content['data'][0]['updated'] = '2017-11-20T06:16:27.000001+00:00'
        cause = snippy.run(['snippy', 'update', '-d', 'b5e5242d971f5616', '--format', 'mkdn', '--brief', 'Testing docker log drivers again in mkdn'])  # pylint: disable=line-too-long
        editor_data.assert_called_with(template)
        assert cause == Cause.ALL_OK
        Content.assert_storage(content)

        content['data'][0]['brief'] = 'Testing docker log drivers again'
        content['data'][0][
            'digest'] = 'b5e5242d971f561675558981b4f25d1e822db282145c4246e3bd50111146096c'
        template = Content.dump_text(content['data'][0])
        editor_data.return_value = template
        content['data'][0]['updated'] = '2017-12-20T06:16:27.000001+00:00'
        cause = snippy.run([
            'snippy', 'update', '-d', '243e51c8b99c80fb', '--format', 'text',
            '--brief', 'Testing docker log drivers again'
        ])
        editor_data.assert_called_with(template)
        assert cause == Cause.ALL_OK
        Content.assert_storage(content)
Ejemplo n.º 3
0
    def test_cli_update_solution_015(snippy, editor_data):
        """Update text native solution with editor.

        Update existing text formatted solution first in text format, then
        in Markdown format and then again in text format without making any
        changes. The content must not change when updated between different
        formats.

        Each update must generate different timestamp in content ``updated``
        attribute.
        """

        content = {'data': [Content.deepcopy(Solution.KAFKA)]}
        content['data'][0]['brief'] = 'Testing docker log drivers again'
        content['data'][0][
            'digest'] = '1072f9a0ddb2ab15a7f6cca0acd9f7e48903faa576fb19eca4e0ec98dc20c041'
        template = Content.dump_text(content['data'][0])
        editor_data.return_value = template
        cause = snippy.run([
            'snippy', 'update', '-d', 'ee3f2ab7c63d6965', '--format', 'text',
            '--brief', 'Testing docker log drivers again'
        ])
        editor_data.assert_called_with(template)
        assert cause == Cause.ALL_OK
        Content.assert_storage(content)

        content['data'][0][
            'brief'] = 'Testing docker log drivers again in mkdn'
        content['data'][0][
            'digest'] = '2887f455e73ad3a6040df7299e69548748db5eb208b9c7eb4717aa2527af4778'
        template = Content.dump_mkdn(content['data'][0])
        editor_data.return_value = template
        content['data'][0]['updated'] = '2017-11-20T06:16:27.000001+00:00'
        cause = snippy.run(['snippy', 'update', '-d', '1072f9a0ddb2ab15', '--format', 'mkdn', '--brief', 'Testing docker log drivers again in mkdn'])  # pylint: disable=line-too-long
        editor_data.assert_called_with(template)
        assert cause == Cause.ALL_OK
        Content.assert_storage(content)

        content['data'][0]['brief'] = 'Testing docker log drivers again'
        content['data'][0][
            'digest'] = '1072f9a0ddb2ab15a7f6cca0acd9f7e48903faa576fb19eca4e0ec98dc20c041'
        template = Content.dump_text(content['data'][0])
        editor_data.return_value = template
        content['data'][0]['updated'] = '2017-12-20T06:16:27.000001+00:00'
        cause = snippy.run([
            'snippy', 'update', '-d', '2887f455e73ad3a6', '--format', 'text',
            '--brief', 'Testing docker log drivers again'
        ])
        editor_data.assert_called_with(template)
        assert cause == Cause.ALL_OK
        Content.assert_storage(content)
Ejemplo n.º 4
0
    def test_cli_update_solution_012(snippy, editor_data):
        """Update solution with editor.

        Update existing Markdown native solution. Editor must show existing
        Markdown native content as is. Updated content must be identified as
        Markdown native content. Editor must be used by default when the
        ``--editor`` option is not used.

        In this case the links must be empty when stored. The edited content
        did not have any links in the content data so they must be updated
        to stored content.
        """

        content = {'data': [Content.deepcopy(Solution.KAFKA_MKDN)]}
        edited = (
            '# Testing docker log drivers @docker', '',
            '> Investigate docker log drivers and the logs2kafka log plugin',
            '', '> [1] https://github.com/MickayG/moby-kafka-logdriver  ',
            '[2] https://github.com/garo/logs2kafka  ',
            '[3] https://groups.google.com/forum/#!topic/kubernetes-users/iLDsG85exRQ',
            '', '## Description', '', 'Investigate docker log drivers.', '',
            '## Solutions', '', '## Whiteboard', '', '## Meta', '',
            '> category  : solution  ',
            'created   : 2019-01-04T10:54:49.265512+00:00  ',
            'digest    : c54c8a896b94ea35edf6c798879957419d26268bd835328d74b19a6e9ce2324d  ',
            'filename  : kubernetes-docker-log-driver-kafka.mkdn  ',
            'languages :  ', 'name      :  ', 'source    :  ',
            'tags      : docker,driver,kafka,kubernetes,logging,logs2kafka,moby,plugin  ',
            'updated   : 2019-01-05T10:54:49.265512+00:00  ',
            'uuid      : 24cd5827-b6ef-4067-b5ac-3ceac07dde9f  ',
            'versions  :  ', '')
        updates = content
        updates['data'][0]['data'] = ('## Description', '',
                                      'Investigate docker log drivers.', '',
                                      '## Solutions', '', '## Whiteboard', '')
        updates['data'][0][
            'description'] = 'Investigate docker log drivers and the logs2kafka log plugin'
        updates['data'][0]['links'] = ()
        updates['data'][0]['updated'] = Content.BEATS_TIME
        updates['data'][0]['uuid'] = Solution.KAFKA_MKDN_UUID
        updates['data'][0][
            'digest'] = '7941851522a23d3651f223b6d69441f77649ccb7ae1e72c6709890f2caf6401a'
        editor_data.return_value = '\n'.join(edited)
        cause = snippy.run([
            'snippy', 'update', '-d', 'c54c8a896b94ea35', '--scat', 'solution'
        ])
        editor_data.assert_called_with(Content.dump_mkdn(Solution.KAFKA_MKDN))
        assert cause == Cause.ALL_OK
        Content.assert_storage(updates)
Ejemplo n.º 5
0
    def test_cli_update_solution_013(snippy, editor_data):
        """Update solution with editor.

        Update existing solution by explicitly defining content format as
        Markdown. In this case the content is not changed at all. In this
        case the solution is stored originally in text format. The content
        must be convertd to Markdown format when displayed in editor.
        """

        content = {'data': [Solution.KAFKA]}
        template = Content.dump_mkdn(content['data'][0])
        editor_data.return_value = template
        cause = snippy.run(
            ['snippy', 'update', '-d', 'ee3f2ab7c63d6965', '--format', 'mkdn'])
        editor_data.assert_called_with(template)
        assert cause == Cause.ALL_OK
        Content.assert_storage(content)