Skip to content

Commit

Permalink
Fix failing tests and add more Python versions to Travis
Browse files Browse the repository at this point in the history
  • Loading branch information
beamerblvd committed Nov 1, 2017
1 parent 58528ea commit e8d2864
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ python:
- '3.2'
- '3.3'
- '3.4'
- '3.5'
- '3.6'
- pypy
- pypy3
install:
- pip install .
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]] || [[ $TRAVIS_PYTHON_VERSION == 3.4 ]]; then pip install .[lua]; fi
- if [[ "$TRAVIS_PYTHON_VERSION" =~ ^(2.7|3.4|3.5|3.6)$ ]]; then pip install .[lua]; fi
script: python setup.py nosetests
deploy:
provider: pypi
Expand Down
21 changes: 11 additions & 10 deletions mockredis/tests/test_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
LIST1, LIST2,
SET1,
VAL1, VAL2, VAL3, VAL4,
bVAL1, bVAL2, bVAL3, bVAL4,
LPOP_SCRIPT
)

Expand Down Expand Up @@ -110,7 +111,7 @@ def test_register_script_lpush(self):
script(keys=[LIST1], args=[VAL1, VAL2])

# validate insertion
eq_([VAL2, VAL1], self.redis.lrange(LIST1, 0, -1))
eq_([bVAL2, bVAL1], self.redis.lrange(LIST1, 0, -1))

def test_register_script_lpop(self):
self.redis.lpush(LIST1, VAL2, VAL1)
Expand All @@ -122,7 +123,7 @@ def test_register_script_lpop(self):

# validate lpop
eq_(VAL1, list_item)
eq_([VAL2], self.redis.lrange(LIST1, 0, -1))
eq_([bVAL2], self.redis.lrange(LIST1, 0, -1))

def test_register_script_rpoplpush(self):
self.redis.lpush(LIST1, VAL2, VAL1)
Expand All @@ -134,8 +135,8 @@ def test_register_script_rpoplpush(self):
script(keys=[LIST1, LIST2])

# validate rpoplpush
eq_([VAL1], self.redis.lrange(LIST1, 0, -1))
eq_([VAL2, VAL3, VAL4], self.redis.lrange(LIST2, 0, -1))
eq_([bVAL1], self.redis.lrange(LIST1, 0, -1))
eq_([bVAL2, bVAL3, bVAL4], self.redis.lrange(LIST2, 0, -1))

def test_register_script_rpop_lpush(self):
self.redis.lpush(LIST1, VAL2, VAL1)
Expand All @@ -150,8 +151,8 @@ def test_register_script_rpop_lpush(self):
script(keys=[LIST1, LIST2])

# validate rpop and then lpush
eq_([VAL1], self.redis.lrange(LIST1, 0, -1))
eq_([VAL2, VAL3, VAL4], self.redis.lrange(LIST2, 0, -1))
eq_([bVAL1], self.redis.lrange(LIST1, 0, -1))
eq_([bVAL2, bVAL3, bVAL4], self.redis.lrange(LIST2, 0, -1))

def test_register_script_client(self):
# lpush two values in LIST1 in first instance of redis
Expand All @@ -170,16 +171,16 @@ def test_register_script_client(self):

# validate lpop from LIST1 in redis2
eq_(VAL3, list_item)
eq_([VAL4], redis2.lrange(LIST1, 0, -1))
eq_([VAL1, VAL2], self.redis.lrange(LIST1, 0, -1))
eq_([bVAL4], redis2.lrange(LIST1, 0, -1))
eq_([bVAL1, bVAL2], self.redis.lrange(LIST1, 0, -1))

def test_eval_lpush(self):
# lpush two values
script_content = "redis.call('LPUSH', KEYS[1], ARGV[1], ARGV[2])"
self.redis.eval(script_content, 1, LIST1, VAL1, VAL2)

# validate insertion
eq_([VAL2, VAL1], self.redis.lrange(LIST1, 0, -1))
eq_([bVAL2, bVAL1], self.redis.lrange(LIST1, 0, -1))

def test_eval_lpop(self):
self.redis.lpush(LIST1, VAL2, VAL1)
Expand All @@ -190,7 +191,7 @@ def test_eval_lpop(self):

# validate lpop
eq_(VAL1, list_item)
eq_([VAL2], self.redis.lrange(LIST1, 0, -1))
eq_([bVAL2], self.redis.lrange(LIST1, 0, -1))

def test_eval_lrem(self):
self.redis.delete(LIST1)
Expand Down

0 comments on commit e8d2864

Please sign in to comment.