Example #1
0
    def test_get_from_and_to_version_from_modified_files(self):
        """
        Given:
            - Integration path with fromversion 6.0.
            - Playbook path with toversion 5.9.9
            - test playbook path with fromversion 5.0.
        When:
            - running get_test_list_and_content_packs_to_install
        Then:
            - Check that the toversion is the default (99.99.99)
            - Check minimum version is 5.0.0

        """
        test_integration_path = 'Tests/scripts/infrastructure_tests/tests_data/mock_integrations/' \
                                'test_fake_integration.yml'
        test_playbook_path = 'Tests/scripts/infrastructure_tests/tests_data/mock_test_playbooks/' \
                             'playbook-fake_test_playbook_to_version.yml'
        playbook_path = 'Tests/scripts/infrastructure_tests/tests_data/mock_playbooks/test_fake_playbook.yml'

        modified_files_list = [test_integration_path, playbook_path]
        modified_tests_list = [test_playbook_path]
        all_modified_files_paths = set(modified_files_list +
                                       modified_tests_list)
        from_version, to_version = get_from_version_and_to_version_bounderies(
            all_modified_files_paths, MOCK_ID_SET)

        assert '5.0.0' in from_version
        assert '99.99.99' in to_version
Example #2
0
def test_get_from_version_and_to_version_bounderies_modified_metadata():
    """
    Given:
        - metadata file with serverMinVersion 6.1.0.
    When:
        - running get_from_version_and_to_version_bounderies
    Then:
        - Check that the toversion is the default (99.99.99)
        - Check that the minimum version is 6.1.0

    """
    all_modified_files_paths = set([])
    pack_list = {'Pack1'}

    with tempfile.TemporaryDirectory() as temp_dir:
        with test_tools.ChangeCWD(temp_dir):
            content = repo.Repo(Path(temp_dir))
            pack1 = content.create_pack('Pack1')
            pack1.pack_metadata.write_json({
                'serverMinVersion': '6.1.0',
                'name': 'Pack1'
            })

            from_version, to_version = get_from_version_and_to_version_bounderies(
                all_modified_files_paths,
                {},
                modified_packs=pack_list,
            )

    assert '6.1.0' in from_version
    assert '99.99.99' in to_version
Example #3
0
    def test_get_from_version_and_to_version_from_modified_files(self):
        """
        Given:
            - fake_test_playbook is fromversion 5.5.0 in id_set
        When:
            - running get_test_list_and_content_packs_to_install
            - running create_filter_envs_file
        Then:
            - Create test list with fake_test_playbook
            - Create filter_envs.json file with 5.0 as False

        """
        test_path = 'Tests/scripts/infrastructure_tests/tests_data/mock_test_playbooks/fake_test_playbook.yml'
        modified_files_list, modified_tests_list, changed_common, _, sample_tests, modified_metadata_list, _, _ = \
            create_get_modified_files_ret(modified_files_list=[test_path], modified_tests_list=[test_path])
        all_modified_files_paths = set(modified_files_list +
                                       modified_tests_list + changed_common +
                                       sample_tests)
        from_version, to_version = get_from_version_and_to_version_bounderies(
            all_modified_files_paths, MOCK_ID_SET)

        create_filter_envs_file(from_version, to_version)
        with open("./Tests/filter_envs.json", "r") as filter_envs_file:
            filter_envs = json.load(filter_envs_file)
        assert filter_envs.get('Server 5.5') is True
        assert filter_envs.get('Server Master') is True
        assert filter_envs.get('Server 6.0') is True
        assert filter_envs.get('Server 5.0') is False
    def test_get_from_version_and_to_version_from_modified_files(self):
        """
        Given:
            - fake_test_playbook is fromversion 4.1.0 in integration file
            - two_before_ga is '4.0.0'
            - one_before_ga is '4.0.1'
            - ga is '4.1.0'
        When:
            - running get_test_list_and_content_packs_to_install
            - running create_filter_envs_file
        Then:
            - Create test list with fake_test_playbook
            - Create filter_envs.json file with Demisto two before GA False and Demisto one before GA False

        """
        two_before_ga = '4.0.0'
        one_before_ga = '4.0.1'
        ga = '4.1.0'
        test_path = 'Tests/scripts/infrastructure_tests/tests_data/mock_test_playbooks/fake_test_playbook.yml'
        modified_files_list, modified_tests_list, changed_common, _, sample_tests, modified_metadata_list, _, _ = \
            create_get_modified_files_ret(modified_files_list=[test_path], modified_tests_list=[test_path])

        all_modified_files_paths = set(modified_files_list + modified_tests_list + changed_common + sample_tests)
        from_version, to_version = get_from_version_and_to_version_bounderies(all_modified_files_paths,
                                                                              MOCK_ID_SET)

        create_filter_envs_file(from_version, to_version, two_before_ga, one_before_ga, ga)
        with open("./Tests/filter_envs.json", "r") as filter_envs_file:
            filter_envs = json.load(filter_envs_file)
        assert filter_envs.get('Demisto PreGA') is True
        assert filter_envs.get('Demisto Marketplace') is True
        assert filter_envs.get('Demisto 6.0') is True
        assert filter_envs.get('Demisto GA') is False