from __future__ import print_function
#Currently, our R/python test suite is executed against an established h2o cluster (run.py sets up the cluster). However, we ignore the mode of 
#operation where the h2o cluster is created by the client. Consequently, we may not recognize bugs in h2o.init() for this mode of operation. 
#For this ticket, I think we should create a set of tests that check that h2o.init() is successful for each OS/client interface combination.

#Below is the test that will be implemented:

import h2o

#Call h2o.init() just in case instance is not running
h2o.init(strict_version_check=False)

#First we will shutdown any instance of h2o
h2o.shutdown(prompt = False)

#Load up h2o.init()

h2o.init(strict_version_check=False)

#Get H2OConnection() class
conn = h2o.H2OConnection(ip="localhost", port=54321, start_h2o=True, enable_assertions=True,
						 license=None, nthreads=-1, max_mem_size=None, min_mem_size=None, ice_root=None,
						 strict_version_check=False, proxy=None, https=False, insecure=False, username=None,
						 password=None, cluster_name=None, force_connect=False, max_mem_size_GB=None, min_mem_size_GB=None,
						 proxies=None, size=None)


#Get if cluster is up (True) or not (False)
cluster_up = conn.cluster_is_up(conn)

#Hacky way to get if cluster is healthy or not. Might need to fix in cluster_status() function in h2o.py...
conn.json = h2o.H2OConnection.get_json("Cloud?skip_ticks=true")

#Nodes contains healthy status. However, first index in Nodes list is a dictionary. So, we allocate that to a variable and take healthy status
nodes = conn.json['nodes']
nodes = nodes[0]
cluster_health = nodes['healthy']

#Logical test to see if status is healthy or not
if cluster_health == True & cluster_up == True:
	print("Cluster health is up and healthy")
elif cluster_health != True & cluster_up == True:
	raise ValueError('Cluster is up but not healthy')
else:
	raise ValueError('Cluster is not up and is not healthy')


@@ -1,43 +1,36 @@
-from __future__ import print_function%0A#
+# -*- encoding: utf-8 -*-%0A%22%22%22%0A  
 Curr
@@ -42,17 +42,17 @@
 , our R/
-p
+P
 ython te
@@ -136,16 +136,18 @@
 luster).
+%0A 
  However
@@ -170,18 +170,16 @@
 mode of 
-%0A#
 operatio
@@ -252,16 +252,18 @@
  may not
+%0A 
  recogni
@@ -315,11 +315,11 @@
 ion.
- %0A#
+%0A  
 For 
@@ -420,16 +420,18 @@
 for each
+%0A 
  OS/clie
@@ -457,17 +457,18 @@
 ation.%0A%0A
-#
+  
 Below is
@@ -507,685 +507,389 @@
 ed:%0A
-%0Aimport h2o%0A%0A#Call h2o.init() just in case instance is not running%0Ah2o.init(strict_version_check=False)%0A%0A#First we will shutdown any instance of h2o%0Ah2o.shutdown(prompt = False)%0A%0A#Load up h2o.init()%0A%0Ah2o.init(strict_version_check=False)%0A%0A#Get H2OConnection() class%0Aconn = h2o.H2OConnection(ip=%22localhost%22, port=54321, start_h2o=True, enable_assertions=True,%0A%09%09%09%09%09%09 license=None, nthreads=-1, max_mem_size=None, min_mem_size=None, ice_root=None,%0A%09%09%09%09%09%09 strict_version_check=False, proxy=None, https=False, insecure=False, username=None,%0A%09%09%09%09%09%09 password=None, cluster_name=None, force_connect=False, max_mem_size_GB=None, min_mem_size_GB=None,%0A%09%09%09%09%09%09 proxies=None, size=None
+%22%22%22%0Afrom __future__ import print_function%0Aimport sys%0Asys.path.insert(0, %22../..%22)%0Aimport h2o%0A%0APORT = 55330%0A%0A# Check whether there is already an instance running at the specified port, and if so shut it down.%0Atry:%0A    conn = h2o.connect(port=PORT)%0A    conn.shutdown(prompt=False)%0Aexcept h2o.H2OConnectionError:%0A    pass%0A%0A%0A# Now start a new H2O server.%0Aconn = h2o.start(port=PORT
 )%0A%0A
-%0A
 #
+ 
 Get 
@@ -963,411 +963,113 @@
 _up(
-conn)%0A%0A#Hacky way to get if cluster is healthy or not. Might need to fix in cluster_status() function in h2o.py...%0Aconn.json = h2o.H2OConnection.get_json(%22Cloud?skip_ticks=true%22)%0A%0A#Nodes contains healthy status. However, first in
+)%0A%0A# Check if cluster is healthy%0Acluster_healthy = all(node%5B%22healthy%22%5D for no
 de
-x
  in 
-Nodes list is a dictionary. So, we allocate that to a variable and take healthy status%0Anodes = conn.json%5B'nodes'%5D%0Anodes = nodes%5B0%5D%0Acluster_health = nodes%5B'healthy'%5D
+conn.info().nodes)
 %0A%0A#
+ 
 Logi
@@ -1133,18 +1133,13 @@
 alth
- == True &
+y and
  clu
@@ -1145,27 +1145,22 @@
 uster_up
- == True:%0A%09
+:%0A    
 print(%22C
@@ -1198,16 +1198,20 @@
 %22)%0Aelif 
+not 
 cluster_
@@ -1220,18 +1220,13 @@
 alth
- != True &
+y and
  clu
@@ -1236,19 +1236,14 @@
 r_up
- == True:%0A%09
+:%0A    
 rais
@@ -1247,33 +1247,33 @@
 aise ValueError(
-'
+%22
 Cluster is up bu
@@ -1289,17 +1289,17 @@
 lthy
-'
+%22
 )%0Aelse:%0A
 %09rai
@@ -1298,9 +1298,12 @@
 se:%0A
-%09
+    
 rais
@@ -1315,17 +1315,17 @@
 ueError(
-'
+%22
 Cluster 
@@ -1356,8 +1356,7 @@
 lthy
-'
+%22
 )%0A
-%0A

Change test h2o.init_test_HOQE-16.py to not use private interfaces, and use some of the newer helper functions