Skip to content

Commit

Permalink
Merge pull request #1 from nottyo/master
Browse files Browse the repository at this point in the history
Merged head repository
  • Loading branch information
thekaizokuou authored Dec 25, 2019
2 parents 600003e + 79703cb commit a830ce8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
17 changes: 16 additions & 1 deletion RedisLibrary/RedisLibraryKeywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,19 @@ def redis_hash_key_should_not_be_exist(self, redis_conn, hash_name, key):
"""
if redis_conn.hexists(hash_name, key) is True:
logger.error("Hash: " + hash_name + " and Key: " + key +" exist in Redis.")
raise AssertionError
raise AssertionError

@keyword('Redis Key Should Not Be Exist')
def check_if_key_not_exists(self, redis_conn, key):
""" Keyword will successed if specify key doesn't exist in Redis
Arguments:
- redis_conn: Redis connection object
- key: String keyword to find.
Examples:
| ${not_exist}= | Redis Key Should Not Be Exist | ${redis_conn} | BARCODE|1234567890 |
"""
if redis_conn.exists(key):
logger.error("Key " + key + " exist in Redis.")
raise AssertionError
7 changes: 7 additions & 0 deletions tests/test_RedisLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,12 @@ def test_flush_all(self):
self.assertIsNone(home_address)
self.assertIsNone(name)

def test_check_if_key_not_exists(self):
self.redis.check_if_key_not_exists(self.fake_redis, 'non_existing_key')

def test_check_if_key_not_exists_with_existing_key(self):
with self.assertRaises(AssertionError):
self.redis.check_if_key_not_exists(self.fake_redis, 'name')

def tearDown(self):
self.fake_redis.flushall()

0 comments on commit a830ce8

Please sign in to comment.