Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_gt():
query = where('value') > 1
assert_true(query({'value': 2}))
assert_false(query({'value': 1}))
def test_has_key():
query = where('val3')
assert_true(query({'val3': 1}))
assert_false(query({'val1': 1, 'val2': 2}))
def test_le():
query = where('value') <= 1
assert_true(query({'value': 0}))
assert_true(query({'value': 1}))
assert_false(query({'value': 2}))
def test_not():
query = ~ (where('val1') == 1)
assert_true(query({'val1': 5, 'val2': 2}))
assert_false(query({'val1': 1, 'val2': 2}))
query = (
(~ (where('val1') == 1)) &
(where('val2') == 2)
)
assert_true(query({'val1': '', 'val2': 2}))
assert_true(query({'val2': 2}))
assert_false(query({'val1': 1, 'val2': 2}))
assert_false(query({'val1': 1}))
assert_false(query({'val1': '', 'val2': ''}))
def test_ge():
query = where('value') >= 1
assert_true(query({'value': 2}))
assert_true(query({'value': 1}))
assert_false(query({'value': 0}))
def test_ne():
query = where('value') != 1
assert_true(query({'value': 2}))
assert_false(query({'value': 1}))
def test_not():
query = ~ (where('val1') == 1)
assert_true(query({'val1': 5, 'val2': 2}))
assert_false(query({'val1': 1, 'val2': 2}))
query = (
(~ (where('val1') == 1)) &
(where('val2') == 2)
)
assert_true(query({'val1': '', 'val2': 2}))
assert_true(query({'val2': 2}))
assert_false(query({'val1': 1, 'val2': 2}))
assert_false(query({'val1': 1}))
assert_false(query({'val1': '', 'val2': ''}))
def search(regex):
db = Database(config.path)
credentials = db.search(
where("name").matches(regex) |
where("login").matches(regex) |
where("comment").matches(regex))
credentials = sorted(credentials, key=lambda x: x["name"]+x["login"])
if credentials:
click.echo(make_table(credentials))
def search(regex):
db = Database(config.path)
credentials = db.search(
where("name").matches(regex) |
where("login").matches(regex) |
where("comment").matches(regex))
credentials = sorted(credentials, key=lambda x: x["name"]+x["login"])
if credentials:
click.echo(make_table(credentials))
def search(regex):
db = Database(config.path)
credentials = db.search(
where("name").matches(regex) |
where("login").matches(regex) |
where("comment").matches(regex))
credentials = sorted(credentials, key=lambda x: x["name"]+x["login"])
if credentials:
click.echo(make_table(credentials))