Exemple #1
0
    def test_http_wrong_status_user(self):
        """Test if an empty user is returned when the http status is not 200"""

        client = LaunchpadClient("mydistribution",
                                 consumer_key=CONSUMER_KEY,
                                 api_token=OAUTH_TOKEN,
                                 package="mypackage")
        with self.assertRaises(requests.exceptions.HTTPError):
            _ = client.user("user1")
    def test_http_wrong_status_user(self):
        """Test if an empty user is returned when the http status is not 200, 404, 410"""

        httpretty.register_uri(httpretty.GET,
                               LAUNCHPAD_API_URL + "/~user1",
                               body="",
                               status=500)

        client = LaunchpadClient("mydistribution", package="mypackage")
        with self.assertRaises(requests.exceptions.HTTPError):
            _ = client.user("user1")
    def test_user_not_retrieved(self):
        """Test user API call"""

        httpretty.register_uri(httpretty.GET,
                               LAUNCHPAD_API_URL + "/~user-not",
                               body="",
                               status=404)

        client = LaunchpadClient("mydistribution", package="mypackage")

        user_retrieved = client.user("user-not")
        self.assertEqual(user_retrieved, "{}")
    def test_user(self):
        """Test user API call"""

        user = read_file('data/launchpad/launchpad_user_1')
        httpretty.register_uri(httpretty.GET,
                               LAUNCHPAD_API_URL + "/~user",
                               body=user,
                               status=200)

        client = LaunchpadClient("mydistribution", package="mypackage")
        user_retrieved = client.user("user")

        self.assertDictEqual(json.loads(user_retrieved), json.loads(user))
Exemple #5
0
    def test_http_wrong_status_user(self):
        """Test if an empty user is returned when the http status is not 200"""

        client = LaunchpadClient("mydistribution", package="mypackage")
        with self.assertRaises(requests.exceptions.HTTPError):
            _ = client.user("user1")