# WARNING: Do not edit by hand, this file was generated by Crank:
#
#   https://github.com/gocardless/crank
#

import json

import requests
import responses
from nose.tools import assert_equal, assert_is_instance

from gocardless_pro import resources
from gocardless_pro import list_response

from .. import helpers

@responses.activate
def test_redirect_flows_create():
    fixture = helpers.load_fixture('redirect_flows')['create']
    helpers.stub_response(fixture)
    response = helpers.client.redirect_flows.create(*fixture['url_params'])
    body = fixture['body']['redirect_flows']

    assert_is_instance(response, resources.RedirectFlow)

    assert_equal(response.created_at, body.get('created_at'))
    assert_equal(response.description, body.get('description'))
    assert_equal(response.id, body.get('id'))
    assert_equal(response.redirect_url, body.get('redirect_url'))
    assert_equal(response.scheme, body.get('scheme'))
    assert_equal(response.session_token, body.get('session_token'))
    assert_equal(response.success_redirect_url, body.get('success_redirect_url'))
    assert_equal(response.links.creditor,
                 body.get('links')['creditor'])
    assert_equal(response.links.mandate,
                 body.get('links')['mandate'])

@responses.activate
def test_redirect_flows_get():
    fixture = helpers.load_fixture('redirect_flows')['get']
    helpers.stub_response(fixture)
    response = helpers.client.redirect_flows.get(*fixture['url_params'])
    body = fixture['body']['redirect_flows']

    assert_is_instance(response, resources.RedirectFlow)

    assert_equal(response.created_at, body.get('created_at'))
    assert_equal(response.description, body.get('description'))
    assert_equal(response.id, body.get('id'))
    assert_equal(response.redirect_url, body.get('redirect_url'))
    assert_equal(response.scheme, body.get('scheme'))
    assert_equal(response.session_token, body.get('session_token'))
    assert_equal(response.success_redirect_url, body.get('success_redirect_url'))
    assert_equal(response.links.creditor,
                 body.get('links')['creditor'])
    assert_equal(response.links.mandate,
                 body.get('links')['mandate'])

@responses.activate
def test_redirect_flows_complete():
    fixture = helpers.load_fixture('redirect_flows')['complete']
    helpers.stub_response(fixture)
    response = helpers.client.redirect_flows.complete(*fixture['url_params'])
    body = fixture['body']['redirect_flows']

    assert_is_instance(response, resources.RedirectFlow)

    assert_equal(response.created_at, body.get('created_at'))
    assert_equal(response.description, body.get('description'))
    assert_equal(response.id, body.get('id'))
    assert_equal(response.redirect_url, body.get('redirect_url'))
    assert_equal(response.scheme, body.get('scheme'))
    assert_equal(response.session_token, body.get('session_token'))
    assert_equal(response.success_redirect_url, body.get('success_redirect_url'))
    assert_equal(response.links.creditor,
                 body.get('links')['creditor'])
    assert_equal(response.links.mandate,
                 body.get('links')['mandate'])

