def test_added_pack(self):
        """
        Given
        - A repository of two new packs:
          - FakePack3 version 1.0.0
          - FakePack4 version 1.0.0

        When
        - Generating a release notes summary file.

        Then
        - Ensure release notes generator creates a valid summary, by checking:
          - the release notes summary contains two packs:
            - FakePack3 with version 1.0.0
            - FakePack4 with version 1.0.0
        """
        new_packs_rn = {
            'FakePack3':
            get_pack_entities(os.path.join(TEST_DATA_PATH, 'FakePack3')),
            'FakePack4':
            get_pack_entities(os.path.join(TEST_DATA_PATH, 'FakePack4')),
        }
        packs_metadta_dict = {'FakePack3': {}, 'FakePack4': {}}

        rn_summary = generate_release_notes_summary(new_packs_rn, {},
                                                    packs_metadta_dict,
                                                    self._version,
                                                    self._asset_id, 'temp.md')

        assert '## New: FakePack3 Pack v1.0.0' in rn_summary
        assert '## New: FakePack4 Pack v1.0.0' in rn_summary
    def test_release_notes_summary_with_empty_lines_in_rn(self):
        """
        Given
        - A repository contains a FakePack3 update with ignored release notes.

        When
        - Generating a release notes summary file.

        Then
        - Ensure release notes generator creates a valid summary, by checking:
          - the output of get_release_notes_dict() is a dict of (pack_name, dict(pack_version, release_note)).
          - empty lines (with dashes) are removed from the release notes summary.
        """
        release_notes_files = [
            os.path.join(TEST_DATA_PATH, 'FakePack3', 'ReleaseNotes',
                         '1_0_1.md')
        ]

        packs_metadta_dict = {'FakePack3': {}}

        rn_dict, _ = get_release_notes_dict(release_notes_files)

        assert '1.0.1' in rn_dict['FakePack3'].keys()
        assert len(rn_dict) == 1

        rn_summary = generate_release_notes_summary({}, rn_dict,
                                                    packs_metadta_dict,
                                                    self._version,
                                                    self._asset_id,
                                                    self._outfile)

        print(rn_summary)

        match = re.search(EMPTY_LINES_REGEX, rn_summary)
        assert match is None
    def test_release_notes_summary_with_ignored_rns(self):
        """
        Given
        - A repository of a packs update and release notes:
          - FakePack4 with versions 1.0.1 and 1.1.0

        When
        - Generating a release notes summary file.

        Then
        - Ensure release notes generator creates a valid summary, by checking:
          - the output of get_release_notes_dict() is a valid dict of (pack_name, dict(pack_version, release_note))
          - the release notes summary contains one packs with 1 updates:
            - FakePack4 version 1.1.0
          - the summary does not contain release notes 1.0.1, because it is ignored.
        """
        release_notes_files = [
            os.path.join(TEST_DATA_PATH, 'FakePack4', 'ReleaseNotes',
                         '1_0_1.md'),
            os.path.join(TEST_DATA_PATH, 'FakePack4', 'ReleaseNotes',
                         '1_1_0.md'),
        ]

        rn_dict = get_release_notes_dict(release_notes_files)

        assert '1.1.0' in rn_dict['FakePack4'].keys()
        assert len(rn_dict) == 1

        rn_summary = generate_release_notes_summary({}, rn_dict, self._version,
                                                    self._asset_id,
                                                    self._outfile)

        assert '### FakePack4 Pack v1.1.0' in rn_summary
        assert '##### FakePack4_Script1' in rn_summary
Exemplo n.º 4
0
    def test_added_contribution_pack(self):
        """
        Given
        - A repository of two new packs:
          - FakePack3 version 1.0.0, metadata "supports" field has value "contribution"
          - FakePack4 version 1.0.0

        When
        - Generating a release notes summary file.

        Then
        - Ensure release notes generator creates a valid summary, by checking:
          - the release notes summary contains two packs:
            - FakePack3 with version 1.0.0 and has the string "(Community Contributed)" after the version
            - FakePack4 with version 1.0.0 dose not have the string "(Community Contributed)" after the version
        """
        new_packs_rn = {
            'FakePack3': get_pack_entities(os.path.join(TEST_DATA_PATH, 'FakePack3')),
            'FakePack4': get_pack_entities(os.path.join(TEST_DATA_PATH, 'FakePack4')),
        }
        packs_metadta_dict = {
            'FakePack3': {'support': 'community'},
            'FakePack4': {'support': 'xsoar'}
        }

        rn_summary = generate_release_notes_summary(
            new_packs_rn, {}, packs_metadta_dict, self._version, self._asset_id, 'temp.md')

        assert '## New: FakePack3 Pack v1.0.0 (Community Contributed)' in rn_summary
        assert '## New: FakePack4 Pack v1.0.0' in rn_summary
        assert '## New: FakePack4 Pack v1.0.0 (Community Contributed)' not in rn_summary
    def test_updated_partner_pack(self):
        """
        Given
        - A repository of two packs updates and release notes:
          - FakePack1 with version 2.0.0 metadata "supports" field has value "partner"
          - FakePack2 version 1.1.0

        When
        - Generating a release notes summary file.

        Then
        - Ensure release notes generator creates a valid summary, by checking:
          - the output of get_release_notes_dict() is a valid dict of (pack_name, dict(pack_version, release_note)).
          - the release notes summary contains two packs with the flowing:
            - FakePack1 with version 2.0.0 and has the string "(Partner Supported)" after the version
            - FakePack2 with version 1.1.0 dose not have the string "(Partner Supported)" after the version
        """
        release_notes_files = [
            os.path.join(TEST_DATA_PATH, 'FakePack1', 'ReleaseNotes',
                         '1_1_0.md'),
            os.path.join(TEST_DATA_PATH, 'FakePack1', 'ReleaseNotes',
                         '2_0_0.md'),
            os.path.join(TEST_DATA_PATH, 'FakePack2', 'ReleaseNotes',
                         '1_1_0.md'),
        ]

        rn_dict, _ = get_release_notes_dict(release_notes_files)

        packs_metadta_dict = {
            'FakePack1': {
                'support': 'partner'
            },
            'FakePack2': {
                'support': 'xsoar'
            }
        }

        assert '2.0.0' in rn_dict['FakePack1'].keys()
        assert '1.1.0' in rn_dict['FakePack2'].keys()

        rn_summary = generate_release_notes_summary({}, rn_dict,
                                                    packs_metadta_dict,
                                                    self._version,
                                                    self._asset_id,
                                                    self._outfile)

        assert VERSION in rn_summary and ASSET_ID in rn_summary  # summary title
        assert '### FakePack1 Pack v2.0.0 (Partner Supported)' in rn_summary
        assert '### FakePack2 Pack v1.1.0' in rn_summary
        assert '### FakePack2 Pack v1.1.0 (Partner Supported)' not in rn_summary
    def test_two_packs(self):
        """
        Given
        - A repository of two packs updates and release notes:
          - FakePack1 with versions 1.1.0 and 2.0.0
          - FakePack2 version 1.1.0

        When
        - Generating a release notes summary file.

        Then
        - Ensure release notes generator creates a valid summary, by checking:
          - the output of get_release_notes_dict() is a valid dict of (pack_name, dict(pack_version, release_note)).
          - the release notes summary contains two packs with 3 updates:
            - FakePack1 with versions 1.1.0 and 2.0.0
            - FakePack2 with versions 1.1.0
        """
        release_notes_files = [
            os.path.join(TEST_DATA_PATH, 'FakePack1', 'ReleaseNotes',
                         '1_1_0.md'),
            os.path.join(TEST_DATA_PATH, 'FakePack1', 'ReleaseNotes',
                         '2_0_0.md'),
            os.path.join(TEST_DATA_PATH, 'FakePack2', 'ReleaseNotes',
                         '1_1_0.md'),
        ]

        rn_dict, _ = get_release_notes_dict(release_notes_files)

        packs_metadta_dict = {'FakePack1': {}, 'FakePack2': {}}

        assert '1.1.0' in rn_dict['FakePack1'].keys()
        assert '2.0.0' in rn_dict['FakePack1'].keys()
        assert '1.1.0' in rn_dict['FakePack2'].keys()

        rn_summary = generate_release_notes_summary({}, rn_dict,
                                                    packs_metadta_dict,
                                                    self._version,
                                                    self._asset_id,
                                                    self._outfile)

        assert VERSION in rn_summary and ASSET_ID in rn_summary  # summary title
        assert '### FakePack1 Pack v2.0.0' in rn_summary
        assert '##### FakePack1_Integration1' in rn_summary
        assert 'This is a fake1 minor release note.' in rn_summary
        assert 'This is a fake1 major release note.' in rn_summary
        assert '### FakePack2 Pack v1.1.0' in rn_summary
        assert '##### FakePack2_Script1' in rn_summary
        assert 'This is a fake2 major release note.' in rn_summary