def test_deploy_so_sanity(self):
        # initialization
        kind = Kind('http://schemas.mobile-cloud-networking.eu/occi/sm#',
                    'myservice',
                    title='Test Service',
                    attributes={'mcn.test.attribute1': 'immutable'},
                    related=[Resource.kind],
                    actions=[])
        entity = Resource('my-id', kind, None)
        entity.extras = {}
        host = 'test.mcn.org:8888/myservice'
        entity.extras['host'] = host
        extras = {}
        extras['token'] = 'test_token'
        extras['tenant_name'] = 'test_tenantname'
        body_content = '123456789'
        httpretty.register_uri(httpretty.POST,
                               'http://' + host + '/action=deploy',
                               status=200,
                               body=body_content,
                               content_type='text/occi')

        # Test method
        self.som._SOManager__deploy_so(entity, extras)

        # Asserts
        self.assertEqual(entity.extras['stack_id'], body_content)
    def test_init_so(self):
        # initialization
        kind = Kind('http://schemas.mobile-cloud-networking.eu/occi/sm#',
                    'myservice',
                    title='Test Service',
                    attributes={'mcn.test.attribute1': 'immutable'},
                    related=[Resource.kind],
                    actions=[])
        entity = Resource('my-id', kind, None)
        entity.extras = {}
        host = 'localhost:8888/myservice'
        entity.extras['host'] = host
        extras = {}
        extras['token'] = 'test_token'
        extras['tenant_name'] = 'test_tenantname'
        httpretty.register_uri(httpretty.POST,
                               'http://' + host + '/action=init',
                               status=200,
                               content_type='text/occi')

        # Test method
        self.som._SOManager__init_so(entity, extras)

        # Asserts
        sent_headers = httpretty.last_request().headers
        self.assertEqual(sent_headers['X-Auth-Token'], 'test_token')
        self.assertEqual(sent_headers['X-Tenant-Name'], 'test_tenantname')
Ejemplo n.º 3
0
    def test_deploy_so_failure(self):
        # Initialization
        kind = Kind('http://schemas.mobile-cloud-networking.eu/occi/sm#',
                    'myservice',
                    title='Test Service',
                    attributes={'mcn.test.attribute1': 'immutable'},
                    related=[Resource.kind],
                    actions=[])
        entity = Resource('my-id', kind, None)
        entity.extras = {}
        host = 'test.mcn.org:8888/myservice'
        entity.extras['host'] = host
        extras = {}
        extras['token'] = 'test_token'
        extras['tenant_name'] = 'test_tenantname'
        body_content = 'Please initialize SO with token and tenant first.'
        httpretty.register_uri(httpretty.POST,
                               'http://' + host + '/action=deploy',
                               status=200,
                               body=body_content,
                               content_type='text/occi')

        # Test method and Assert exception
        self.assertRaises(Exception, self.som._SOManager__deploy_so,
                          (entity, extras))
Ejemplo n.º 4
0
    def test_deploy_so_sanity(self):
        # initialization
        kind = Kind('http://schemas.mobile-cloud-networking.eu/occi/sm#',
                    'myservice',
                    title='Test Service',
                    attributes={'mcn.test.attribute1': 'immutable'},
                    related=[Resource.kind],
                    actions=[])
        entity = Resource('my-id', kind, None)
        entity.extras = {}
        host = 'test.mcn.org:8888/myservice'
        entity.extras['host'] = host
        extras = {}
        extras['token'] = 'test_token'
        extras['tenant_name'] = 'test_tenantname'
        body_content = '123456789'
        httpretty.register_uri(httpretty.POST,
                               'http://' + host + '/action=deploy',
                               status=200,
                               body=body_content,
                               content_type='text/occi')

        # Test method
        self.som._SOManager__deploy_so(entity, extras)

        # Asserts
        self.assertEqual(entity.extras['stack_id'], body_content)
Ejemplo n.º 5
0
    def test_init_so(self):
        # initialization
        kind = Kind('http://schemas.mobile-cloud-networking.eu/occi/sm#',
                    'myservice',
                    title='Test Service',
                    attributes={'mcn.test.attribute1': 'immutable'},
                    related=[Resource.kind],
                    actions=[])
        entity = Resource('my-id', kind, None)
        entity.extras = {}
        host = 'localhost:8888/myservice'
        entity.extras['host'] = host
        extras = {}
        extras['token'] = 'test_token'
        extras['tenant_name'] = 'test_tenantname'
        httpretty.register_uri(httpretty.POST,
                               'http://' + host + '/action=init',
                               status=200,
                               content_type='text/occi')

        # Test method
        self.som._SOManager__init_so(entity, extras)

        # Asserts
        sent_headers = httpretty.last_request().headers
        self.assertEqual(sent_headers['X-Auth-Token'], 'test_token')
        self.assertEqual(sent_headers['X-Tenant-Name'], 'test_tenantname')
    def test_deploy_so_failure(self):
        # Initialization
        kind = Kind('http://schemas.mobile-cloud-networking.eu/occi/sm#',
                    'myservice',
                    title='Test Service',
                    attributes={'mcn.test.attribute1': 'immutable'},
                    related=[Resource.kind],
                    actions=[])
        entity = Resource('my-id', kind, None)
        entity.extras = {}
        host = 'test.mcn.org:8888/myservice'
        entity.extras['host'] = host
        extras = {}
        extras['token'] = 'test_token'
        extras['tenant_name'] = 'test_tenantname'
        body_content = 'Please initialize SO with token and tenant first.'
        httpretty.register_uri(httpretty.POST,
                               'http://' + host + '/action=deploy',
                               status=200,
                               body=body_content,
                               content_type='text/occi')

        # Test method and Assert exception
        self.assertRaises(Exception, self.som._SOManager__deploy_so, (entity, extras))