import unittest

import logging
from preparation_and_cleaning import *
from models_preparation import *


class TestAIFunction(unittest.TestCase):
    runtime_uid = None
    deployment_uid = None
    function_uid = None
    scoring_href = None
    logger = logging.getLogger(__name__)

    @classmethod
    def setUpClass(self):
        TestAIFunction.logger.info("Service Instance: setting up credentials")
        self.function_filepath = os.path.join(os.getcwd(), 'artifacts', 'ai_function.gz')

        self.wml_credentials = get_wml_credentials()
        self.client = get_client()

        self.function_name = 'simplest AI function'
        self.deployment_name = "Test deployment"

    def test_01_service_instance_details(self):
        TestAIFunction.logger.info("Check client ...")
        self.assertTrue(self.client.__class__.__name__ == 'APIClient')

        TestAIFunction.logger.info("Getting instance details ...")
        details = self.client.service_instance.get_details()
        TestAIFunction.logger.debug(details)

        self.assertTrue("published_models" in str(details))
        self.assertEqual(type(details), dict)

    def test_02_create_ai_function(self):

        self.client.repository.FunctionMetaNames.show()

        function_props = {
            self.client.repository.FunctionMetaNames.NAME: self.function_name,
            self.client.repository.FunctionMetaNames.DESCRIPTION: 'desc',
            self.client.repository.FunctionMetaNames.TAGS: [{"value": "ProjectA", "description": "Functions created for ProjectA"}]
        }

        ai_function_details = self.client.repository.store_function(self.function_filepath, function_props)

        TestAIFunction.function_uid = self.client.repository.get_function_uid(ai_function_details)
        function_url = self.client.repository.get_function_href(ai_function_details)
        TestAIFunction.logger.info("AI function ID:" + str(TestAIFunction.function_uid))
        TestAIFunction.logger.info("AI function URL:" + str(function_url))
        self.assertIsNotNone(TestAIFunction.function_uid)
        self.assertIsNotNone(function_url)
        TestAIFunction.runtime_uid = self.client.runtimes.get_uid(ai_function_details)

    def test_03_download_ai_function_content(self):
        try:
            os.remove('test_ai_function.tar.gz')
        except:
            pass

        self.client.repository.download(TestAIFunction.function_uid, filename='test_ai_function.tar.gz')

        try:
            os.remove('test_ai_function.gz')
        except:
            pass

    def test_04_get_details(self):
        details = self.client.repository.get_function_details()
        self.assertTrue(self.function_name in str(details))

        details = self.client.repository.get_function_details(self.function_uid)
        self.assertTrue(self.function_name in str(details))

        details = self.client.repository.get_details()
        self.assertTrue("functions" in details)

        details = self.client.repository.get_details(self.function_uid)
        self.assertTrue(self.function_name in str(details))

    def test_05_list(self):
        self.client.repository.list()

        self.client.repository.list_functions()

    def test_09_delete_function(self):
        TestAIFunction.logger.info("Delete function")
        self.client.repository.delete(TestAIFunction.function_uid)


if __name__ == '__main__':
    unittest.main()

f4e8b578f583a22a9ac667cc8f7ef5d5b9770c28
<mask token>


class TestAIFunction(unittest.TestCase):
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>

    @classmethod
    def setUpClass(self):
        TestAIFunction.logger.info('Service Instance: setting up credentials')
        self.function_filepath = os.path.join(os.getcwd(), 'artifacts',
            'ai_function.gz')
        self.wml_credentials = get_wml_credentials()
        self.client = get_client()
        self.function_name = 'simplest AI function'
        self.deployment_name = 'Test deployment'

    def test_01_service_instance_details(self):
        TestAIFunction.logger.info('Check client ...')
        self.assertTrue(self.client.__class__.__name__ == 'APIClient')
        TestAIFunction.logger.info('Getting instance details ...')
        details = self.client.service_instance.get_details()
        TestAIFunction.logger.debug(details)
        self.assertTrue('published_models' in str(details))
        self.assertEqual(type(details), dict)

    def test_02_create_ai_function(self):
        self.client.repository.FunctionMetaNames.show()
        function_props = {self.client.repository.FunctionMetaNames.NAME:
            self.function_name, self.client.repository.FunctionMetaNames.
            DESCRIPTION: 'desc', self.client.repository.FunctionMetaNames.
            TAGS: [{'value': 'ProjectA', 'description':
            'Functions created for ProjectA'}]}
        ai_function_details = self.client.repository.store_function(self.
            function_filepath, function_props)
        TestAIFunction.function_uid = self.client.repository.get_function_uid(
            ai_function_details)
        function_url = self.client.repository.get_function_href(
            ai_function_details)
        TestAIFunction.logger.info('AI function ID:' + str(TestAIFunction.
            function_uid))
        TestAIFunction.logger.info('AI function URL:' + str(function_url))
        self.assertIsNotNone(TestAIFunction.function_uid)
        self.assertIsNotNone(function_url)
        TestAIFunction.runtime_uid = self.client.runtimes.get_uid(
            ai_function_details)

    def test_03_download_ai_function_content(self):
        try:
            os.remove('test_ai_function.tar.gz')
        except:
            pass
        self.client.repository.download(TestAIFunction.function_uid,
            filename='test_ai_function.tar.gz')
        try:
            os.remove('test_ai_function.gz')
        except:
            pass

    def test_04_get_details(self):
        details = self.client.repository.get_function_details()
        self.assertTrue(self.function_name in str(details))
        details = self.client.repository.get_function_details(self.function_uid
            )
        self.assertTrue(self.function_name in str(details))
        details = self.client.repository.get_details()
        self.assertTrue('functions' in details)
        details = self.client.repository.get_details(self.function_uid)
        self.assertTrue(self.function_name in str(details))
    <mask token>

    def test_09_delete_function(self):
        TestAIFunction.logger.info('Delete function')
        self.client.repository.delete(TestAIFunction.function_uid)


<mask token>

<mask token>


class TestAIFunction(unittest.TestCase):
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>

    @classmethod
    def setUpClass(self):
        TestAIFunction.logger.info('Service Instance: setting up credentials')
        self.function_filepath = os.path.join(os.getcwd(), 'artifacts',
            'ai_function.gz')
        self.wml_credentials = get_wml_credentials()
        self.client = get_client()
        self.function_name = 'simplest AI function'
        self.deployment_name = 'Test deployment'

    def test_01_service_instance_details(self):
        TestAIFunction.logger.info('Check client ...')
        self.assertTrue(self.client.__class__.__name__ == 'APIClient')
        TestAIFunction.logger.info('Getting instance details ...')
        details = self.client.service_instance.get_details()
        TestAIFunction.logger.debug(details)
        self.assertTrue('published_models' in str(details))
        self.assertEqual(type(details), dict)

    def test_02_create_ai_function(self):
        self.client.repository.FunctionMetaNames.show()
        function_props = {self.client.repository.FunctionMetaNames.NAME:
            self.function_name, self.client.repository.FunctionMetaNames.
            DESCRIPTION: 'desc', self.client.repository.FunctionMetaNames.
            TAGS: [{'value': 'ProjectA', 'description':
            'Functions created for ProjectA'}]}
        ai_function_details = self.client.repository.store_function(self.
            function_filepath, function_props)
        TestAIFunction.function_uid = self.client.repository.get_function_uid(
            ai_function_details)
        function_url = self.client.repository.get_function_href(
            ai_function_details)
        TestAIFunction.logger.info('AI function ID:' + str(TestAIFunction.
            function_uid))
        TestAIFunction.logger.info('AI function URL:' + str(function_url))
        self.assertIsNotNone(TestAIFunction.function_uid)
        self.assertIsNotNone(function_url)
        TestAIFunction.runtime_uid = self.client.runtimes.get_uid(
            ai_function_details)

    def test_03_download_ai_function_content(self):
        try:
            os.remove('test_ai_function.tar.gz')
        except:
            pass
        self.client.repository.download(TestAIFunction.function_uid,
            filename='test_ai_function.tar.gz')
        try:
            os.remove('test_ai_function.gz')
        except:
            pass

    def test_04_get_details(self):
        details = self.client.repository.get_function_details()
        self.assertTrue(self.function_name in str(details))
        details = self.client.repository.get_function_details(self.function_uid
            )
        self.assertTrue(self.function_name in str(details))
        details = self.client.repository.get_details()
        self.assertTrue('functions' in details)
        details = self.client.repository.get_details(self.function_uid)
        self.assertTrue(self.function_name in str(details))

    def test_05_list(self):
        self.client.repository.list()
        self.client.repository.list_functions()

    def test_09_delete_function(self):
        TestAIFunction.logger.info('Delete function')
        self.client.repository.delete(TestAIFunction.function_uid)


<mask token>

<mask token>


class TestAIFunction(unittest.TestCase):
    runtime_uid = None
    deployment_uid = None
    function_uid = None
    scoring_href = None
    logger = logging.getLogger(__name__)

    @classmethod
    def setUpClass(self):
        TestAIFunction.logger.info('Service Instance: setting up credentials')
        self.function_filepath = os.path.join(os.getcwd(), 'artifacts',
            'ai_function.gz')
        self.wml_credentials = get_wml_credentials()
        self.client = get_client()
        self.function_name = 'simplest AI function'
        self.deployment_name = 'Test deployment'

    def test_01_service_instance_details(self):
        TestAIFunction.logger.info('Check client ...')
        self.assertTrue(self.client.__class__.__name__ == 'APIClient')
        TestAIFunction.logger.info('Getting instance details ...')
        details = self.client.service_instance.get_details()
        TestAIFunction.logger.debug(details)
        self.assertTrue('published_models' in str(details))
        self.assertEqual(type(details), dict)

    def test_02_create_ai_function(self):
        self.client.repository.FunctionMetaNames.show()
        function_props = {self.client.repository.FunctionMetaNames.NAME:
            self.function_name, self.client.repository.FunctionMetaNames.
            DESCRIPTION: 'desc', self.client.repository.FunctionMetaNames.
            TAGS: [{'value': 'ProjectA', 'description':
            'Functions created for ProjectA'}]}
        ai_function_details = self.client.repository.store_function(self.
            function_filepath, function_props)
        TestAIFunction.function_uid = self.client.repository.get_function_uid(
            ai_function_details)
        function_url = self.client.repository.get_function_href(
            ai_function_details)
        TestAIFunction.logger.info('AI function ID:' + str(TestAIFunction.
            function_uid))
        TestAIFunction.logger.info('AI function URL:' + str(function_url))
        self.assertIsNotNone(TestAIFunction.function_uid)
        self.assertIsNotNone(function_url)
        TestAIFunction.runtime_uid = self.client.runtimes.get_uid(
            ai_function_details)

    def test_03_download_ai_function_content(self):
        try:
            os.remove('test_ai_function.tar.gz')
        except:
            pass
        self.client.repository.download(TestAIFunction.function_uid,
            filename='test_ai_function.tar.gz')
        try:
            os.remove('test_ai_function.gz')
        except:
            pass

    def test_04_get_details(self):
        details = self.client.repository.get_function_details()
        self.assertTrue(self.function_name in str(details))
        details = self.client.repository.get_function_details(self.function_uid
            )
        self.assertTrue(self.function_name in str(details))
        details = self.client.repository.get_details()
        self.assertTrue('functions' in details)
        details = self.client.repository.get_details(self.function_uid)
        self.assertTrue(self.function_name in str(details))

    def test_05_list(self):
        self.client.repository.list()
        self.client.repository.list_functions()

    def test_09_delete_function(self):
        TestAIFunction.logger.info('Delete function')
        self.client.repository.delete(TestAIFunction.function_uid)


if __name__ == '__main__':
    unittest.main()

import unittest
import logging
from preparation_and_cleaning import *
from models_preparation import *


class TestAIFunction(unittest.TestCase):
    runtime_uid = None
    deployment_uid = None
    function_uid = None
    scoring_href = None
    logger = logging.getLogger(__name__)

    @classmethod
    def setUpClass(self):
        TestAIFunction.logger.info('Service Instance: setting up credentials')
        self.function_filepath = os.path.join(os.getcwd(), 'artifacts',
            'ai_function.gz')
        self.wml_credentials = get_wml_credentials()
        self.client = get_client()
        self.function_name = 'simplest AI function'
        self.deployment_name = 'Test deployment'

    def test_01_service_instance_details(self):
        TestAIFunction.logger.info('Check client ...')
        self.assertTrue(self.client.__class__.__name__ == 'APIClient')
        TestAIFunction.logger.info('Getting instance details ...')
        details = self.client.service_instance.get_details()
        TestAIFunction.logger.debug(details)
        self.assertTrue('published_models' in str(details))
        self.assertEqual(type(details), dict)

    def test_02_create_ai_function(self):
        self.client.repository.FunctionMetaNames.show()
        function_props = {self.client.repository.FunctionMetaNames.NAME:
            self.function_name, self.client.repository.FunctionMetaNames.
            DESCRIPTION: 'desc', self.client.repository.FunctionMetaNames.
            TAGS: [{'value': 'ProjectA', 'description':
            'Functions created for ProjectA'}]}
        ai_function_details = self.client.repository.store_function(self.
            function_filepath, function_props)
        TestAIFunction.function_uid = self.client.repository.get_function_uid(
            ai_function_details)
        function_url = self.client.repository.get_function_href(
            ai_function_details)
        TestAIFunction.logger.info('AI function ID:' + str(TestAIFunction.
            function_uid))
        TestAIFunction.logger.info('AI function URL:' + str(function_url))
        self.assertIsNotNone(TestAIFunction.function_uid)
        self.assertIsNotNone(function_url)
        TestAIFunction.runtime_uid = self.client.runtimes.get_uid(
            ai_function_details)

    def test_03_download_ai_function_content(self):
        try:
            os.remove('test_ai_function.tar.gz')
        except:
            pass
        self.client.repository.download(TestAIFunction.function_uid,
            filename='test_ai_function.tar.gz')
        try:
            os.remove('test_ai_function.gz')
        except:
            pass

    def test_04_get_details(self):
        details = self.client.repository.get_function_details()
        self.assertTrue(self.function_name in str(details))
        details = self.client.repository.get_function_details(self.function_uid
            )
        self.assertTrue(self.function_name in str(details))
        details = self.client.repository.get_details()
        self.assertTrue('functions' in details)
        details = self.client.repository.get_details(self.function_uid)
        self.assertTrue(self.function_name in str(details))

    def test_05_list(self):
        self.client.repository.list()
        self.client.repository.list_functions()

    def test_09_delete_function(self):
        TestAIFunction.logger.info('Delete function')
        self.client.repository.delete(TestAIFunction.function_uid)


if __name__ == '__main__':
    unittest.main()

import unittest

import logging
from preparation_and_cleaning import *
from models_preparation import *


class TestAIFunction(unittest.TestCase):
    runtime_uid = None
    deployment_uid = None
    function_uid = None
    scoring_href = None
    logger = logging.getLogger(__name__)

    @classmethod
    def setUpClass(self):
        TestAIFunction.logger.info("Service Instance: setting up credentials")
        self.function_filepath = os.path.join(os.getcwd(), 'artifacts', 'ai_function.gz')

        self.wml_credentials = get_wml_credentials()
        self.client = get_client()

        self.function_name = 'simplest AI function'
        self.deployment_name = "Test deployment"

    def test_01_service_instance_details(self):
        TestAIFunction.logger.info("Check client ...")
        self.assertTrue(self.client.__class__.__name__ == 'APIClient')

        TestAIFunction.logger.info("Getting instance details ...")
        details = self.client.service_instance.get_details()
        TestAIFunction.logger.debug(details)

        self.assertTrue("published_models" in str(details))
        self.assertEqual(type(details), dict)

    def test_02_create_ai_function(self):

        self.client.repository.FunctionMetaNames.show()

        function_props = {
            self.client.repository.FunctionMetaNames.NAME: self.function_name,
            self.client.repository.FunctionMetaNames.DESCRIPTION: 'desc',
            self.client.repository.FunctionMetaNames.TAGS: [{"value": "ProjectA", "description": "Functions created for ProjectA"}]
        }

        ai_function_details = self.client.repository.store_function(self.function_filepath, function_props)

        TestAIFunction.function_uid = self.client.repository.get_function_uid(ai_function_details)
        function_url = self.client.repository.get_function_href(ai_function_details)
        TestAIFunction.logger.info("AI function ID:" + str(TestAIFunction.function_uid))
        TestAIFunction.logger.info("AI function URL:" + str(function_url))
        self.assertIsNotNone(TestAIFunction.function_uid)
        self.assertIsNotNone(function_url)
        TestAIFunction.runtime_uid = self.client.runtimes.get_uid(ai_function_details)

    def test_03_download_ai_function_content(self):
        try:
            os.remove('test_ai_function.tar.gz')
        except:
            pass

        self.client.repository.download(TestAIFunction.function_uid, filename='test_ai_function.tar.gz')

        try:
            os.remove('test_ai_function.gz')
        except:
            pass

    def test_04_get_details(self):
        details = self.client.repository.get_function_details()
        self.assertTrue(self.function_name in str(details))

        details = self.client.repository.get_function_details(self.function_uid)
        self.assertTrue(self.function_name in str(details))

        details = self.client.repository.get_details()
        self.assertTrue("functions" in details)

        details = self.client.repository.get_details(self.function_uid)
        self.assertTrue(self.function_name in str(details))

    def test_05_list(self):
        self.client.repository.list()

        self.client.repository.list_functions()

    def test_09_delete_function(self):
        TestAIFunction.logger.info("Delete function")
        self.client.repository.delete(TestAIFunction.function_uid)


if __name__ == '__main__':
    unittest.main()
