def test_releases(self):
        """Test releases API call"""

        http_requests = setup_http_server()

        client = PuppetForgeClient(PUPPET_FORGE_URL, max_items=2)

        # Call API
        releases = client.releases('norisnetwork', 'ceph')
        result = [release for release in releases]

        self.assertEqual(len(result), 1)

        expected = [
            {
                'limit': ['2'],
                'module': ['norisnetwork-ceph'],
                'show_deleted': ['true'],
                'sort_by': ['release_date']
            }
        ]

        self.assertEqual(len(http_requests), 1)

        for x in range(0, len(http_requests)):
            req = http_requests[x]
            self.assertEqual(req.method, 'GET')
            self.assertRegex(req.path, '/v3/releases')
            self.assertDictEqual(req.querystring, expected[x])
    def test_modules(self):
        """Test modules API call"""

        http_requests = setup_http_server()

        client = PuppetForgeClient(PUPPET_FORGE_URL, max_items=2)

        # Call API
        modules = client.modules()
        result = [module for module in modules]

        self.assertEqual(len(result), 2)

        expected = [
            {
                'limit': ['2'],
                'sort_by': ['latest_release']
            },
            {
                'limit': ['2'],
                'offset': ['2'],
                'sort_by': ['latest_release']
            },
        ]

        self.assertEqual(len(http_requests), 2)

        for x in range(0, len(http_requests)):
            req = http_requests[x]
            self.assertEqual(req.method, 'GET')
            self.assertRegex(req.path, '/v3/modules')
            self.assertDictEqual(req.querystring, expected[x])
示例#3
0
    def test_init(self):
        """Test initialization"""

        client = PuppetForgeClient(PUPPET_FORGE_URL, max_items=2)
        self.assertEqual(client.base_url, PUPPET_FORGE_URL)
        self.assertEqual(client.max_items, 2)
        self.assertTrue(client.ssl_verify)

        client = PuppetForgeClient(PUPPET_FORGE_URL, ssl_verify=False)
        self.assertEqual(client.base_url, PUPPET_FORGE_URL)
        self.assertEqual(client.max_items, 100)
        self.assertFalse(client.ssl_verify)
    def test_user(self):
        """Test user API call"""

        http_requests = setup_http_server()

        client = PuppetForgeClient(PUPPET_FORGE_URL, max_items=2)

        # Call API
        _ = client.user('norisnetwork')

        self.assertEqual(len(http_requests), 1)

        req = http_requests[0]
        self.assertEqual(req.method, 'GET')
        self.assertRegex(req.path, '/v3/users/norisnetwork')
        self.assertDictEqual(req.querystring, {})
    def test_init(self):
        """Test initialization"""

        client = PuppetForgeClient(PUPPET_FORGE_URL, max_items=2)
        self.assertEqual(client.base_url, PUPPET_FORGE_URL)
        self.assertEqual(client.max_items, 2)