from benchmark.test_types.framework_test_type import FrameworkTestType
from benchmark.test_types.query_type import QueryTestType

from pprint import pprint

class UpdateTestType(QueryTestType):
  def __init__(self):
    args = ['update_url']
    FrameworkTestType.__init__(self, name='update', requires_db=True, 
      accept_header=self.accept_json, args=args)

  def get_url(self):
    return self.update_url

  def verify(self, base_url):
    '''Validates the response is a JSON array of 
    the proper length, each JSON Object in the array 
    has keys 'id' and 'randomNumber', and these keys 
    map to integers. Case insensitive and 
    quoting style is ignored
    '''

    url = base_url + self.update_url
    problems = []
    
    response = self._curl(url + '2')
    body = self._curl_body(url + '2')
    problems += self._verifyQueryList(2, response, body, url + '2')

    response = self._curl(url + '0')
    body = self._curl_body(url + '0')
    problems += self._verifyQueryList(1, response, body, url + '0', 'warn')

    response = self._curl(url + 'foo')
    body = self._curl_body(url + 'foo')
    problems += self._verifyQueryList(1, response, body, url + 'foo', 'warn')

    response = self._curl(url + '501')
    body = self._curl_body(url + '501')
    problems += self._verifyQueryList(500, response, body, url + '501', 'warn')

    if len(problems) == 0:
      return [('pass','',url + '2'),
              ('pass','',url + '0'),
              ('pass','',url + 'foo'),
              ('pass','',url + '501')]
    else:
      return problems



@@ -187,16 +187,17 @@
 tType):%0A
+%0A
   def __
@@ -218,82 +218,91 @@
     
+kw
 args = 
-%5B'update_url'%5D%0A    FrameworkTestType.__init__(self, name='update', 
+%7B%0A      'name': 'update',%0A      'accept_header': self.accept_json,%0A      '
 requ
@@ -312,59 +312,93 @@
 s_db
-=
+': 
 True,
- 
 %0A      
-accept_header=self.accept_json, args=
+'args': %5B'update_url'%5D%0A    %7D%0A    FrameworkTestType.__init__(self, **kw
 args
@@ -763,321 +763,62 @@
     
-problem
+case
 s = %5B
-%5D
 %0A    
-%0A  
   
-response = self._curl(url + '2')%0A    body = self._curl_body(url + '2')%0A    problems += self._verifyQueryList(2, response, body, url + '2')%0A%0A    response = self._curl(url + '0
+('2',   'fail
 ')
+,
 %0A    
-body = self._curl_body(url + '0')%0A    problems += self._verifyQueryList(1, response, body, url + '0',
+  ('0',  
  'warn')
 %0A%0A  
@@ -817,156 +817,44 @@
 rn')
-%0A
+,
 %0A    
-response = self._curl(url + 'foo')%0A    body = self._curl_body(url + 'foo
+  ('foo', 'warn
 ')
+,
 %0A    
-problems += self._verifyQueryList(1, response, body, url + 'foo
+  ('501
 ', '
@@ -863,88 +863,37 @@
 rn')
-%0A
+,
 %0A    
-response = self._curl(url + '501')%0A    body = self._curl_body(url + '501')
+  ('',    'warn')%0A    %5D
 %0A   
@@ -902,17 +902,16 @@
 roblems 
-+
 = self._
@@ -925,53 +925,24 @@
 uery
-List(500, response, body, url + '501', 'warn'
+Cases(url, cases
 )%0A%0A 

Update update_type for requests