def test_prepare_release_notes_upgrade_version_dup(self, mocker, dummy_pack):
     """
        Given:
            - Valid new version and valid current changelog found in index with existing version.
        When:
            - Not updating versions and adding to changelog.json
        Then:
            - return True
    """
     dummy_pack.current_version = '2.0.0'
     mocker.patch("os.path.exists", return_value=True)
     mocker.patch("Tests.Marketplace.marketplace_services.print_warning")
     mocker.patch("Tests.Marketplace.marketplace_services.print_color")
     dir_list = ['1_0_1.md', '2_0_0.md']
     mocker.patch("os.listdir", return_value=dir_list)
     original_changelog = '''{
         "1.0.0": {
             "releaseNotes": "First release notes",
             "displayName": "1.0.0",
             "released": "2020-05-05T13:39:33Z"
         },
         "2.0.0": {
             "releaseNotes": "Second release notes",
             "displayName": "2.0.0",
             "released": "2020-06-05T13:39:33Z"
         }
     }'''
     mocker.patch('builtins.open', mock_open(read_data=original_changelog))
     dummy_path = 'Irrelevant/Test/Path'
     build_number = random.randint(0, 100000)
     task_status, not_updated_build = Pack.prepare_release_notes(self=dummy_pack, index_folder_path=dummy_path,
                                                                 build_number=build_number)
     assert task_status is True
     assert not_updated_build is False
Пример #2
0
 def test_prepare_release_notes_upgrade_version_mismatch(self, mocker, dummy_pack):
     """
        Given:
            - Invalid new version and valid current changelog found in index. Mismatching versions.
        When:
            - Upgrading versions and adding to changelog.json
        Then:
            - return False
    """
     dummy_pack.current_version = '2.0.0'
     mocker.patch("Tests.Marketplace.marketplace_services.print_error")
     mocker.patch("Tests.Marketplace.marketplace_services.print_color")
     mocker.patch("os.path.exists", return_value=True)
     dir_list = ['1_0_1.md', '2_0_2.md', '2_0_0.md']
     mocker.patch("os.listdir", return_value=dir_list)
     original_changelog = '''{
         "1.0.0": {
             "releaseNotes": "First release notes",
             "displayName": "1.0.0",
             "released": "2020-05-05T13:39:33Z"
         },
         "2.0.0": {
             "releaseNotes": "Second release notes",
             "displayName": "2.0.0",
             "released": "2020-06-05T13:39:33Z"
         }
     }'''
     mocker.patch('builtins.open', mock_open(read_data=original_changelog))
     dummy_path = 'Irrelevant/Test/Path'
     result = Pack.prepare_release_notes(self=dummy_pack, index_folder_path=dummy_path)
     assert result is False
Пример #3
0
 def test_prepare_release_notes_upgrade_version_dup(self, mocker, dummy_pack):
     # TODO When we move to not overriding packs in the build, we will need to change result returned.
     """
        Given:
            - Valid new version and valid current changelog found in index with existing version.
        When:
            - Not updating versions and adding to changelog.json
        Then:
            - return True
    """
     dummy_pack.current_version = '2.0.0'
     mocker.patch("os.path.exists", return_value=True)
     mocker.patch("Tests.Marketplace.marketplace_services.print_warning")
     mocker.patch("Tests.Marketplace.marketplace_services.print_color")
     dir_list = ['1_0_1.md', '2_0_0.md']
     mocker.patch("os.listdir", return_value=dir_list)
     original_changelog = '''{
         "1.0.0": {
             "releaseNotes": "First release notes",
             "displayName": "1.0.0",
             "released": "2020-05-05T13:39:33Z"
         },
         "2.0.0": {
             "releaseNotes": "Second release notes",
             "displayName": "2.0.0",
             "released": "2020-06-05T13:39:33Z"
         }
     }'''
     mocker.patch('builtins.open', mock_open(read_data=original_changelog))
     dummy_path = 'Irrelevant/Test/Path'
     result = Pack.prepare_release_notes(self=dummy_pack, index_folder_path=dummy_path)
     assert result is True
Пример #4
0
 def test_prepare_release_notes_first_run(self, mocker, dummy_pack):
     """ In case changelog.json doesn't exists, expected result should be initial version 1.0.0
     """
     mocker.patch("os.path.exists", return_value=False)
     dummy_path = 'Irrelevant/Test/Path'
     result = Pack.prepare_release_notes(self=dummy_pack, index_folder_path=dummy_path)
     assert result is True
 def test_prepare_release_notes_first_run(self, mocker, dummy_pack):
     """ In case changelog.json doesn't exists, expected result should be initial version 1.0.0
     """
     mocker.patch("os.path.exists", return_value=False)
     dummy_path = 'Irrelevant/Test/Path'
     build_number = random.randint(0, 100000)
     task_status, not_updated_build = Pack.prepare_release_notes(self=dummy_pack, index_folder_path=dummy_path,
                                                                 build_number=build_number)
     assert task_status is True
     assert not_updated_build is False