|  | @@ -1,6 +1,8 @@
 | 
	
		
			
				|  |  |  """Tests for the CouchbaseBackend."""
 | 
	
		
			
				|  |  |  from __future__ import absolute_import, unicode_literals
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +from datetime import timedelta
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  import pytest
 | 
	
		
			
				|  |  |  from case import MagicMock, Mock, patch, sentinel, skip
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -59,9 +61,19 @@ class test_CouchbaseBackend:
 | 
	
		
			
				|  |  |          assert x.get('1f3fab') == sentinel.retval
 | 
	
		
			
				|  |  |          x._connection.get.assert_called_once_with('1f3fab')
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    def test_set(self):
 | 
	
		
			
				|  |  | +    def test_set_no_expires(self):
 | 
	
		
			
				|  |  |          self.app.conf.couchbase_backend_settings = None
 | 
	
		
			
				|  |  |          x = CouchbaseBackend(app=self.app)
 | 
	
		
			
				|  |  | +        x.expires = None
 | 
	
		
			
				|  |  | +        x._connection = MagicMock()
 | 
	
		
			
				|  |  | +        x._connection.set = MagicMock()
 | 
	
		
			
				|  |  | +        # should return None
 | 
	
		
			
				|  |  | +        assert x.set(sentinel.key, sentinel.value) is None
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    def test_set_expires(self):
 | 
	
		
			
				|  |  | +        self.app.conf.couchbase_backend_settings = None
 | 
	
		
			
				|  |  | +        x = CouchbaseBackend(app=self.app, expires=30)
 | 
	
		
			
				|  |  | +        assert x.expires == 30
 | 
	
		
			
				|  |  |          x._connection = MagicMock()
 | 
	
		
			
				|  |  |          x._connection.set = MagicMock()
 | 
	
		
			
				|  |  |          # should return None
 | 
	
	
		
			
				|  | @@ -107,3 +119,20 @@ class test_CouchbaseBackend:
 | 
	
		
			
				|  |  |              assert x.username == 'johndoe'
 | 
	
		
			
				|  |  |              assert x.password == 'mysecret'
 | 
	
		
			
				|  |  |              assert x.port == 123
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    def test_expires_defaults_to_config(self):
 | 
	
		
			
				|  |  | +        self.app.conf.result_expires = 10
 | 
	
		
			
				|  |  | +        b = CouchbaseBackend(expires=None, app=self.app)
 | 
	
		
			
				|  |  | +        assert b.expires == 10
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    def test_expires_is_int(self):
 | 
	
		
			
				|  |  | +        b = CouchbaseBackend(expires=48, app=self.app)
 | 
	
		
			
				|  |  | +        assert b.expires == 48
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    def test_expires_is_None(self):
 | 
	
		
			
				|  |  | +        b = CouchbaseBackend(expires=None, app=self.app)
 | 
	
		
			
				|  |  | +        assert b.expires == self.app.conf.result_expires.total_seconds()
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    def test_expires_is_timedelta(self):
 | 
	
		
			
				|  |  | +        b = CouchbaseBackend(expires=timedelta(minutes=1), app=self.app)
 | 
	
		
			
				|  |  | +        assert b.expires == 60
 |