# Path: sahara_tempest_plugin/tests/clients/base.py
# TEMPEST_CONF = config.CONF
# CLUSTER_STATUS_ACTIVE = "Active"
# CLUSTER_STATUS_ERROR = "Error"
# class ClusterErrorException(exceptions.TempestException):
# class BaseDataProcessingTest(tempest.test.BaseTestCase):
#     def resource_setup(cls):
#     def get_floating_ip_pool_id_for_neutron(cls):
#     def get_private_network_id(cls):
#     def _find_network_by_name(cls, network_name):
#     def get_image_id(cls, image_name):
#     def get_plugin(cls):
#     def create_node_group_template(self, name, **kwargs):
#     def create_cluster_template(self, name, **kwargs):
#     def create_data_source(self, name, url, description, type,
#                            credentials=None):
#     def create_job_binary(self, name, url, description, extra=None):
#     def create_job_binary_internal(self, name, data):
#     def create_job(self, name, job_type, mains, libs=None, description=None):
#     def create_cluster(self, name, **kwargs):
#     def check_cluster_active(self, cluster_id):
#     def create_job_execution(self, **kwargs):
#     def create_container(self, name):
#     def delete_resource(self, resource_client, resource_id):
#     def delete_timeout(
#             self, resource_client, resource_id,
#             timeout=TEMPEST_CONF.data_processing.cluster_timeout):
#     def delete_swift_container(self, container):


from tempest import config
from tempest.lib.common.utils import data_utils
from sahara_tempest_plugin.tests.clients import base
    def _check_job_binary_internal_list(self, binary_id, binary_name):
        # check for job binary internal in list
        binary_list = self.client.job_binary_internals.list()
        binaries_info = [(binary.id, binary.name) for binary in binary_list]
        self.assertIn((binary_id, binary_name), binaries_info)

    def _check_job_binary_internal_get(self, binary_id, binary_name):
        # check job binary internal fetch by id
        binary = self.client.job_binary_internals.get(binary_id)
        self.assertEqual(binary_name, binary.name)

    def _check_job_binary_internal_update(self, binary_id):
        values = {
            'name': data_utils.rand_name('sahara-internal-job-binary'),
            'is_public': True
        }
        binary = self.client.job_binary_internals.update(binary_id, **values)
        self.assertDictContainsSubset(values, binary.job_binary_internal)

    def _check_job_binary_internal_delete(self, binary_id):
        # delete job binary internal by id
        self.client.job_binary_internals.delete(binary_id)
        # check that job binary internal really deleted
        binary_list = self.client.job_binary_internals.list()
        self.assertNotIn(binary_id, [binary.id for binary in binary_list])

    def test_job_binary_internal(self):
        binary_id, binary_name = self._check_job_binary_internal_create()
        self._check_job_binary_internal_list(binary_id, binary_name)
        self._check_job_binary_internal_get(binary_id, binary_name)

# Path: sahara_tempest_plugin/tests/clients/base.py
# TEMPEST_CONF = config.CONF
# CLUSTER_STATUS_ACTIVE = "Active"
# CLUSTER_STATUS_ERROR = "Error"
# class ClusterErrorException(exceptions.TempestException):
# class BaseDataProcessingTest(tempest.test.BaseTestCase):
#     def resource_setup(cls):
#     def get_floating_ip_pool_id_for_neutron(cls):
#     def get_private_network_id(cls):
#     def _find_network_by_name(cls, network_name):
#     def get_image_id(cls, image_name):
#     def get_plugin(cls):
#     def create_node_group_template(self, name, **kwargs):
#     def create_cluster_template(self, name, **kwargs):
#     def create_data_source(self, name, url, description, type,
#                            credentials=None):
#     def create_job_binary(self, name, url, description, extra=None):
#     def create_job_binary_internal(self, name, data):
#     def create_job(self, name, job_type, mains, libs=None, description=None):
#     def create_cluster(self, name, **kwargs):
#     def check_cluster_active(self, cluster_id):
#     def create_job_execution(self, **kwargs):
#     def create_container(self, name):
#     def delete_resource(self, resource_client, resource_id):
#     def delete_timeout(
#             self, resource_client, resource_id,
#             timeout=TEMPEST_CONF.data_processing.cluster_timeout):
#     def delete_swift_container(self, container):


# Path: sahara_tempest_plugin/tests/clients/test_job_binary_internals.py
from tempest import config
from tempest.lib.common.utils import data_utils
from sahara_tempest_plugin.tests.clients import base

    def _check_job_binary_internal_list(self, binary_id, binary_name):
        # check for job binary internal in list
        binary_list = self.client.job_binary_internals.list()
        binaries_info = [(binary.id, binary.name) for binary in binary_list]
        self.assertIn((binary_id, binary_name), binaries_info)

    def _check_job_binary_internal_get(self, binary_id, binary_name):
        # check job binary internal fetch by id
        binary = self.client.job_binary_internals.get(binary_id)
        self.assertEqual(binary_name, binary.name)

    def _check_job_binary_internal_update(self, binary_id):
        values = {
            'name': data_utils.rand_name('sahara-internal-job-binary'),
            'is_public': True
        }
        binary = self.client.job_binary_internals.update(binary_id, **values)
        self.assertDictContainsSubset(values, binary.job_binary_internal)

    def _check_job_binary_internal_delete(self, binary_id):
        # delete job binary internal by id
        self.client.job_binary_internals.delete(binary_id)
        # check that job binary internal really deleted
        binary_list = self.client.job_binary_internals.list()
        self.assertNotIn(binary_id, [binary.id for binary in binary_list])

    def test_job_binary_internal(self):
        binary_id, binary_name = self._check_job_binary_internal_create()
        self._check_job_binary_internal_list(binary_id, binary_name)
        self._check_job_binary_internal_get(binary_id, binary_name)

        self._check_job_binary_internal_update(binary_id)