<s> import apiserver . const as C <EOL> from datastore . slabutil import * <EOL> from ConfigParser import ConfigParser <EOL> INLINE_SIZE = <NUM_LIT> <EOL> PER_SLAB = <NUM_LIT> <EOL> SLAB_LRU_SIZE = <NUM_LIT:8> <EOL> def pytest_funcarg__config ( request ) : <EOL> "<STR_LIT>" <EOL> cfg = ConfigParser ( ) <EOL> cfg . add_section ( C . DATASTORE ) <EOL> for k in [ C . CHANGESETS_INLINE_SIZE , C . NODES_INLINE_SIZE , <EOL> C . RELATIONS_INLINE_SIZE , C . WAYS_INLINE_SIZE ] : <EOL> cfg . set ( C . DATASTORE , k , str ( INLINE_SIZE ) ) <EOL> for k in [ C . CHANGESETS_PER_SLAB , C . NODES_PER_SLAB , <EOL> C . RELATIONS_PER_SLAB , C . WAYS_PER_SLAB ] : <EOL> cfg . set ( C . DATASTORE , k , str ( PER_SLAB ) ) <EOL> return cfg <EOL> def test_use_slab ( config ) : <EOL> "<STR_LIT>" <EOL> slabutil_init ( config ) <EOL> for ns in [ C . CHANGESET , C . NODE , C . RELATION , C . WAY ] : <EOL> assert slabutil_use_slab ( ns ) is True <EOL> for ns in [ C . GEODOC ] : <EOL> assert slabutil_use_slab ( ns ) is False <EOL> def test_get_config ( config ) : <EOL> "<STR_LIT>" <EOL> slabutil_init ( config ) <EOL> for ns in [ C . CHANGESET , C . NODE , C . RELATION , C . WAY ] : <EOL> inline_size , per_slab = slabutil_get_config ( ns ) <EOL> assert inline_size == INLINE_SIZE <EOL> assert per_slab == PER_SLAB <EOL> def test_groupkeys ( config ) : <EOL> "<STR_LIT>" <EOL> slabutil_init ( config ) <EOL> expected_node_slabset = { <EOL> "<STR_LIT>" : set ( [ '<STR_LIT:0>' , '<STR_LIT:1>' , '<STR_LIT>' , '<STR_LIT>' ] ) , <EOL> "<STR_LIT>" : set ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) , <EOL> "<STR_LIT>" : set ( [ '<STR_LIT>' ] ) <EOL> } <EOL> expected_way_slabset = { <EOL> "<STR_LIT>" : set ( [ '<STR_LIT:0>' , '<STR_LIT:1>' , '<STR_LIT>' , '<STR_LIT>' ] ) , <EOL> "<STR_LIT>" : set ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) , <EOL> "<STR_LIT>" : set ( [ '<STR_LIT>' ] ) <EOL> } <EOL> expected_relation_slabset = { <EOL> "<STR_LIT>" : set ( [ '<STR_LIT:0>' , '<STR_LIT:1>' , '<STR_LIT>' , '<STR_LIT>' ] ) , <EOL> "<STR_LIT>" : set ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) , <EOL> "<STR_LIT>" : set ( [ '<STR_LIT>' ] ) <EOL> } <EOL> keys = map ( str , [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> slabset = slabutil_group_keys ( C . NODE , keys ) <EOL> assert slabset == expected_node_slabset <EOL> slabset = slabutil_group_keys ( C . WAY , keys ) <EOL> assert slabset == expected_way_slabset <EOL> slabset = slabutil_group_keys ( C . RELATION , keys ) <EOL> assert slabset == expected_relation_slabset <EOL> def test_groupkeys_nonnumeric ( config ) : <EOL> "<STR_LIT>" <EOL> slabutil_init ( config ) <EOL> expected_geodoc_slabset = { <EOL> "<STR_LIT>" : set ( [ "<STR_LIT>" ] ) , <EOL> "<STR_LIT>" : set ( [ "<STR_LIT>" ] ) <EOL> } <EOL> keys = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> slabset = slabutil_group_keys ( C . GEODOC , keys ) <EOL> assert slabset == expected_geodoc_slabset <EOL> def test_make_slabkey ( config ) : <EOL> "<STR_LIT>" <EOL> slabutil_init ( config ) <EOL> expected = [ <EOL> ( C . CHANGESET , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( C . GEODOC , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( C . NODE , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( C . RELATION , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( C . WAY , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> for ( ns , key , slabkey ) in expected : <EOL> v = slabutil_make_slabkey ( ns , key ) <EOL> assert v == slabkey </s>
