Merge pull request #13 from nejec/master

Allow multiple key value specification
This commit is contained in:
Drew Kerrigan 2015-07-29 11:45:04 -07:00
commit e4334d0c4a
2 changed files with 5 additions and 3 deletions

View File

@ -67,7 +67,8 @@ optional arguments:
Basic auth string "username:password" Basic auth string "username:password"
-p PATH, --path PATH Path. -p PATH, --path PATH Path.
-e [KEY_LIST [KEY_LIST ...]], --key_exists [KEY_LIST [KEY_LIST ...]] -e [KEY_LIST [KEY_LIST ...]], --key_exists [KEY_LIST [KEY_LIST ...]]
Checks existence of these keys to determine status. Checks existence of these keys to determine status. Multiple key values can
be delimited with colon (key,value1:value2).
-q [KEY_VALUE_LIST [KEY_VALUE_LIST ...]], --key_equals [KEY_VALUE_LIST [KEY_VALUE_LIST ...]] -q [KEY_VALUE_LIST [KEY_VALUE_LIST ...]], --key_equals [KEY_VALUE_LIST [KEY_VALUE_LIST ...]]
Checks equality of these keys and values (key,value Checks equality of these keys and values (key,value
key2,value2) to determine status. key2,value2) to determine status.

View File

@ -75,7 +75,7 @@ class JsonHelper:
else: else:
return (None, 'not_found') return (None, 'not_found')
def equals(self, key, value): return self.exists(key) and str(self.get(key)) == value def equals(self, key, value): return self.exists(key) and str(self.get(key)) in value.split(':')
def lte(self, key, value): return self.exists(key) and float(self.get(key)) <= float(value) def lte(self, key, value): return self.exists(key) and float(self.get(key)) <= float(value)
def gte(self, key, value): return self.exists(key) and float(self.get(key)) >= float(value) def gte(self, key, value): return self.exists(key) and float(self.get(key)) >= float(value)
def exists(self, key): return (self.get(key) != (None, 'not_found')) def exists(self, key): return (self.get(key) != (None, 'not_found'))
@ -193,7 +193,8 @@ def parseArgs():
parser.add_argument('-e', '--key_exists', dest='key_list', nargs='*', parser.add_argument('-e', '--key_exists', dest='key_list', nargs='*',
help='Checks existence of these keys to determine status.') help='Checks existence of these keys to determine status.')
parser.add_argument('-q', '--key_equals', dest='key_value_list', nargs='*', parser.add_argument('-q', '--key_equals', dest='key_value_list', nargs='*',
help='Checks equality of these keys and values (key,value key2,value2) to determine status.') help='Checks equality of these keys and values (key,value key2,value2) to determine status.\
Multiple key values can be delimited with colon (key,value1:value2)')
parser.add_argument('-l', '--key_lte', dest='key_lte_list', nargs='*', parser.add_argument('-l', '--key_lte', dest='key_lte_list', nargs='*',
help='Checks that these keys and values (key,value key2,value2) are less than or equal to\ help='Checks that these keys and values (key,value key2,value2) are less than or equal to\
the returned json value to determine status.') the returned json value to determine status.')