Ejemplo n.º 1
0
                           message='Counter reached 3 while not expected')
    except Exception as e:
        pass


@jvmTestDecorator()
def testCommandReaderBasic(env, **kargs):
    env.expect('RG.TRIGGER', 'test1', 'this', 'is', 'a',
               'test').equal(['a', 'is', 'test', 'test1', 'this'])
    env.expect('RG.TRIGGER', 'test2', 'this', 'is', 'a',
               'test').equal(['a', 'is', 'test', 'test2', 'this'])
    env.expect('RG.TRIGGER', 'test3', 'this', 'is', 'a',
               'test').equal(['a', 'is', 'test', 'test3', 'this'])


@jvmTestDecorator(preExecute=putKeys({'x': 'foo', 'y': 'bar', 'z': 'foo'}))
def testUnregisterCallback(env, conn, **kargs):
    registrationId = env.cmd('RG.DUMPREGISTRATIONS')[0][1]
    env.cmd('RG.UNREGISTER', registrationId)
    env.expect('RG.PYEXECUTE', 'GB().count().run()').equal([[], []])


@jvmTestDecorator()
def testCommandOverride(env, results, errs, conn, **kargs):
    env.assertEqual(len(errs), 0)
    env.assertEqual(conn.execute_command('hset', 'h1', 'foo', 'bar'), 2)
    env.assertNotEqual(conn.execute_command('hget', 'h1', 'time'), None)

    env.assertEqual(conn.execute_command('hset', 'b1', 'foo', 'bar'), 1)
    env.assertEqual(conn.execute_command('hget', 'b1', 'time'), None)
Ejemplo n.º 2
0
from common import jvmTestDecorator
from common import putKeys


@jvmTestDecorator(preExecute=putKeys({'x': '1'}))
def testBasic(env, results, errs, **kargs):
    env.assertEqual(len(errs), 0)
    env.assertEqual(len(results), 1)
    env.assertEqual(results[0]['key'], 'x')
    env.assertEqual(results[0]['stringVal'], '1')


@jvmTestDecorator(preExecute=putKeys({'x': '1'}))
def testMap(env, results, errs, **kargs):
    env.assertEqual(len(errs), 0)
    env.assertEqual(len(results), 1)
    env.assertEqual(results[0], '1')


@jvmTestDecorator(preExecute=putKeys({'x': {'y': '1'}}))
def testForeach(env, results, errs, **kargs):
    env.assertEqual(len(errs), 0)
    env.assertEqual(len(results), 1)
    env.assertEqual(results[0]['hashVal']['test'], 'test')


@jvmTestDecorator(preExecute=putKeys({'x': '1', 'y': '2'}))
def testFilter(env, results, errs, **kargs):
    env.assertEqual(len(errs), 0)
    env.assertEqual(len(results), 1)
    env.assertEqual(results[0]['key'], 'x')
Ejemplo n.º 3
0
def testExecutionError(env, executionError, **kargs):
	env.assertIn('Test Exception', executionError)

@jvmTestDecorator()
def testClassNotExistsError(env, executionError, **kargs):
	env.assertIn('gears_tests.testClassNotExistsError', executionError)

@jvmTestDecorator()
def testClassWithoutMainFunction(env, executionError, **kargs):
	env.assertIn('main', executionError)

@jvmTestDecorator()
def testClassWithInvalidMainFunction(env, executionError, **kargs):
	env.assertIn('main', executionError)

@jvmTestDecorator(preExecute=putKeys({'x':'1'}))
def testMapError(env, results, errs, **kargs):
	env.assertEqual(len(results), 0)
	env.assertEqual(len(errs), 1)
	env.assertIn('Map Error', errs[0])

@jvmTestDecorator(preExecute=putKeys({'x':'1'}))
def testFilterError(env, results, errs, **kargs):
	env.assertEqual(len(results), 0)
	env.assertEqual(len(errs), 1)
	env.assertIn('Filter Error', errs[0])

@jvmTestDecorator(preExecute=putKeys({'x':['1', '2', '3']}))
def testFlatmapError(env, results, errs, **kargs):
	env.assertEqual(len(results), 0)
	env.assertEqual(len(errs), 1)
Ejemplo n.º 4
0
from common import jvmTestDecorator
from common import putKeys


@jvmTestDecorator(preExecute=putKeys({
    'pref1:1': '1',
    'pref2:1': '1',
    'pref3:1': '1'
}))
def testKeyReaderPattern(env, results, errs, **kargs):
    env.assertEqual(len(results), 1)
    env.assertEqual(results[0], 'pref1:1')


@jvmTestDecorator(preExecute=putKeys({
    'pref1:1': '1',
    'pref2:1': '1',
    'pref3:1': '1'
}))
def testKeyReaderNoValues(env, results, errs, **kargs):
    env.assertEqual(len(results), 0)


@jvmTestDecorator(preExecute=putKeys({
    'pref1:1': '1',
    'pref2:1': '1',
    'pref3:1': '1'
}))
def testKeyReaderNoScan(env, results, errs, **kargs):
    env.assertEqual(len(results), 0)
Ejemplo n.º 5
0
from common import jvmTestDecorator
from common import putKeys


@jvmTestDecorator()
def testAsyncRecordOnMap(env, results, errs, **kargs):
    env.assertEqual(len(errs), 0)
    env.assertEqual(len(results), 1)
    env.assertEqual(results, [env.shardsCount])


@jvmTestDecorator(preExecute=putKeys({'x': '1', 'y': '2'}))
def testAsyncRecordOnFilter(env, results, errs, **kargs):
    env.assertEqual(len(errs), 0)
    env.assertEqual(len(results), 1)
    env.assertEqual(results, ['x'])


@jvmTestDecorator(preExecute=putKeys({'x': '1', 'y': '2'}))
def testAsyncRecordOnForeach(env, results, errs, **kargs):
    env.assertEqual(len(errs), 0)
    env.assertEqual(len(results), 2)
    env.assertEqual(sorted(results), sorted(['x', 'y']))


@jvmTestDecorator()
def testAsyncRecrodMapRaiseError(env, errs, **kargs):
    env.assertEqual(len(errs), env.shardsCount)
    env.assertEqual(errs, ['error'] * env.shardsCount)