def test_create_record_set(record_set, mocked_responses, vinyldns_client):
    change = gen_rs_change(record_set)
    mocked_responses.add(responses.POST,
                         'http://test.com/zones/{0}/recordsets'.format(
                             record_set.zone_id),
                         body=to_json_string(change),
                         status=200)
    r = vinyldns_client.create_record_set(record_set)
    check_record_set_changes_are_equal(change, r)
    mocked_responses.reset()
def test_get_record_set_change(record_set, mocked_responses, vinyldns_client):
    change = gen_rs_change(record_set)
    mocked_responses.add(
        responses.GET,
        'http://test.com/zones/{0}/recordsets/{1}/changes/{2}'.format(
            record_set.zone_id, record_set.id, change.id),
        body=to_json_string(change),
        status=200)
    r = vinyldns_client.get_record_set_change(record_set.zone_id,
                                              record_set.id, change.id)
    check_record_set_changes_are_equal(r, change)
def test_delete_record_set(record_set, mocked_responses, vinyldns_client):
    rs = copy.deepcopy(record_set)
    rs.id = rs.name + 'id'
    change = gen_rs_change(rs)
    mocked_responses.add(responses.DELETE,
                         'http://test.com/zones/{0}/recordsets/{1}'.format(
                             rs.zone_id, rs.id),
                         body=to_json_string(change),
                         status=200)
    r = vinyldns_client.delete_record_set(rs.zone_id, rs.id)
    check_record_set_changes_are_equal(change, r)
    mocked_responses.reset()
def test_record_set_changes_serdes(record_set):
    a = gen_rs_change(record_set)
    s = to_json_string(a)
    b = from_json_string(s, RecordSetChange.from_dict)

    assert a.user_id == b.user_id
    assert a.change_type == b.change_type
    assert a.status == b.status
    assert a.created == b.created
    assert a.system_message == b.system_message
    assert a.id == b.id
    assert a.user_name == b.user_name
    assert a.zone.id == b.zone.id
    check_record_sets_are_equal(a.record_set, b.record_set)
    check_record_sets_are_equal(a.updates, b.updates)
def test_list_record_set_changes(mocked_responses, vinyldns_client):
    changes = [gen_rs_change(c) for c in record_set_values]
    lrscr = ListRecordSetChangesResponse(forward_zone.id, changes, 'next',
                                         'start', 100)
    mocked_responses.add(
        responses.GET,
        'http://test.com/zones/{0}/recordsetchanges?startFrom=start&maxItems=100'
        .format(forward_zone.id),
        body=to_json_string(lrscr),
        status=200)
    r = vinyldns_client.list_record_set_changes(forward_zone.id, 'start', 100)
    r.start_from = lrscr.start_from
    r.next_id = lrscr.next_id
    r.max_items = lrscr.max_items
    r.zone_id = lrscr.zone_id
    for l, r in zip(r.record_set_changes, lrscr.record_set_changes):
        check_record_set_changes_are_equal(l, r)