def test_copy_from_used(self):
        class LegacyFakeArg(object):
            def __init__(self, fields):
                self.fields = fields
                self.dry_run = False
                self.verbose = False

        def images_create(**kwargs):
            class FakeImage():
                id = "ThisiSanID"
            self.assertNotEqual(kwargs['data'], sys.stdin)
            return FakeImage()

        self.gc.images.create = images_create
        args = LegacyFakeArg(["copy_from=http://somehost.com/notreal.qcow"])
        legacy_shell.do_add(self.gc, args)
    def test_do_add_without_dry_run(self):
        gc = client.Client('1', 'http://is.invalid')

        class FakeImage():
            fields = ['name=test',
                      'status=active',
                      'is_public=True',
                      'id=test',
                      'protected=False',
                      'min_disk=10',
                      'container_format=ovi',
                      'status=active',
                      'size=256',
                      'location=test',
                      'checksum=1024',
                      'owner=test_user']
            dry_run = False
            id = 'test'
            verbose = False

        test_args = FakeImage()
        with mock.patch.object(gc.images, 'create') as mocked_create:
            mocked_create.return_value = FakeImage()
            actual = test_shell.do_add(gc, test_args)
            self.assertEqual(0, actual)
Example #3
0
    def test_copy_from_used(self):
        class LegacyFakeArg(object):
            def __init__(self, fields):
                self.fields = fields
                self.dry_run = False
                self.verbose = False

        def images_create(**kwargs):
            class FakeImage():
                id = "ThisiSanID"
            self.assertNotEqual(kwargs['data'], sys.stdin)
            return FakeImage()

        self.gc.images.create = images_create
        args = LegacyFakeArg(["copy_from=http://somehost.com/notreal.qcow"])
        legacy_shell.do_add(self.gc, args)
    def test_do_add_error(self):
        class FakeClient():
            endpoint = 'http://is.invalid'

        class args:
            fields = 'name'

        actual = test_shell.do_add(FakeClient(), args)
        self.assertEqual(1, actual)
Example #5
0
    def test_do_add(self):
        gc = client.Client('1', 'http://is.invalid')

        class FakeImage():
            fields = [
                'name=test', 'status=active', 'id=test', 'is_public=True',
                'protected=False', 'min_disk=10', 'container_format=ovi',
                'status=active'
            ]
            dry_run = True

        test_args = FakeImage()
        actual = test_shell.do_add(gc, test_args)
        self.assertEqual(0, actual)
Example #6
0
    def test_do_add_with_image_meta(self):
        gc = client.Client('1', 'http://is.invalid')

        class FakeImage():
            fields = [
                'name=test', 'status=active', 'is_public=True', 'id=test',
                'protected=False', 'min_disk=10', 'container_format=ovi',
                'status=active', 'size=256', 'location=test', 'checksum=1024',
                'owner=test_user'
            ]
            dry_run = True

        test_args = FakeImage()
        actual = test_shell.do_add(gc, test_args)
        self.assertEqual(0, actual)
    def test_do_add(self):
        gc = client.Client('1', 'http://is.invalid')

        class FakeImage():
            fields = ['name=test',
                      'status=active',
                      'id=test',
                      'is_public=True',
                      'protected=False',
                      'min_disk=10',
                      'container_format=ovi',
                      'status=active']
            dry_run = True

        test_args = FakeImage()
        actual = test_shell.do_add(gc, test_args)
        self.assertEqual(0, actual)
    def test_do_add_with_image_meta(self):
        gc = client.Client('1', 'http://is.invalid')

        class FakeImage():
            fields = ['name=test',
                      'status=active',
                      'is_public=True',
                      'id=test',
                      'protected=False',
                      'min_disk=10',
                      'container_format=ovi',
                      'status=active',
                      'size=256',
                      'location=test',
                      'checksum=1024',
                      'owner=test_user']
            dry_run = True

        test_args = FakeImage()
        actual = test_shell.do_add(gc, test_args)
        self.assertEqual(0, actual)