Example #1
0
 def test_write_against_file_contents(self):
     filename = u'tests/testdata/simple_1.concrete'
     key = 'comm'
     with open(filename, 'rb') as f:
         f_buf = f.read()
         comm = read_communication_from_buffer(f_buf)
         with RedisServer(loglevel='warning') as server:
             redis_db = Redis(port=server.port)
             write_communication_to_redis_key(redis_db, key, comm)
             self.assertEquals(f_buf, redis_db.get(key))
Example #2
0
 def test_read_write_fixed_point(self):
     key = 'comm'
     comm = create_comm('comm-1')
     with RedisServer(loglevel='warning') as server:
         redis_db = Redis(port=server.port)
         buf_1 = write_communication_to_redis_key(redis_db, key, comm)
         buf_2 = write_communication_to_redis_key(
             redis_db, key,
             read_communication_from_redis_key(redis_db, key)
         )
         self.assertEquals(buf_1, buf_2)
Example #3
0
def test_write_communication_to_redis_key(mock_write_communication_to_buffer):
    redis = Mock(set=Mock())
    mock_write_communication_to_buffer.side_effect = [sentinel.buf]
    write_communication_to_redis_key(redis, sentinel.key, sentinel.comm)
    redis.set.assert_called_once_with(sentinel.key, sentinel.buf)
    mock_write_communication_to_buffer.assert_called_once_with(sentinel.comm)
Example #4
0
def test_write_communication_to_redis_key(mock_write_communication_to_buffer):
    redis = Mock(set=Mock())
    mock_write_communication_to_buffer.side_effect = [sentinel.buf]
    write_communication_to_redis_key(redis, sentinel.key, sentinel.comm)
    redis.set.assert_called_once_with(sentinel.key, sentinel.buf)
    mock_write_communication_to_buffer.assert_called_once_with(sentinel.comm)