from testmodule import *

class TestWrites(TestRunner):
		
	def __init__(self):
		super().__init__()
	
	def mthd(self):
	
		import pysharkbite

		
		tableOperations = super().getTableOperations()
			
		if not tableOperations.exists(False):
		    print ("Creating table")
		    if not tableOperations.create(False):
		    	print("Could not create table")  
		else:
		    print ("Table already exists, so not creating it")  
		
		
		auths = pysharkbite.Authorizations()
		
		""" Add authorizations """ 
		""" mutation.put("cf","cq","cv",1569786960) """
		
		writer = tableOperations.createWriter(auths, 10)
		
		mutation = pysharkbite.Mutation("row2");    
		
		mutation.put("cf","cq","",1569786960, "value")
		mutation.put("cf2","cq2","",1569786960, "value2")
		""" no value """
		mutation.put("cf3","cq3","",1569786960, "") 
		
		writer.addMutation( mutation )
		
		writer.close()
		
		print("written")
		
		""" auths.addAuthorization("cv") """
		
		scanner = tableOperations.createScanner(auths, 2)
		
		startKey = pysharkbite.Key()
		
		endKey = pysharkbite.Key()
		
		startKey.setRow("row")
		
		endKey.setRow("row3")
		
		range = pysharkbite.Range(startKey,True,endKey,False)
		
		scanner.addRange( range )
		
		resultset = scanner.getResultSet()
		
		for keyvalue in resultset:
			key = keyvalue.getKey()
			assert( "row2" == key.getRow() )
			value = keyvalue.getValue()
			if "cf" == key.getColumnFamily():
				assert( "value"  == value.get() )
			if ("cf2" == key.getColumnFamily() ):
				assert( "value2" == value.get() )
			if ("cf3" == key.getColumnFamily() ):
				assert( "" == value.get() )
		    
		    
		
		""" delete your table if user did not create temp """
		
		tableOperations.remove()


runner = TestWrites()
runner.mthd()
@@ -543,24 +543,27 @@
 960) %22%22%22%0A%09%09%0A
+%09%09%0A
 %09%09writer = t
@@ -639,17 +639,17 @@
 tation(%22
-r
+s
 ow2%22);  
@@ -880,16 +880,286 @@
 se()%0A%09%09%0A
+%09%09writer = tableOperations.createWriter(auths, 10)%0A%09%09%0A%09%09rng = range(0,1000)%0A%09%09for i in rng:%0A%09%09%09row = (%22row%25i%22 %25 (i+5))%0A%09%09%09mutation = pysharkbite.Mutation(row);    %0A%09%09%09mutation.put(%22cf%22,%22cq%22,%22%22,1569786960, %22value%22)%0A%09%09%09writer.addMutation(mutation)%0A%09%09%09%0A%09%09writer.close()%0A%09%09%0A
 %09%09print(
@@ -1354,17 +1354,17 @@
 setRow(%22
-r
+s
 ow%22)%0A%09%09%0A
@@ -1380,17 +1380,17 @@
 setRow(%22
-r
+s
 ow3%22)%0A%09%09
@@ -1392,17 +1392,25 @@
 %22)%0A%09%09%0A%09%09
-r
+accumuloR
 ange = p
@@ -1477,17 +1477,25 @@
 dRange( 
-r
+accumuloR
 ange )%0A%09
@@ -1604,17 +1604,17 @@
 ssert( %22
-r
+s
 ow2%22 == 
@@ -1897,18 +1897,354 @@
    %0A%09%09  
-  
+%0A%09%09scanner = tableOperations.createScanner(auths, 2)   %0A%09%09%0A%09%09accumuloRange = pysharkbite.Range(%22row%22,True,%22row9999999%22,False)%0A%09%09%0A%09%09scanner.addRange( accumuloRange )%0A%09%09%0A%09%09resultset = scanner.getResultSet()%0A%09%09count=0%0A%09%09for keyvalue in resultset:%0A%09%09%09key = keyvalue.getKey()%0A%09%09%09count=count+1%0A%09%09print(%22count is %22, count) %0A%09%09assert(count==1000)
 %0A%09%09%0A%09%09%22%22

update test