def test_create(self, mock_glclient, mock_ksclient):
        mock_glclient().images.get().checksum = '1234abc'
        mock_glclient().images.get().size = 100

        login_args = {'username': '******',
                      'password': '******',
                      'tenant_name': 'test-tenant',
                      'auth_url': 'http://auth.url/blah'}

        ou = OpenstackUtils(**login_args)
        image_filename = 'common/test/data/cirros-0.3.2-x86_64-disk.img'
        ou.create_image(image_filename, 'fake-repoid', name='some name',
                        checksum='1234abc', size=100)

        # test with bad checksum
        try:
            ou.create_image(image_filename, 'fake-repoid', name='some name',
                            checksum='1234abcdef', size=100)
            self.assertTrue(False, "should not get here, exception not thrown")
        except RuntimeError:
            pass

        # test with bad size
        try:
            ou.create_image(image_filename, 'fake-repoid', name='some name',
                            checksum='1234abc', size=999)
            self.assertTrue(False, "should not get here, exception not thrown")
        except RuntimeError:
            pass
Ejemplo n.º 2
0
    def test_create(self, mock_glclient, mock_ksclient):
        mock_glclient().images.get().checksum = '1234abc'
        mock_glclient().images.get().size = 100

        login_args = {
            'username': '******',
            'password': '******',
            'tenant_name': 'test-tenant',
            'auth_url': 'http://auth.url/blah'
        }

        ou = OpenstackUtils(**login_args)
        image_filename = 'common/test/data/cirros-0.3.2-x86_64-disk.img'
        ou.create_image(image_filename,
                        'fake-repoid',
                        name='some name',
                        checksum='1234abc',
                        size=100)

        # test with bad checksum
        try:
            ou.create_image(image_filename,
                            'fake-repoid',
                            name='some name',
                            checksum='1234abcdef',
                            size=100)
            self.assertTrue(False, "should not get here, exception not thrown")
        except RuntimeError:
            pass

        # test with bad size
        try:
            ou.create_image(image_filename,
                            'fake-repoid',
                            name='some name',
                            checksum='1234abc',
                            size=999)
            self.assertTrue(False, "should not get here, exception not thrown")
        except RuntimeError:
            pass