# Path: tsuru_autoscale/datasource/forms.py
# class DataSourceForm(forms.Form):
#     name = forms.CharField()
#     url = forms.CharField()
#     method = forms.CharField()
#     body = forms.CharField(required=False)
#     headers = forms.CharField(required=False)
# 
# Path: tsuru_autoscale/datasource/client.py
# def host():
# def new(data, token):
# def list(token):
# def remove(name, token):
# def get(name, token):


from django.test import TestCase
from django.core.urlresolvers import reverse
from tsuru_autoscale.datasource.forms import DataSourceForm
from tsuru_autoscale.datasource import client
import httpretty
import mock
import os
        self.assertTemplateUsed(response, "datasource/list.html")
        self.assertIn('list', response.context)
        list_mock.assert_called_with("bla")


class GetTest(TestCase):
    @mock.patch("tsuru_autoscale.datasource.client.get")
    def test_get(self, get_mock):
        result_mock = mock.Mock()
        result_mock.json.return_value = {"Name": "ble"}
        get_mock.return_value = result_mock

        url = "{}?TSURU_TOKEN=bla".format(reverse("datasource-get", args=["ble"]))
        response = self.client.get(url)

        self.assertTemplateUsed(response, "datasource/get.html")
        self.assertIn('item', response.context)
        get_mock.assert_called_with("ble", "bla")


class DataSourceFormTestCase(TestCase):
    def test_required_fields(self):
        fields = {
            "url": True,
            "method": True,
            "name": True,
            "body": False,
            "headers": False,
        }


# Path: tsuru_autoscale/datasource/forms.py
# class DataSourceForm(forms.Form):
#     name = forms.CharField()
#     url = forms.CharField()
#     method = forms.CharField()
#     body = forms.CharField(required=False)
#     headers = forms.CharField(required=False)
# 
# Path: tsuru_autoscale/datasource/client.py
# def host():
# def new(data, token):
# def list(token):
# def remove(name, token):
# def get(name, token):


# Path: tsuru_autoscale/datasource/tests.py
from django.test import TestCase
from django.core.urlresolvers import reverse
from tsuru_autoscale.datasource.forms import DataSourceForm
from tsuru_autoscale.datasource import client
import httpretty
import mock
import os

        self.assertTemplateUsed(response, "datasource/list.html")
        self.assertIn('list', response.context)
        list_mock.assert_called_with("bla")


class GetTest(TestCase):
    @mock.patch("tsuru_autoscale.datasource.client.get")
    def test_get(self, get_mock):
        result_mock = mock.Mock()
        result_mock.json.return_value = {"Name": "ble"}
        get_mock.return_value = result_mock

        url = "{}?TSURU_TOKEN=bla".format(reverse("datasource-get", args=["ble"]))
        response = self.client.get(url)

        self.assertTemplateUsed(response, "datasource/get.html")
        self.assertIn('item', response.context)
        get_mock.assert_called_with("ble", "bla")


class DataSourceFormTestCase(TestCase):
    def test_required_fields(self):
        fields = {
            "url": True,
            "method": True,
            "name": True,
            "body": False,
            "headers": False,
        }


        form = DataSourceForm()