OmniSciDB  340b00dbf6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tests.conftest Namespace Reference

Functions

def _check_open
 
def omnisci_server
 
def con
 
def mock_client
 
def no_gpu
 
def gen_string
 
def tmp_table
 

Variables

tuple omniscihost = os.environ.get('OMNISCI_HOST', 'localhost')
 

Function Documentation

def tests.conftest._check_open ( )
private
Test to see if OmniSci running on localhost and socket open

Definition at line 15 of file conftest.py.

Referenced by tests.conftest.omnisci_server().

15 
16 def _check_open():
17  """
18  Test to see if OmniSci running on localhost and socket open
19  """
20  socket = TSocket.TSocket(omniscihost, 6274)
21  transport = TTransport.TBufferedTransport(socket)
22 
23  try:
24  transport.open()
25  return True
26  except TTransportException:
27  return False
28 
29 
@pytest.fixture(scope='session')
def _check_open
Definition: conftest.py:15

+ Here is the caller graph for this function:

def tests.conftest.con (   omnisci_server)
Fixture to provide Connection for tests run against live OmniSci instance

Definition at line 61 of file conftest.py.

References omnisci.connection.connect().

61 
62 def con(omnisci_server):
63  """
64  Fixture to provide Connection for tests run against live OmniSci instance
65  """
66  return connect(
67  user="admin",
68  password='HyperInteractive',
69  host=omniscihost,
70  port=6274,
71  protocol='binary',
72  dbname='omnisci',
73  )
74 
75 
@pytest.fixture

+ Here is the call graph for this function:

def tests.conftest.gen_string ( )
Generate a random string sequence for use in _tests_table_no_nulls

Definition at line 96 of file conftest.py.

References join().

96 
97 def gen_string():
98  """Generate a random string sequence for use in _tests_table_no_nulls"""
99  return ''.join(
100  [
101  random.choice(string.ascii_letters + string.digits)
102  for n in range(10)
103  ]
104  )
105 
106 
@pytest.fixture
std::string join(T const &container, std::string const &delim)
def gen_string
Definition: conftest.py:96

+ Here is the call graph for this function:

def tests.conftest.mock_client (   mocker)
A magicmock for omnisci.connection.Client

Definition at line 76 of file conftest.py.

76 
77 def mock_client(mocker):
78  """A magicmock for omnisci.connection.Client"""
79  return mocker.patch("omnisci.connection.Client")
80 
def mock_client
Definition: conftest.py:76
def tests.conftest.no_gpu ( )
Check for the required GPU dependencies

Definition at line 81 of file conftest.py.

81 
82 def no_gpu():
83  """Check for the required GPU dependencies"""
84  try:
85  from numba import cuda
86  import cudf # noqa
87 
88  try:
89  cuda.select_device(0)
90  except cuda.cudadrv.error.CudaDriverError:
91  return True
92  except ImportError:
93  return True
94  return False
95 
def tests.conftest.omnisci_server ( )
Ensure an omnisci server is running, optionally starting one if none

Definition at line 30 of file conftest.py.

References tests.conftest._check_open().

30 
31 def omnisci_server():
32  """Ensure an omnisci server is running, optionally starting one if none"""
33  if _check_open():
34  # already running before pytest started
35  pass
36  else:
37  # not yet running...
38  subprocess.check_output(
39  [
40  'docker',
41  'run',
42  '-d',
43  '--ipc=host',
44  '-v',
45  '/dev:/dev',
46  '-p',
47  '6274:6274',
48  '-p',
49  '9092:9092',
50  '--name=mapd',
51  'omnisci/core-os-cpu:latest',
52  ]
53  )
54  # yield and stop afterwards?
55  assert _check_open()
56  # Takes some time to start up. Unfortunately even trying to connect
57  # will cause it to hang.
58  time.sleep(5)
59 
60 
@pytest.fixture(scope='session')
def omnisci_server
Definition: conftest.py:30
def _check_open
Definition: conftest.py:15

+ Here is the call graph for this function:

def tests.conftest.tmp_table (   con,
  str 
)

Definition at line 107 of file conftest.py.

108 def tmp_table(con) -> str:
109  table_name = 'table_{}'.format(uuid4().hex)
110  con.execute("drop table if exists {};".format(table_name))
111 
112  try:
113  yield table_name
114  finally:
115  con.execute("drop table if exists {};".format(table_name))

Variable Documentation

tuple tests.conftest.omniscihost = os.environ.get('OMNISCI_HOST', 'localhost')

Definition at line 13 of file conftest.py.