def test_disable_user(username):
    """ test administrator to disable a ueser by giving user name """

    bt = BaseTest()
    user = bt.get_user_by_name(username)

    if(user == None):
        return 3

    user_id = user['id']

    endpoint = bt.get_service_endpoint('keystone')
    endpoint = endpoint + '/users/' + user_id + '/enabled'

    headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
    body = {
            'user': {
                'enabled': False,
            },
        }

    response, content = bt.put(endpoint, headers=headers, body=json.dumps(body))    

    if(response['status'] != '200'):
        return 1

    return 0
def upload_glance_remote_image(file_path, disk_format='raw', container_format='bare', image_name='jeos_remote', timeout=60):
    """ Upload remote glance image file """

    baseTest = BaseTest()
    token = baseTest.token
    endpoint = baseTest.get_service_endpoint('glance')
    endpoint = endpoint.rsplit('/', 1)[0]

    glance = Client('1', endpoint, token)

    meta = {
        'name': image_name,
        'is_public': True,
        'disk_format': disk_format,
        'container_format': container_format,
        'copy_from': file_path,
    }

    start = int(time.time())
    results = glance.images.create(**meta)

    image_id = results.id
   
    ret = baseTest._wait_for_image_status(image_id, 'ACTIVE', timeout)

    image_file = "/var/lib/glance/images/" + image_id
    # Ensure the image has been realy stroed in the glance location
    if ret == 0 and os.path.isfile(image_file):
        # clean the created image
        baseTest.clean_images(image_name)
        return 0
    return 1
Пример #3
0
def test_nova_change_quota_by_tenantname(tenant_name, key, value):
    """ test to change quotas of a tenant with a key and value """

    support_keys = ('metadata_items', 'injected_file_content_bytes', 'injected_files', 'gigabytes', 'ram',
                    'floating_ips',   'security_group_rules',        'instances',      'volumes',   'cores',
                    'id',             'security_groups')

    if key not in support_keys:
        return 2

    headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}

    bt = BaseTest()
    endpoint = bt.get_service_endpoint('nova')
    tenant = bt.get_tenant_by_name(tenant_name)

    body = {
        'quota_set': {
            key: value
        }
    }

    endpoint = endpoint + '/os-quota-sets/' + tenant['id']
    #response, content = bt.get(endpoint)
    
    response, content = bt.put(endpoint, headers, body=json.dumps(body))

    if response['status'] == '200':
        return 0
    return 1
def test_user_reenable(username):
    """ test enable a user who was disabled """

    bt = BaseTest()
    user = bt.get_user_by_name(username)

    if (user == None):
        return 3

    user_id = user['id']

    endpoint = bt.get_service_endpoint('keystone')
    endpoint = endpoint + '/users/' + user_id + '/enabled'

    headers = {
        'Content-Type': 'application/json',
        'Accept': 'application/json'
    }
    body = {
        'user': {
            'enabled': True,
        },
    }

    response, content = bt.put(endpoint,
                               headers=headers,
                               body=json.dumps(body))

    if (response['status'] != '200'):
        print "Reenable user failed!"
        return 1

    return 0
def test_nova_launch_instance_cycle(username, password, tenant_name, image_name, flavor_id, cycle_number, timeout):
    """ test a user to teminate a creating server for times in a specific time period """

    user_bt = BaseTest(username, password, tenant_name)
    image = user_bt.get_image_by_name(image_name)

    if image == None:
        return 3

    image_id = image['id']

    server_name = 'test_cycle'

    for i in range(0, cycle_number):
        resp, server = user_bt.servers_client.create_server(server_name, image_id, flavor_id)
        resp, body = user_bt.servers_client.delete_server(server['id'])

        start = int(time.time())
        while(server != None):
            time.sleep(5)
            timed_out = int(time.time()) - start >= timeout

            if timed_out:
                return 1
            
            server = user_bt.get_server_by_name(server_name)

    return 0
def change_user_password(username, password, tenant_name, newpassword):
    """ Change a user can change its password """

    bt = BaseTest()
    user = bt.get_user_by_name(username)
    if user == None:
        return 3

    headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}

    endpoint = bt.get_service_endpoint('keystone')
    endpoint = endpoint + '/users/' + user['id']

    bt_user = BaseTest(username, password, tenant_name)
    
    post_body = {
                'user': {
                    'id': user['id'],
                    'password': newpassword,
                }
            }

    response, content = bt_user.put(endpoint, headers=headers, body=json.dumps(post_body))

    if(response['status'] != '200'):
        return 1
    return 0
Пример #7
0
def test_create_tenant_by_name(name):
    """ test administrator to create a tenant whose name is the giving name """
    bt = BaseTest()
    endpoint = bt.get_service_endpoint('keystone')
    endpoint = endpoint + '/tenants'
    headers = {
        'Content-Type': 'application/json',
        'Accept': 'application/json'
    }

    body = {
        "tenant": {
            "name": name,
            "description": "test create tenant",
            "enabled": "true",
        },
    }

    response, content = bt.post(endpoint,
                                headers=headers,
                                body=json.dumps(body))

    if (response['status'] == '200'):
        return 0
    return 1
def test_nova_launch_instance_multiple(username, password, tenant_name, image_name, flavor_id, number):
    """ test a user to create multiple servers with a same image """

    bt_user = BaseTest(username, password, tenant_name)
    image = bt_user.get_image_by_name(image_name)

    if image == None:
        return 3

    image_id = image['id']

    server_ids = list()
    for i in range(0, number):
        server_name = 'test_' + str(i)
        resp, server = bt_user.servers_client.create_server(server_name, image_id, flavor_id)
        server_ids.append(server['id'])

    ret = 0
    for server_id in server_ids:
        ret += bt_user._wait_for_server_status(server_id, 'ACTIVE', 180)

    if(ret > 0):
        return 1

    bt_user.clean_servers('test_', True)
    return 0
def test_user_reenable(username):
    """ test enable a user who was disabled """

    bt = BaseTest()
    user = bt.get_user_by_name(username)

    if(user == None):
        return 3

    user_id = user['id']

    endpoint = bt.get_service_endpoint('keystone')
    endpoint = endpoint + '/users/' + user_id + '/enabled'

    headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
    body = {
            'user': {
                'enabled': True,
            },
        }

    response, content = bt.put(endpoint, headers=headers, body=json.dumps(body));
    
    if(response['status'] != '200'):
        print "Reenable user failed!"
        return 1

    return 0
Пример #10
0
    def test_list_users_query(self):
        

        
    
        map = RequestMap()
        map.set("max", "10")
        
        
        response = User.listByCriteria(map)

        ignoreAsserts = []
        
        self.customAssertEqual(ignoreAsserts, "website", response.get("list[0].website"),"hildegard.org")
        self.customAssertEqual(ignoreAsserts, "address.instructions.doorman", response.get("list[0].address.instructions.doorman"),"true")
        self.customAssertEqual(ignoreAsserts, "address.instructions.text", response.get("list[0].address.instructions.text"),"some delivery instructions text")
        self.customAssertEqual(ignoreAsserts, "address.city", response.get("list[0].address.city"),"New York")
        self.customAssertEqual(ignoreAsserts, "address.postalCode", response.get("list[0].address.postalCode"),"10577")
        self.customAssertEqual(ignoreAsserts, "address.id", response.get("list[0].address.id"),"1")
        self.customAssertEqual(ignoreAsserts, "address.state", response.get("list[0].address.state"),"NY")
        self.customAssertEqual(ignoreAsserts, "address.line1", response.get("list[0].address.line1"),"2000 Purchase Street")
        self.customAssertEqual(ignoreAsserts, "phone", response.get("list[0].phone"),"1-770-736-8031")
        self.customAssertEqual(ignoreAsserts, "name", response.get("list[0].name"),"Joe Bloggs")
        self.customAssertEqual(ignoreAsserts, "id", response.get("list[0].id"),"1")
        self.customAssertEqual(ignoreAsserts, "email", response.get("list[0].email"),"*****@*****.**")
        self.customAssertEqual(ignoreAsserts, "username", response.get("list[0].username"),"jbloggs")
        

        BaseTest.putResponse("list_users_query", response.get("list[0]"))
def test_tenant_disable(tenant_name):
    """ test disable a tenant by name given """
    
    bt = BaseTest()
    tenant = bt.get_tenant_by_name(tenant_name)

    if(tenant == None):
        return 3

    tenant_id = tenant['id']

    endpoint = bt.get_service_endpoint('keystone')
    endpoint = endpoint + '/tenants/' + tenant_id

    body = {
                "tenant": {
                    "enabled": False,
                },
    }

    headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}

    response, content = bt.post(endpoint, headers=headers, body=json.dumps(body))

    if(response['status'] == '200'):
        return 0
    return 1
Пример #12
0
	def test_singleton_fgh_within_epsilon(self):
		x, y, _ = BaseTest.get_data()
		imgpe = iMGPE(x, y, initial_k=6)
		BaseTest.divide_data(imgpe, singleton=True)
		BaseTest.prepare_kernels(imgpe)

		TINY = 1.25e-7
		for gating_phi in [0.5, 1, 2, 4]:
			imgpe.gating_phi = gating_phi

			old_phi = imgpe.gating_phi
			imgpe.compute_gating_distances()
			imgpe.compute_gating_distances_class()

			_, analytic_g, analytic_h = imgpe.log_posterior_1st_2nd()

			imgpe.gating_phi = np.exp(np.log(old_phi) - TINY)
			imgpe.compute_gating_distances()
			imgpe.compute_gating_distances_class()
			lower_f, lower_g, _ = imgpe.log_posterior_1st_2nd()

			imgpe.gating_phi = np.exp(np.log(old_phi) + TINY)
			imgpe.compute_gating_distances()
			imgpe.compute_gating_distances_class()
			upper_f, upper_g, _ = imgpe.log_posterior_1st_2nd()

			central_diff_g = (upper_f - lower_f) / (2 * TINY)
			central_diff_h = (upper_g - lower_g) / (2 * TINY)

			self.assertAlmostEqual(analytic_g, central_diff_g, places=5)
			self.assertAlmostEqual(analytic_h, central_diff_h, places=5)
Пример #13
0
    def test_get_user_query(self):
        

        

        id = ""
        map = RequestMap()
        map.set("min", "1")
        map.set("max", "10")
        
        map.set("id", BaseTest.resolveResponseValue("create_user.id"));
        
        response = User.read(id,map)

        ignoreAsserts = []
        
        self.customAssertEqual(ignoreAsserts, "website", response.get("website"),"hildegard.org")
        self.customAssertEqual(ignoreAsserts, "address.instructions.doorman", response.get("address.instructions.doorman"),"true")
        self.customAssertEqual(ignoreAsserts, "address.instructions.text", response.get("address.instructions.text"),"some delivery instructions text")
        self.customAssertEqual(ignoreAsserts, "address.city", response.get("address.city"),"New York")
        self.customAssertEqual(ignoreAsserts, "address.postalCode", response.get("address.postalCode"),"10577")
        self.customAssertEqual(ignoreAsserts, "address.id", response.get("address.id"),"1")
        self.customAssertEqual(ignoreAsserts, "address.state", response.get("address.state"),"NY")
        self.customAssertEqual(ignoreAsserts, "address.line1", response.get("address.line1"),"2000 Purchase Street")
        self.customAssertEqual(ignoreAsserts, "phone", response.get("phone"),"1-770-736-8031")
        self.customAssertEqual(ignoreAsserts, "name", response.get("name"),"Joe Bloggs")
        self.customAssertEqual(ignoreAsserts, "id", response.get("id"),"1")
        self.customAssertEqual(ignoreAsserts, "email", response.get("email"),"*****@*****.**")
        self.customAssertEqual(ignoreAsserts, "username", response.get("username"),"jbloggs")
        

        BaseTest.putResponse("get_user_query", response)
def test_create_user_by_name(username, password, tenant_name):
    """ test administrator to create a user whose name is the giving name"""
    bt = BaseTest()
    endpoint = bt.get_service_endpoint('keystone')
    endpoint = endpoint + '/users'
    headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}

    tenant = bt.get_tenant_by_name(tenant_name)
    user = bt.get_user_by_name(username)

    if tenant == None or user != None:
        return 3

    body = {
            'user': {
                'name': username,
                'password': password,
                'tenantId': tenant['id'],
                'email': '*****@*****.**',
                'enabled': True
            }
        }

    response, content = bt.post(endpoint, headers=headers, body=json.dumps(body))

    if(response['status'] == '200'):
        return 0
    return 1
def test_disable_user(username):
    """ test administrator to disable a ueser by giving user name """

    bt = BaseTest()
    user = bt.get_user_by_name(username)

    if (user == None):
        return 3

    user_id = user['id']

    endpoint = bt.get_service_endpoint('keystone')
    endpoint = endpoint + '/users/' + user_id + '/enabled'

    headers = {
        'Content-Type': 'application/json',
        'Accept': 'application/json'
    }
    body = {
        'user': {
            'enabled': False,
        },
    }

    response, content = bt.put(endpoint,
                               headers=headers,
                               body=json.dumps(body))

    if (response['status'] != '200'):
        return 1

    return 0
def test_tenant_reenable(tenant_name):
    """ test enable a disabled tenant """

    bt = BaseTest()
    tenant = bt.get_tenant_by_name(tenant_name)

    if (tenant == None):
        return 3

    tenant_id = tenant['id']

    endpoint = bt.get_service_endpoint('keystone')
    endpoint = endpoint + '/tenants/' + tenant_id

    body = {
        "tenant": {
            "enabled": True,
        },
    }

    headers = {
        'Content-Type': 'application/json',
        'Accept': 'application/json'
    }

    response, content = bt.post(endpoint,
                                headers=headers,
                                body=json.dumps(body))

    if (response['status'] == '200'):
        return 0
    return 1
Пример #17
0
    def navigate_to_page(self):
        """Navigate to the drawer swipe until it gets to desired page."""
        BaseTest.navigate_to_page(self)
        tab_view = TabViewPage(self.driver)

        for __ in range(self.get_page_index()):
            tab_view.go_to_next_page()
            sleep(self.ANIMATION_DELAY)
Пример #18
0
    def setUpClass(cls):
        BaseTest.initEnvironment(cls)
        # log in
        BaseTest.login(cls)

        # wait for home page loaded
        cls.home_page = HomePage(cls.driver)
        cls.home_page.check_if_loaded()
Пример #19
0
	def test_singleton_phi_modified(self):
		x, y, _ = BaseTest.get_data()
		imgpe = iMGPE(x, y, initial_k=6, initial_gating_phi=0.1)
		BaseTest.divide_data(imgpe, singleton=True)
		BaseTest.prepare_kernels(imgpe)

		pre_c, pre_class_indices, pre_param_vals = BaseTest.extract_sample_state(imgpe)
		pre_priors = BaseTest.extract_prior_state(imgpe)
		pre_phi = imgpe.gating_phi

		np.random.seed(1008)
		imgpe.hmh_gating_phi()

		post_c, post_class_indices, post_param_vals = BaseTest.extract_sample_state(imgpe)
		post_priors = BaseTest.extract_prior_state(imgpe)
		post_phi = imgpe.gating_phi

		self.assertEqual(len(pre_c), len(post_c))
		for pre_c_i, post_c_i in zip(pre_c, post_c):
			self.assertEqual(pre_c_i, post_c_i)

		self.assertEqual(len(pre_class_indices), len(post_class_indices))
		for pre_class_indices_j, post_class_indices_j in zip(pre_class_indices, post_class_indices):
			self.assertTrue(np.array_equal(pre_class_indices_j, post_class_indices_j))

		self.assertEqual(pre_param_vals, post_param_vals)
		self.assertEqual(pre_priors, post_priors)

		self.assertNotEqual(pre_phi, post_phi)
Пример #20
0
	def test_singleton_different_class(self):
		x, y, _ = BaseTest.get_data()
		imgpe = iMGPE(x, y, initial_k=6)
		BaseTest.divide_data(imgpe, singleton=True)
		BaseTest.prepare_kernels(imgpe)
		target_cluster = 4
		BaseTest.boost_target_affinity(imgpe, 43, target_cluster)

		pre_c, pre_class_indices, pre_param_vals = BaseTest.extract_sample_state(imgpe)
		imgpe.gibbs(43)
		post_c, post_class_indices, post_param_vals = BaseTest.extract_sample_state(imgpe)

		self.assertEqual(len(pre_c), len(post_c))
		for index, (pre_c_i, post_c_i) in enumerate(zip(pre_c, post_c)):
			if index == 43:
				self.assertEqual(post_c_i, target_cluster - 1) # Shifted by one because target cluster is ahead
			else:
				if pre_c_i > 2:
					self.assertEqual(pre_c_i - 1, post_c_i)
				else:
					self.assertEqual(pre_c_i, post_c_i)

		pre_class_indices_compare = [pre_class_indices_j for index, pre_class_indices_j in enumerate(pre_class_indices) if index != 2 and index != target_cluster]
		post_class_indices_compare = [pre_class_indices_j for index, pre_class_indices_j in enumerate(post_class_indices) if index != target_cluster - 1]
		self.assertEqual(len(pre_class_indices) - 1, len(post_class_indices))
		for pre_class_indices_j, post_class_indices_j in zip(pre_class_indices_compare, post_class_indices_compare):
			self.assertTrue(np.array_equal(pre_class_indices_j, post_class_indices_j))
		self.assertTrue(np.array_equal(np.append(pre_class_indices[target_cluster], 43), post_class_indices[target_cluster - 1]))

		self.assertEqual(len(pre_param_vals) - 1, len(post_param_vals))
		pre_param_vals_compare = [pre_param_vals_j for index, pre_param_vals_j in enumerate(pre_param_vals) if index != 2]
		self.assertEqual(pre_param_vals_compare, post_param_vals)
Пример #21
0
	def test_singleton_hyperparams_modified(self):
		x, y, _ = BaseTest.get_data()
		imgpe = iMGPE(x, y, initial_k=6)
		BaseTest.divide_data(imgpe, singleton=True)
		BaseTest.prepare_kernels(imgpe)

		pre_c, pre_class_indices, pre_param_vals = BaseTest.extract_sample_state(imgpe)
		pre_priors = BaseTest.extract_prior_state(imgpe)
		imgpe.hmc_round()
		post_c, post_class_indices, post_param_vals = BaseTest.extract_sample_state(imgpe)
		post_priors = BaseTest.extract_prior_state(imgpe)

		self.assertEqual(len(pre_c), len(post_c))
		for pre_c_i, post_c_i in zip(pre_c, post_c):
			self.assertEqual(pre_c_i, post_c_i)

		self.assertEqual(len(pre_class_indices), len(post_class_indices))
		for pre_class_indices_j, post_class_indices_j in zip(pre_class_indices, post_class_indices):
			self.assertTrue(np.array_equal(pre_class_indices_j, post_class_indices_j))

		self.assertEqual(len(pre_param_vals), len(post_param_vals))
		for pre_param_vals_j, post_param_vals_j in zip(pre_param_vals, post_param_vals):
			self.assertEqual(len(pre_param_vals_j), len(post_param_vals_j))
			self.assertNotEqual(pre_param_vals_j, post_param_vals_j)

		self.assertEqual(pre_priors, post_priors)
def test_nocleanup_nova_instance_admin_user(username, password, tenant_name, server_name):
    """ test a uer to teminiate a server created by administrator should fail """

    bt = BaseTest()
    server = bt.get_server_by_name(server_name)

    res, meta = bt.servers_client.delete_server(server['id'])

    if res['status'] == '204':
        return 0
    return 1
def test_delete_user_nologin(username, password, tenant_name):
    """ test a user deleted can not login anymore """

    bt = BaseTest()

    try:
        bt_user = BaseTest(username, password, tenant_name)
    except exceptions.AuthenticationFailure:
        return 0

    return 1
Пример #24
0
def test_nocleanup_nova_instance_admin_user(username, password, tenant_name,
                                            server_name):
    """ test a uer to teminiate a server created by administrator should fail """

    bt = BaseTest()
    server = bt.get_server_by_name(server_name)

    res, meta = bt.servers_client.delete_server(server['id'])

    if res['status'] == '204':
        return 0
    return 1
Пример #25
0
    def setUpClass(cls):
        BaseTest.initEnvironment(cls)
        BaseTest.login(cls)

        home_page = HomePage(cls.driver)
        home_page.check_if_loaded()
        home_page.click_app("common")

        home_page.check_app_loaded()
        home_page.click_channel_link()

        cls.channel_page = ChannelPage(cls.driver)
    def test_delete_user_posts_with_mutplie_path(self):

        map = RequestMap()
        map.set("user_id", "1")
        map.set("post_id", "2")

        response = MultiplePathUserPost.deleteById("", map)
        self.assertNotEqual(response, None)

        ignoreAsserts = []

        BaseTest.putResponse("delete_user_posts_with_mutplie_path", response)
def test_nocleanup_nova_instance_admin_user(username, password, tenant_name, server_name):
    """ test a uer to teminiate a server created by administrator should fail """

    bt = BaseTest()
    server = bt.get_server_by_name(server_name)

    user_bt = BaseTest(username, password, tenant_name)

    try:
        res, meta = user_bt.servers_client.delete_server(server['id'])
    except exceptions.NotFound:
        return 0
    return 1
Пример #28
0
    def setUpClass(cls):
        BaseTest.initEnvironment(cls)
        BaseTest.login_private(cls)

        home_page = HomePage(cls.driver)
        home_page.check_if_loaded()

        home_page.click_app("my")
        home_page.check_app_loaded()
        home_page.click_order_link()

        cls.order_page = OrderPage(cls.driver)
        cls.order_page.check_orderpage_loaded()
def test_nova_launch_instance_admin(server_name, image_name, flavor_id):
    """ test a administrato to create server by uploading image file and tiny flavor """

    bt_admin = BaseTest()
    image = bt_admin.get_image_by_name(image_name)

    if image == None:
        return 3

    image_id = image['id']
    resp, server = bt_admin.servers_client.create_server(server_name, image_id, flavor_id)

    return bt_admin._wait_for_server_status(server['id'], 'ACTIVE', 180)
Пример #30
0
	def test_prior_prime(self):
		x, y, _ = BaseTest.get_data()
		imgpe = iMGPE(x, y, initial_k=29)
		BaseTest.divide_data(imgpe, singleton=True)
		BaseTest.prepare_kernels(imgpe)

		TINY = 1.25e-7
		for log_alpha in [-4, -2, -1, -0.5, 0, 0.5, 1, 2, 4]:
			analytic_1st = imgpe.log_alpha_posterior_prime(log_alpha)
			upper_prior = imgpe.log_alpha_posterior(log_alpha + TINY)
			lower_prior = imgpe.log_alpha_posterior(log_alpha - TINY)
			central_diff_1st = (upper_prior - lower_prior) / (2 * TINY)
			self.assertAlmostEqual(analytic_1st, central_diff_1st, places=5)
def test_nova_launch_instance_user(username, password, tenant_name, server_name, image_name, flavor_id):
    """ test a user to create instance by uploading image file and tiny flavor """

    user_bt = BaseTest(username, password, tenant_name)
    image = user_bt.get_image_by_name(image_name)

    if image == None:
        return 3
    image_id = image['id']

    resp, server = user_bt.servers_client.create_server(server_name, image_id, flavor_id)

    return user_bt._wait_for_server_status(server['id'], 'ACTIVE', 180)
def test_nova_launch_instance_multiimg(username, password, tenant_name,
                                       images_name, flavor_id, timeout):
    """ test a user to create multiple server with different images file """

    images_id = list()

    bt = BaseTest()
    user_bt = BaseTest(username, password, tenant_name)
    for image_name in images_name:
        image = bt.get_image_by_name(image_name)
        if (image == None):
            return 3
        images_id.append(image['id'])

    images_dict = dict(zip(images_name, images_id))

    for image_name in images_dict:
        server_name = 'jeos_' + image_name
        resp, server = user_bt.servers_client.create_server(
            server_name, images_dict[image_name], flavor_id)

        ret = user_bt._wait_for_server_status(server['id'], 'ACTIVE', timeout)
        if (ret != 0):
            return 1

    user_bt.clean_servers('jeos_', True)

    return 0
def test_cleanup_nova_instance_user(username, password, tenant_name, server_name):
    """ test a user to delete a server """

    user_bt = BaseTest(username, password, tenant_name)

    server = user_bt.get_server_by_name(server_name)
    if server == None: 
        return 3

    response, content = user_bt.clean_servers(server_name)
    if response['status'] == '204':
        return 0

    return 1
Пример #34
0
	def test_singleton_kern_to_class_match(self):
		x, y, _ = BaseTest.get_data()
		imgpe = iMGPE(x, y, initial_k=6)
		BaseTest.divide_data(imgpe, singleton=True)
		BaseTest.prepare_kernels(imgpe)

		distances_own_class = imgpe.gating_distances_own_class.copy()
		distances_own_class_recompute = []
		
		for i, (x, c) in enumerate(zip(imgpe.x, imgpe.c)):
			distance_own_class_point = sum([imgpe.gating_kern(x, x_other) for i_other, (x_other, c_other) in enumerate(zip(imgpe.x, imgpe.c)) if i_other != i and c_other == c])
			distances_own_class_recompute.append(distance_own_class_point)

		self.assertTrue(np.allclose(distances_own_class, distances_own_class_recompute))
Пример #35
0
def test_nova_launch_instance_admin(server_name, image_name, flavor_id):
    """ test a administrato to create server by uploading image file and tiny flavor """

    bt_admin = BaseTest()
    image = bt_admin.get_image_by_name(image_name)

    if image == None:
        return 3

    image_id = image['id']
    resp, server = bt_admin.servers_client.create_server(
        server_name, image_id, flavor_id)

    return bt_admin._wait_for_server_status(server['id'], 'ACTIVE', 180)
    def test_update_user_posts_with_mutplie_path(self):

        map = RequestMap()
        map.set("user_id", "1")
        map.set("post_id", "1")
        map.set("testQuery", "testQuery")
        map.set("name", "Joe Bloggs")
        map.set("username", "jbloggs")
        map.set("email", "*****@*****.**")
        map.set("phone", "1-770-736-8031")
        map.set("website", "hildegard.org")
        map.set("address.line1", "2000 Purchase Street")
        map.set("address.city", "New York")
        map.set("address.state", "NY")
        map.set("address.postalCode", "10577")

        response = MultiplePathUserPost(map).update()

        ignoreAsserts = []

        self.customAssertEqual(ignoreAsserts, "website",
                               response.get("website"), "hildegard.org")
        self.customAssertEqual(ignoreAsserts, "address.instructions.doorman",
                               response.get("address.instructions.doorman"),
                               "true")
        self.customAssertEqual(ignoreAsserts, "address.instructions.text",
                               response.get("address.instructions.text"),
                               "some delivery instructions text")
        self.customAssertEqual(ignoreAsserts, "address.city",
                               response.get("address.city"), "New York")
        self.customAssertEqual(ignoreAsserts, "address.postalCode",
                               response.get("address.postalCode"), "10577")
        self.customAssertEqual(ignoreAsserts, "address.id",
                               response.get("address.id"), "1")
        self.customAssertEqual(ignoreAsserts, "address.state",
                               response.get("address.state"), "NY")
        self.customAssertEqual(ignoreAsserts, "address.line1",
                               response.get("address.line1"),
                               "2000 Purchase Street")
        self.customAssertEqual(ignoreAsserts, "phone", response.get("phone"),
                               "1-770-736-8031")
        self.customAssertEqual(ignoreAsserts, "name", response.get("name"),
                               "Joe Bloggs")
        self.customAssertEqual(ignoreAsserts, "id", response.get("id"), "1")
        self.customAssertEqual(ignoreAsserts, "email", response.get("email"),
                               "*****@*****.**")
        self.customAssertEqual(ignoreAsserts, "username",
                               response.get("username"), "jbloggs")

        BaseTest.putResponse("update_user_posts_with_mutplie_path", response)
def test_nocleanup_nova_instance_admin_user(username, password, tenant_name,
                                            server_name):
    """ test a uer to teminiate a server created by administrator should fail """

    bt = BaseTest()
    server = bt.get_server_by_name(server_name)

    user_bt = BaseTest(username, password, tenant_name)

    try:
        res, meta = user_bt.servers_client.delete_server(server['id'])
    except exceptions.NotFound:
        return 0
    return 1
Пример #38
0
    def setUpClass(cls):
        BaseTest.initEnvironment(cls)
        # log in
        BaseTest.login(cls)

        # wait for home page loaded
        home_page = HomePage(cls.driver)
        home_page.check_if_loaded()

        home_page.click_app("common")
        home_page.check_app_loaded()

        home_page.click_order_link()
        cls.order_page = OrderPage(cls.driver)
        cls.order_page.check_orderpage_loaded()
Пример #39
0
def test_cleanup_nova_instance_user(username, password, tenant_name,
                                    server_name):
    """ test a user to delete a server """

    user_bt = BaseTest(username, password, tenant_name)

    server = user_bt.get_server_by_name(server_name)
    if server == None:
        return 3

    response, content = user_bt.clean_servers(server_name)
    if response['status'] == '204':
        return 0

    return 1
def test_user_disabled_nologin(username, password, tenant_name):
    """ test a disabled user can not to login anymore """

    bt = BaseTest()
    user = bt.get_user_by_name(username)

    if(user == None):
        return 3

    try:
        bt_user = BaseTest(username, password, tenant_name)
    except exceptions.AuthenticationFailure:
        return 0

    return 1
def test_nova_launch_instance_user(username, password, tenant_name,
                                   server_name, image_name, flavor_id):
    """ test a user to create instance by uploading image file and tiny flavor """

    user_bt = BaseTest(username, password, tenant_name)
    image = user_bt.get_image_by_name(image_name)

    if image == None:
        return 3
    image_id = image['id']

    resp, server = user_bt.servers_client.create_server(
        server_name, image_id, flavor_id)

    return user_bt._wait_for_server_status(server['id'], 'ACTIVE', 180)
def test_user_disabled_nologin(username, password, tenant_name):
    """ test a disabled user can not to login anymore """

    bt = BaseTest()
    user = bt.get_user_by_name(username)

    if (user == None):
        return 3

    try:
        bt_user = BaseTest(username, password, tenant_name)
    except exceptions.AuthenticationFailure:
        return 0

    return 1
Пример #43
0
    def setUpClass(cls):
        BaseTest.initEnvironment(cls)

        # log in
        BaseTest.login_private(cls)

        # wait for home page loaded
        home_page = HomePage(cls.driver)
        home_page.check_if_loaded()
        home_page.click_app("my")

        home_page.check_app_loaded()
        home_page.click_webhooks_link()

        cls.webhook_page = WebHookPage(cls.driver)
        assert  cls.webhook_page.check_page_loaded()
def upload_glance_image(file, disk_format='raw', container_format='bare', image_name='jeos1', timeout=60):
    """ Upload glance image file """

    baseTest = BaseTest()
    token = baseTest.token
    endpoint = baseTest.get_service_endpoint('glance')
    endpoint = endpoint.rsplit('/', 1)[0]

    glance = Client('1', endpoint, token)

    start = int(time.time())
    image = glance.images.create(name=image_name, disk_format=disk_format, container_format=container_format, is_public=True)

    image.update(data=open(file, 'rb'))
   
    return baseTest._wait_for_image_status(image.id, 'ACTIVE', 60) 
Пример #45
0
    def __init__(self, finder, value):

        self.driver = BaseTest.get_driver()
        self.finder = finder
        self.value = value
        self.element = None
        self.elements = []
Пример #46
0
	def test_collect_values_match(self):
		x, y, _ = BaseTest.get_data()
		imgpe = iMGPE(x, y, initial_k=6)
		BaseTest.divide_data(imgpe, singleton=True)

		grouped_inverse_gamma = imgpe.collect_gamma()
		naive_grouped = self.naive_prior_value_extraction(imgpe)

		for prior, values in grouped_inverse_gamma:
			found_prior = False
			for naive_grouped_prior, naive_grouped_values in naive_grouped:
				if not (naive_grouped_prior is prior):
					continue
				found_prior = True
				self.assertItemsEqual(values, naive_grouped_values)
			self.assertTrue(found_prior)
Пример #47
0
    def test_delete_user_204(self):
        

        

        map = RequestMap()
        
        map.set("id", BaseTest.resolveResponseValue("create_user.id"));
        
        response = User.delete204ById("ssss",map)
        self.assertNotEqual(response,None)

        ignoreAsserts = []
        
        

        BaseTest.putResponse("delete_user_204", response)
Пример #48
0
	def test_non_singleton_hyperhypers_modified(self):
		x, y, _ = BaseTest.get_data()
		imgpe = iMGPE(x, y, initial_k=6)
		BaseTest.divide_data(imgpe, singleton=False)

		pre_c, pre_class_indices, pre_param_vals = BaseTest.extract_sample_state(imgpe)
		pre_priors = BaseTest.extract_prior_state(imgpe)
		imgpe.optimize_priors()
		post_c, post_class_indices, post_param_vals = BaseTest.extract_sample_state(imgpe)
		post_priors = BaseTest.extract_prior_state(imgpe)

		self.assertEqual(len(pre_c), len(post_c))
		for pre_c_i, post_c_i in zip(pre_c, post_c):
			self.assertEqual(pre_c_i, post_c_i)

		self.assertEqual(len(pre_class_indices), len(post_class_indices))
		for pre_class_indices_j, post_class_indices_j in zip(pre_class_indices, post_class_indices):
			self.assertTrue(np.array_equal(pre_class_indices_j, post_class_indices_j))

		self.assertEqual(pre_param_vals, post_param_vals)

		self.assertNotEqual(pre_priors, post_priors)
		priors_and_values = self.naive_prior_value_extraction(imgpe)
		for prior, values in priors_and_values:
			self.ensure_optimal_hyperhypers(prior, values)
def test_delete_user(username):
    """ test administrator to delete a user whose name is the giving name"""

    bt = BaseTest()
    user = bt.get_user_by_name(username)

    if(user == None):
        return 3

    user_id = user['id']

    endpoint = bt.get_service_endpoint('keystone')
    endpoint = endpoint + '/users/' + user_id

    response, content = bt.delete(endpoint)    

    if(response['status'] == '200'):
        return 0

    return 1
def test_create_tenant_by_name(name):
    """ test administrator to create a tenant whose name is the giving name """
    bt = BaseTest()
    endpoint = bt.get_service_endpoint('keystone')
    endpoint = endpoint + '/tenants'
    headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}

    body = {
                "tenant": {
                    "name": name,
                    "description": "test create tenant",
                    "enabled": "true",
                },
    }
    
    response, content = bt.post(endpoint, headers=headers, body=json.dumps(body))

    if(response['status'] == '200'):
        return 0
    return 1
Пример #51
0
    def setUpClass(cls):
        # pre_condition
        # Create and pay charges for live mode before test suites begin
        for i in range(100):
            live_charges = BatchPayment()
            live_charges.run()

        BaseTest.initEnvironment(cls)
        BaseTest.login_private(cls)

        # wait for home page loaded
        home_page = HomePage(cls.driver)
        home_page.check_if_loaded()

        home_page.click_app("my")
        home_page.check_app_loaded()

        home_page.click_order_link()
        cls.order_page = OrderPage(cls.driver)
        cls.order_page.check_orderpage_loaded()
def delete_tenant(name):
    """ test administrator to delete a tenant whose name is the giving name"""
    bt = BaseTest()

    tenant = bt.get_tenant_by_name(name)

    if(tenant == None):
        print 'the tenant named %s is not existed!, skipped' %name
        return 3

    tenant_id = tenant['id']

    endpoint = bt.get_service_endpoint('keystone')
    endpoint = endpoint + '/tenants/' + tenant_id

    response, content = bt.delete(endpoint)

    if(response['status'] == '204'):
        return 0

    return 1
def test_nova_launch_instance_multiimg(username, password, tenant_name, images_name, flavor_id, timeout):
    """ test a user to create multiple server with different images file """

    images_id = list()

    bt = BaseTest()
    user_bt = BaseTest(username, password, tenant_name)
    for image_name in images_name:
        image = bt.get_image_by_name(image_name)
        if(image == None):
            return 3
        images_id.append(image['id'])

    images_dict = dict(zip(images_name, images_id))

    for image_name in images_dict:
        server_name = 'jeos_' + image_name
        resp, server = user_bt.servers_client.create_server(server_name, images_dict[image_name], flavor_id)

        ret = user_bt._wait_for_server_status(server['id'], 'ACTIVE', timeout)
        if(ret != 0):
            return 1

    user_bt.clean_servers('jeos_', True)

    return 0
def test_user_chpasswd_login(username, password, tenant_name, newpassword):
    """ test change a users password and the user can login with new password """

    ret = change_user_password(username, password, tenant_name, newpassword)

    if(ret != 0):
        return ret

    bt = BaseTest()
    endpoint = bt.get_service_endpoint('nova')
    endpoint = endpoint + '/servers'

    bt_user = BaseTest(username, newpassword, tenant_name)
    response, content = bt_user.get(endpoint)

    # restore the user's password
    change_user_password(username, newpassword, tenant_name, password)

    if response['status'] == '200':
        return 0

    return 1
def test_tenant_reenable(tenant_name):
    """ test enable a disabled tenant """

    bt = BaseTest()
    tenant = bt.get_tenant_by_name(tenant_name)

    if tenant == None:
        return 3

    tenant_id = tenant["id"]

    endpoint = bt.get_service_endpoint("keystone")
    endpoint = endpoint + "/tenants/" + tenant_id

    body = {"tenant": {"enabled": True}}

    headers = {"Content-Type": "application/json", "Accept": "application/json"}

    response, content = bt.post(endpoint, headers=headers, body=json.dumps(body))

    if response["status"] == "200":
        return 0
    return 1
Пример #56
0
 def tearDownClass(cls):
     BaseTest.clearUp(cls)
def delete_image(name, regmode):
    bt = BaseTest()
    bt.clean_images(name, regmode)