コード例 #1
0
def test_edit_service_raises_error_if_no_transaction_started(monkeypatch):
    set_up_edit_service_mock(monkeypatch)
    edit_service = EditService('service_account', 'credentials_file_path',
                               'dummy_package_name')
    edit_service.commit_transaction()
    with pytest.raises(NoTransactionError):
        edit_service.upload_apk(apk_path='/path/to/dummy.apk')
コード例 #2
0
def test_edit_service_is_allowed_to_not_make_a_single_call_to_google_play(
        monkeypatch):
    edit_service_mock = set_up_edit_service_mock(monkeypatch)
    edit_service = EditService('service_account',
                               'credentials_file_path',
                               'dummy_package_name',
                               commit=True,
                               contact_google_play=False)
    upload_apk_result = edit_service.upload_apk(apk_path='/path/to/dummy.apk')
    edit_service.update_listings(language='some_language',
                                 title='some_title',
                                 full_description='some_description',
                                 short_description='some_desc')
    edit_service.update_track(track='some_track', version_codes=['1', '2'])
    edit_service.update_whats_new(language='some_language',
                                  apk_version_code='some_version_code',
                                  whats_new='some_text')
    edit_service.commit_transaction()

    assert upload_apk_result == {
        'versionCode': 'fake-version-code'
    }  # Value set when contact_google_play is False
    edit_service_mock.apks().upload.assert_not_called()
    edit_service_mock.apklistings().update.assert_not_called()
    edit_service_mock.tracks().update.assert_not_called()
    edit_service_mock.apklistings().update.assert_not_called()
    edit_service_mock.commit.assert_not_called()
コード例 #3
0
def test_upload_apk_returns_files_metadata(monkeypatch):
    edit_mock = set_up_edit_service_mock(monkeypatch)
    edit_mock.apks().upload().execute.return_value = {
        'binary': {'sha1': '1234567890abcdef1234567890abcdef12345678'}, 'versionCode': 2015012345
    }
    edit_mock.apks().upload.reset_mock()

    edit_service = EditService('service_account', 'credentials_file_path', 'dummy_package_name')
    response = edit_service.upload_apk(apk_path='/path/to/dummy.apk')
    assert response == {
        'binary': {'sha1': '1234567890abcdef1234567890abcdef12345678'}, 'versionCode': 2015012345
    }
    edit_mock.apks().upload.assert_called_once_with(
        editId=edit_service._edit_id,
        packageName='dummy_package_name',
        media_body='/path/to/dummy.apk',
    )
コード例 #4
0
def test_edit_service_starts_new_transaction_upon_init(monkeypatch):
    set_up_edit_service_mock(monkeypatch)
    edit_service = EditService('service_account', 'credentials_file_path',
                               'dummy_package_name')
    edit_service.upload_apk(apk_path='/path/to/dummy.apk')