Пример #1
0
    def mock_app(self, app):
        expected_response = json.dumps({
            "name":
            app,
            "ip":
            "{}.tsuru.io".format(app),
            "platform":
            "php",
            "units": [
                {
                    "Address": {
                        "Host": "10.10.10.10"
                    },
                    "ID": "app1/0",
                    "Status": "stopped"
                },
            ],
            "pool":
            "mypool",
        })

        httpretty.register_uri(httpretty.GET,
                               TsuruClientUrls.get_app_url(app),
                               body=expected_response,
                               content_type="application/json",
                               status=200)
Пример #2
0
 def test_get_app_with_success(self):
     app_name = 'morfeu'
     expected_response = self.__expected_unit(name=app_name)
     httpretty.register_uri(httpretty.GET, TsuruClientUrls.get_app_url(app_name),
                            body=expected_response,
                            content_type="application/json",
                            status=200)
     self.assertEqual(self.tsuru_client.get_app(app_name=app_name), json.loads(expected_response))
Пример #3
0
    def test_get_app_with_timeout(self):
        def raiseTimeout(request, uri, headers):
            raise requests.Timeout('Connection timed out.')

        app_name = 'morfeu'
        httpretty.register_uri(httpretty.GET, TsuruClientUrls.get_app_url(app_name),
                               body=raiseTimeout,
                               content_type="application/json",
                               status=500)
        self.assertEqual(self.tsuru_client.get_app(app_name=app_name), json.loads("{}"))
Пример #4
0
 def test_get_app_with_failure(self):
     app_name = "morfeu"
     expected_response = self.__expected_unit(name=app_name)
     httpretty.register_uri(
         httpretty.GET,
         TsuruClientUrls.get_app_url(app_name),
         body=expected_response,
         content_type="application/json",
         status=500,
     )
     self.assertEqual(self.tsuru_client.get_app(app_name=app_name), json.loads("{}"))
Пример #5
0
    def mock_app(self, app):
        expected_response = json.dumps({
            "name": app,
            "ip": "{}.tsuru.io".format(app),
            "platform": "php",
            "units": [
                {"Address": {"Host": "10.10.10.10"}, "ID": "app1/0", "Status": "stopped"},
            ],
            "pool": "mypool",
        })

        httpretty.register_uri(httpretty.GET, TsuruClientUrls.get_app_url(app),
                               body=expected_response, content_type="application/json", status=200)
Пример #6
0
    def test_get_app_with_timeout(self):
        def raiseTimeout(request, uri, headers):
            raise requests.Timeout("Connection timed out.")

        app_name = "morfeu"
        httpretty.register_uri(
            httpretty.GET,
            TsuruClientUrls.get_app_url(app_name),
            body=raiseTimeout,
            content_type="application/json",
            status=500,
        )
        self.assertEqual(self.tsuru_client.get_app(app_name=app_name), json.loads("{}"))