Exemplo n.º 1
0
def test_crud_overrides():
    api.internal_delete(partner_id, playable_id)
    api.internal_create(partner_id, playable_id, playable_type, viewable_id,
                        ad_settings)

    overrides = api.internal_list(partner_id).json()
    override_ids = map(lambda o: o['playableId'], overrides)
    assert_equal(playable_id in override_ids, True, 'playable_id_in_list')

    override = api.internal_get(partner_id, playable_id).json()
    assert_equal(override['playableId'], playable_id, 'playable_id_in_get')
    assert_equal(override['partnerId'], partner_id)
    assert_equal(override['playableType'], playable_type)
    assert_equal(override['viewableId'], viewable_id)
    assert_equal(override['adSettings'], ad_settings)

    api.internal_update(partner_id, playable_id, updated_ad_settings)

    override = api.internal_get(partner_id, playable_id).json()
    assert_equal(override['adSettings'], updated_ad_settings)

    api.internal_delete(partner_id, playable_id)

    response = api.internal_get(partner_id, playable_id)
    assert_equal(response.status_code, 404, 'get should be 404 after delete')
Exemplo n.º 2
0
def test_create_double():
    api.internal_delete(partner_id, playable_id)

    api.internal_create(partner_id, playable_id, playable_type, viewable_id,
                        ad_settings)
    response = api.internal_create(partner_id, playable_id, playable_type,
                                   viewable_id, {})
    assert_equal(response.status_code, 400, 'status on double create')

    override = api.internal_get(partner_id, playable_id).json()
    assert_equal(override['playableId'], playable_id, 'playable_id_in_get')
    assert_equal(override['partnerId'], partner_id)
    assert_equal(override['playableType'], playable_type)
    assert_equal(override['viewableId'], viewable_id)
    assert_equal(override['adSettings'], ad_settings)

    api.internal_delete(partner_id, playable_id)
Exemplo n.º 3
0
def test_update_invalid_schema():
    api.internal_delete(partner_id, playable_id).status_code
    assert_equal(
        api.internal_create(partner_id, playable_id, playable_type,
                            viewable_id, ad_settings).status_code, 200)
    assert_equal(
        api.internal_update(
            partner_id, playable_id,
            '{"foo": "this-is-not-a-valid-schema"}').status_code, 400,
        'status for invalid schema')
Exemplo n.º 4
0
def test_create_full():
    api.internal_delete(partner_id, playable_id)
    response = api.internal_create(partner_id, playable_id, playable_type,
                                   viewable_id, ad_settings_full)
    assert_equal(response.status_code, 200, "create full status")

    override = api.internal_get(partner_id, playable_id).json()
    assert_equal(override['playableId'], playable_id, 'playable_id_in_get')
    assert_equal(override['partnerId'], partner_id)
    assert_equal(override['playableType'], playable_type)
    assert_equal(override['viewableId'], viewable_id)
    assert_equal(override['adSettings'], ad_settings_full)
Exemplo n.º 5
0
def test_setup():
    email, password, _, _ = config.credentials()
    context['partner'] = partner_api.get(PARTNER_ID).json()
    context['clientApiToken'] = context['partner']['clientApiToken']
    api.internal_delete(PARTNER_ID, VOD_ID)
    assert_equal(
        api.internal_create(PARTNER_ID, VOD_ID, 'vod', 'api-test-viewable-id',
                            VOD_SETTINGS).status_code, 200,
        'create test VOD status')
    user = user_api.login(context['clientApiToken'], email, password).json()
    context['user_id'] = user['userId']
    context['user_token'] = user['token']
    print('user_id=%s, user_token=%s' %
          (context['user_id'], context['user_token']))
    context['user_info'] = {'gender': 'm', 'yearOfBirth': 1974}
    user_api.set_dynamic(context['user_id'], context['clientApiToken'],
                         context['user_token'], context['user_info'])
Exemplo n.º 6
0
def test_create_invalid_playable_type():
    api.internal_delete(partner_id, playable_id)
    response = api.internal_create(partner_id, playable_id, 'foobar',
                                   viewable_id, ad_settings)
    assert_equal(response.status_code, 400, 'status for invalid playable type')
Exemplo n.º 7
0
def test_create_invalid_schema():
    api.internal_delete(partner_id, playable_id)
    response = api.internal_create(partner_id, playable_id, playable_type,
                                   viewable_id,
                                   '{"foo": "this-is-not-a-valid-schema"}')
    assert_equal(response.status_code, 400, 'status for invalid schema')
Exemplo n.º 8
0
def test_create_invalid_json():
    api.internal_delete(partner_id, playable_id)
    response = api.internal_create(partner_id, playable_id, playable_type,
                                   viewable_id, "{this-is-not-valid-json")
    assert_equal(response.status_code, 400, 'status for invalid json')
Exemplo n.º 9
0
def test_create_empty_allowed():
    api.internal_delete(partner_id, playable_id)
    assert_equal(
        api.internal_create(partner_id, playable_id, playable_type,
                            viewable_id, None).status_code, 200,
        'create empty status code')