Beispiel #1
0
    def test_get_url_with_https(self):
        registry = Registry()

        registry.set_credentials('username', 'password')

        url = registry.get_url('_catalog')

        self.assertEqual(url, 'https://localhost:5000/v2/_catalog')
Beispiel #2
0
    def test_delete_tag(self, mock_obj):
        registry = Registry()

        registry.delete_tag('image', 'tag')
        self.assertIn(
            mock.call(
                registry.get_url('{0}/manifests/{1}'.format('image', 'tag')),
                **registry.http_params), mock_obj.call_args_list)
Beispiel #3
0
    def test_get_tags(self, mock_obj):
        registry = Registry()

        tags = registry.get_tags('image')

        self.assertEqual(tags, ['latest', '1.0.0'])
        self.assertIn(
            mock.call(registry.get_url('image/tags/list'),
                      **registry.http_params), mock_obj.call_args_list)
Beispiel #4
0
    def test_get_images_with_connection_error(self, mock_obj):
        registry = Registry()

        self.assertRaises(error.ConnectionError, registry.get_images)
        self.assertIn(
            mock.call(registry.get_url('_catalog'),
                      **registry.http_params,
                      params=registry.get_pagination(10, None)),
            mock_obj.call_args_list)
Beispiel #5
0
    def test_get_inexistent_image(self, mock_obj):
        registry = Registry()

        self.assertRaises(error.NotFoundError, registry.get_images)

        self.assertIn(
            mock.call(registry.get_url('_catalog'),
                      **registry.http_params,
                      params=registry.get_pagination(10, None)),
            mock_obj.call_args_list)
Beispiel #6
0
    def test_get_images(self, mock_obj):
        registry = Registry()

        images, link = registry.get_images()

        self.assertEqual(images, ['hello-world', 'postgres'])
        self.assertEqual(link, '?n=2&last=b')
        self.assertIn(
            mock.call(registry.get_url('_catalog'),
                      **registry.http_params,
                      params=registry.get_pagination(10, None)),
            mock_obj.call_args_list)
Beispiel #7
0
    def test_get_manifests(self, mock_obj):
        registry = Registry()

        manifests_data = registry.get_manifests('image', 'tag')

        self.assertEqual(
            manifests_data, {
                'manifests': {},
                'digest':
                'sha256:9e81e4ce4899448e5e7aea69a72dfd1df989a7a0fe7365ad63be1133f05acf10'
            })
        self.assertIn(
            mock.call(
                registry.get_url('{0}/manifests/{1}'.format('image', 'tag')),
                **registry.http_params), mock_obj.call_args_list)
Beispiel #8
0
    def test_get_url_with_http(self):
        registry = Registry()

        url = registry.get_url('_catalog')

        self.assertEqual(url, 'http://localhost:5000/v2/_catalog')
Beispiel #9
0
    def test_get_url_withouth_param(self):
        registry = Registry()

        url = registry.get_url()

        self.assertEqual(url, 'http://localhost:5000/v2')