Exemple #1
0
 def test_service_list(self, get):
     AppDetail.service_list = self.old_service_list
     app_detail = AppDetail()
     app_detail.request = self.request
     app_detail.service_list()
     get.assert_called_with(
         '{0}/services/instances'.format(settings.TSURU_HOST),
         headers={'authorization': self.request.session.get('tsuru_token')})
 def test_service_instances(self, get):
     get.return_value = Mock(status_code=200)
     AppDetail.service_instances = self.old_service_instances
     app_detail = AppDetail()
     app_detail.request = self.request
     app_detail.service_instances("appname")
     get.assert_called_with(
         '{0}/services/instances?app=appname'.format(settings.TSURU_HOST),
         headers={'authorization': self.request.session.get('tsuru_token')})
 def test_service_instances(self, get):
     get.return_value = Mock(status_code=200)
     AppDetail.service_instances = self.old_service_instances
     app_detail = AppDetail()
     app_detail.request = self.request
     app_detail.service_instances("appname")
     get.assert_called_with(
         '{0}/services/instances?app=appname'.format(settings.TSURU_HOST),
         headers={'authorization': self.request.session.get('tsuru_token')})
Exemple #4
0
 def test_service_info(self, get):
     AppDetail.service_info = self.old_service_info
     app_detail = AppDetail()
     app_detail.request = self.request
     instance_name = "shubiduba"
     app_detail.service_info(instance_name)
     get.assert_called_with(
         '{0}/services/instances/{1}'.format(settings.TSURU_HOST,
                                             instance_name),
         headers={'authorization': self.request.session.get('tsuru_token')})
    def test_get_containers(self, get):
        expected = []
        response_mock = Mock(status_code=200)
        response_mock.json.return_value = expected
        get.return_value = response_mock

        request = RequestFactory().get("/")
        request.session = {"is_admin": True, "tsuru_token": "admin"}

        app_detail = AppDetail()
        app_detail.request = request
        envs = app_detail.get_containers("appname")

        self.assertListEqual(envs, expected)
        url = "{}/docker/node/apps/appname/containers".format(settings.TSURU_HOST)
        get.assert_called_with(url, headers={"authorization": "admin"})
    def test_get_containers(self, get):
        expected = []
        response_mock = Mock(status_code=200)
        response_mock.json.return_value = expected
        get.return_value = response_mock

        request = RequestFactory().get("/")
        request.session = {"is_admin": True, "tsuru_token": "admin"}

        app_detail = AppDetail()
        app_detail.request = request
        envs = app_detail.get_containers("appname")

        self.assertListEqual(envs, expected)
        url = '{}/docker/node/apps/appname/containers'.format(
            settings.TSURU_HOST)
        get.assert_called_with(url, headers={'authorization': 'admin'})
    def test_get_envs(self, get):
        expected = [{
            "name": "DATABASE_HOST",
            "value": "localhost",
            "public": True
        }]
        response_mock = Mock()
        response_mock.json.return_value = expected
        get.return_value = response_mock

        request = RequestFactory().get("/")
        request.session = {"tsuru_token": "admin"}

        app_detail = AppDetail()
        app_detail.request = request
        envs = app_detail.get_envs("appname")

        self.assertListEqual(envs, expected)
        url = '{}/apps/appname/env'.format(settings.TSURU_HOST)
        get.assert_called_with(url, headers={'authorization': 'admin'})