# Path: tsuru_autoscale/instance/client.py
# def host():
# def list(token):
# def get(name, token):
# def alarms_by_instance(instance, token):


from django.test import TestCase
from django.core.urlresolvers import reverse
from django.conf import settings
from tsuru_autoscale.instance import client
from importlib import import_module
import httpretty
import mock
import os
        self.session["tsuru_token"] = "b bla"
        self.session.save()

    @mock.patch("tsuru_autoscale.instance.client.alarms_by_instance")
    @mock.patch("tsuru_autoscale.instance.client.get")
    def test_get_without_alarms(self, list_mock, alarms_by_instance_mock):
        json_mock = mock.Mock()
        json_mock.json.return_value = {"Name": "instance"}
        list_mock.return_value = json_mock

        aresponse = mock.Mock()
        aresponse.json.return_value = None
        alarms_by_instance_mock.return_value = aresponse

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

        self.assertTemplateUsed(response, "instance/get.html")
        self.assertIn('item', response.context)
        self.assertIn('alarms', response.context)
        self.assertIn('events', response.context)
        list_mock.assert_called_with("instance", "bla")

    @mock.patch("tsuru_autoscale.instance.client.alarms_by_instance")
    @mock.patch("tsuru_autoscale.instance.client.get")
    def test_get(self, list_mock, alarms_by_instance_mock):
        json_mock = mock.Mock()
        json_mock.json.return_value = {"Name": "instance"}
        list_mock.return_value = json_mock
        url = "{}?TSURU_TOKEN=bla".format(reverse("instance-get", args=["instance"]))

# Path: tsuru_autoscale/instance/client.py
# def host():
# def list(token):
# def get(name, token):
# def alarms_by_instance(instance, token):


# Path: tsuru_autoscale/instance/tests.py
from django.test import TestCase
from django.core.urlresolvers import reverse
from django.conf import settings
from tsuru_autoscale.instance import client
from importlib import import_module
import httpretty
import mock
import os

        self.session["tsuru_token"] = "b bla"
        self.session.save()

    @mock.patch("tsuru_autoscale.instance.client.alarms_by_instance")
    @mock.patch("tsuru_autoscale.instance.client.get")
    def test_get_without_alarms(self, list_mock, alarms_by_instance_mock):
        json_mock = mock.Mock()
        json_mock.json.return_value = {"Name": "instance"}
        list_mock.return_value = json_mock

        aresponse = mock.Mock()
        aresponse.json.return_value = None
        alarms_by_instance_mock.return_value = aresponse

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

        self.assertTemplateUsed(response, "instance/get.html")
        self.assertIn('item', response.context)
        self.assertIn('alarms', response.context)
        self.assertIn('events', response.context)
        list_mock.assert_called_with("instance", "bla")

    @mock.patch("tsuru_autoscale.instance.client.alarms_by_instance")
    @mock.patch("tsuru_autoscale.instance.client.get")
    def test_get(self, list_mock, alarms_by_instance_mock):
        json_mock = mock.Mock()
        json_mock.json.return_value = {"Name": "instance"}
        list_mock.return_value = json_mock
        url = "{}?TSURU_TOKEN=bla".format(reverse("instance-get", args=["instance"]))

        response = self.client.get(url)