'This test checks filtering of instances by Instance Name
Steps:
1) Login to Horizon dashboard as regular user
2) Go to Project > Compute > Instances
3) Create 2 instances
4) Go to appropriate page (depends on user)
5) Use filter by Instance Name
6) Check that filtered table has one instance only (which name is equal
to filter value) and no other instances in the table
7) Check that filtered table has both instances (search by common part
of instance names)
8) Set nonexistent instance name. Check that 0 rows are displayed
9) Clear filter and delete instances via proper page (depends on user)'

def test_filter_instances(self):

    instance_count = 2
    instance_list = ['{0}-{1}'.format(self.INSTANCE_NAME, item) for item in range(1, (instance_count + 1))]
    instances_page = self.home_pg.go_to_compute_instancespage()
    instances_page.create_instance(self.INSTANCE_NAME, instance_count=instance_count)
    self.assertTrue(instances_page.find_message_and_dismiss(messages.SUCCESS))
    self.assertTrue(instances_page.is_instance_active(instance_list[0]))
    instances_page = self.instances_page
    instances_page.instances_table.set_filter_value('name')
    instances_page.instances_table.filter(instance_list[0])
    self.assertTrue(instances_page.is_instance_present(instance_list[0]))
    for instance in instance_list[1:]:
        self.assertFalse(instances_page.is_instance_present(instance))
    instances_page.instances_table.filter(self.INSTANCE_NAME)
    for instance in instance_list:
        self.assertTrue(instances_page.is_instance_present(instance))
    nonexistent_instance_name = '{0}_test'.format(self.INSTANCE_NAME)
    instances_page.instances_table.filter(nonexistent_instance_name)
    self.assertEqual(instances_page.instances_table.rows, [])
    instances_page.instances_table.filter('')
    instances_page.delete_instances(instance_list)
    self.assertTrue(instances_page.find_message_and_dismiss(messages.SUCCESS))
    self.assertTrue(instances_page.are_instances_deleted(instance_list))
