def test_clone(): payload = {'name': generate_name('test_clone'), 'group_id': 122} cloning_campaign = api.campaigns.create(payload).json() response = api.campaigns.clone(cloning_campaign['id']) json = response.json() assert response.status_code == 200 assert isinstance(json, list) assert json[0]['name'] == 'Copy of ' + cloning_campaign['name']
def test_create(): name = generate_name('test_create') group_id = 122 payload = {'name': name, 'group_id': group_id} response = api.campaigns.create(payload) json = response.json() assert response.status_code == 200 assert isinstance(json, dict) assert json['name'] == name assert json['group_id'] == group_id
def test_restore(): payload = { 'name': generate_name('test_restore'), 'group_id': 122, 'state': 'deleted' } deleted_campaign = api.campaigns.create(payload).json() response = api.campaigns.restore(deleted_campaign['id']) json = response.json() assert response.status_code == 200 assert json[0]['id'] == deleted_campaign['id'] assert json[0]['state'] == 'active'
def test_disable(): payload = { 'name': generate_name('test_disable'), 'group_id': 122, 'state': 'active' } active_campaign = api.campaigns.create(payload).json() response = api.campaigns.disable(active_campaign['id']) json = response.json() assert response.status_code == 200 assert json[0]['id'] == active_campaign['id'] assert json[0]['state'] == 'disabled'
def test_delete(): payload = { 'name': generate_name('test_delete'), 'group_id': 14 } created_offer = api.offers.create(payload) created_offer_id = created_offer.json()['id'] response = api.offers.delete(created_offer_id) json = response.json() assert response.status_code == 200 assert isinstance(json, list) assert json[0]['id'] == int(created_offer_id) assert json[0]['state'] == 'deleted'
def test_update(): name = generate_name('test_update') payload = { 'name': name, 'group_id': 122, } campaign = api.campaigns.create(payload).json() updated_name = name + '_updated' update_payload = { 'group_id': 122, 'name': updated_name, 'cost_value': '11', 'cost_auto': False, 'traffic_source_id': 3 } response = api.campaigns.update(campaign['id'], update_payload) json = response.json() assert response.status_code == 200 assert json['name'] == updated_name assert json['id'] == campaign['id'] assert json['cost_value'] == '11' assert json['cost_auto'] == False
def test_update(): name = generate_name('test_update') offer_payload = { 'name': name, 'country': 'GB', 'action_payload': 'https://example.com' } offer = api.offers.create(offer_payload).json() updated_name = name + '_updated' updated_action_payload = 'https://updatedurl.net' payload = { 'name': updated_name, 'country': 'BH', 'action_payload': updated_action_payload } response = api.offers.update(offer['id'], payload) json = response.json() assert response.status_code == 200 assert isinstance(json, dict) assert json['name'] == updated_name assert json['country'][0] == 'BH' assert json['action_payload'] == updated_action_payload