Example #1
0
 def test_multiple_hosts(self):
     user, passwd = tm.get_user_pass()
     if self.s._protocol in ['http', 'https']:
         unittest.TestCase.skipTest(
             self, 'REST does not support multiple hosts yet')
     with swat.CAS([HOST, 'foo', 'bar'], PORT, USER, PASSWD) as s:
         self.assertTrue(len(s.serverstatus()) > 0)
Example #2
0
    def test_set_bad_session_locale(self):
        if self.s._protocol in ['http', 'https']:
            tm.TestCase.skipTest(self, 'REST does not raise an error for bad locales')

        user, passwd = tm.get_user_pass()
        with captured_stderr() as out:  # noqa: F841
            with self.assertRaises(swat.SWATError):
                swat.CAS(HOST, PORT, USER, PASSWD, protocol=PROTOCOL, locale='bad-locale')
Example #3
0
 def test_set_bad_session_locale(self):
     user, passwd = tm.get_user_pass()
     with self.assertRaises(swat.SWATError):
         swat.CAS(HOST,
                  PORT,
                  USER,
                  PASSWD,
                  protocol=PROTOCOL,
                  locale='bad-locale')
Example #4
0
 def test_connect_with_bad_session(self):
     user, passwd = tm.get_user_pass()
     with self.assertRaises(swat.SWATError):
         swat.CAS(HOST,
                  PORT,
                  USER,
                  PASSWD,
                  protocol=PROTOCOL,
                  session='bad-session')
Example #5
0
 def test_connection_failure(self):
     user, passwd = tm.get_user_pass()
     with captured_stderr() as out:  # noqa: F841
         with self.assertRaises(swat.SWATError):
             swat.CAS(re.sub(r':\d+(/|$)', r'\1', HOST),
                      1999,
                      USER,
                      PASSWD,
                      protocol=PROTOCOL)
Example #6
0
 def test_set_session_locale(self):
     user, passwd = tm.get_user_pass()
     u = swat.CAS(HOST, PORT, USER, PASSWD, protocol=PROTOCOL, locale='es_US')
     if self.s._protocol == 'http':
         self.assertIn(u._soptions, ['locale=es_US protocol=http',
                                    'protocol=http locale=es_US'])
     else:
         self.assertIn(u._soptions, ['locale=es_US', 'locale=es_US protocol=cas',
                                                    'protocol=cas locale=es_US'])
     u.endsession()
Example #7
0
    def setUp(self):
        swat.reset_option()
        swat.options.cas.print_messages = False
        swat.options.interactive_mode = False

        user, passwd = tm.get_user_pass()

        self.s = swat.CAS(HOST, PORT, USER, PASSWD, protocol=PROTOCOL)

        if type(self).server_type is None:
            type(self).server_type = tm.get_cas_host_type(self.s)

        self.srcLib = tm.get_casout_lib(self.server_type)
Example #8
0
    def test_connect_existing_session(self):      
        user, passwd = tm.get_user_pass()
        t = swat.CAS(HOST, PORT, USER, PASSWD, protocol=PROTOCOL, session=self.s._session)

        self.assertEqual(t._hostname, HOST)
        self.assertEqual(t._port, PORT)
        self.assertEqual(t._session, self.s._session)
        if self.s._protocol == 'http':
            self.assertIn(t._soptions, ['session=%s protocol=http' % self.s._session,
                                        'protocol=http session=%s' % self.s._session])
        else:
            self.assertIn(t._soptions, ['session=%s' % self.s._session,
                                        'session=%s protocol=cas' % self.s._session,
                                        'protocol=cas session=%s' % self.s._session])
Example #9
0
    def setUp(self):
        swat.reset_option()
        swat.options.cas.print_messages = False
        swat.options.cas.trace_actions = False
        swat.options.cas.trace_ui_actions = False
        swat.options.interactive_mode = False

        user, passwd = tm.get_user_pass()

        self.s = swat.CAS(HOST, PORT, USER, PASSWD, protocol=PROTOCOL)

        if type(self).server_type is None: 
            type(self).server_type = tm.get_cas_host_type(self.s)        

        self.srcLib = tm.get_casout_lib(self.server_type)

        r = tm.load_data(self.s, 'datasources/cars_single.sashdat', self.server_type)

        self.tablename = r['tableName']
        self.assertNotEqual(self.tablename, None)
        self.table = r['casTable']
Example #10
0
    def test_multihost(self):
        hosts = [HOST, 'rdcgrd001', 'snap001', 'cas01']

        hostlist = list(sorted(set(hosts)))

        def str2hostlist(hoststr):
            return list(sorted(set(hoststr.split())))

        user, passwd = tm.get_user_pass()

        self.s = swat.CAS(hosts, PORT, USER, PASSWD)
        self.assertEqual(str2hostlist(self.s._hostname), hostlist)
        self.assertEqual(self.s._port, PORT)
        #       self.assertEqual(self.s._username, USERNAME)

        self.s = swat.CAS(set(hosts), PORT, USER, PASSWD)
        self.assertEqual(str2hostlist(self.s._hostname), hostlist)
        self.assertEqual(self.s._port, PORT)
        #       self.assertEqual(self.s._username, USERNAME)

        self.s = swat.CAS(tuple(hosts), PORT, USER, PASSWD)
        self.assertEqual(str2hostlist(self.s._hostname), hostlist)
        self.assertEqual(self.s._port, PORT)
Example #11
0
from __future__ import print_function, division, absolute_import, unicode_literals

import os
import numpy as np
import pandas as pd
import swat
import swat.utils.testing as tm
import unittest
from pipefitter.backends.cas.estimator.base import EstimatorMixIn, ModelMixIn

from swat.utils.compat import patch_pandas_sort
from swat.utils.testing import UUID_RE, get_cas_host_type, load_data

patch_pandas_sort()

USER, PASSWD = tm.get_user_pass()
HOST, PORT, PROTOCOL = tm.get_host_port_proto()


class TestModelMixIn(tm.TestCase):
    def test_get_default_event_level(self):
        mmi = ModelMixIn()
        self.assertTrue(mmi.get_default_event_level(0) is None)
        self.assertTrue(mmi.get_default_event_level(2) is None)


class TestEstimatorMixIn(tm.TestCase):

    server_type = None

    def setUp(self):
Example #12
0
 def test_connection_failure(self):
     user, passwd = tm.get_user_pass()
     with self.assertRaises(swat.SWATError):
         swat.CAS(HOST, 1999, USER, PASSWD, protocol=PROTOCOL)
Example #13
0
 def test_name(self):
     user, passwd = tm.get_user_pass()
     s = swat.CAS(HOST, PORT, USER, PASSWD, name='My Connection')
     name = list(s.sessionid().keys())[0].split(':')[0]
     self.assertEqual(s._name, name)