<s> import unittest <EOL> from cubes . sql . mapper import StarSchemaMapper , distill_naming <EOL> from cubes . model import Attribute <EOL> from . . common import CubesTestCaseBase , create_provider <EOL> class MapperTestCase ( CubesTestCaseBase ) : <EOL> def setUp ( self ) : <EOL> super ( MapperTestCase , self ) . setUp ( ) <EOL> self . provider = create_provider ( "<STR_LIT>" ) <EOL> self . cube = self . provider . cube ( "<STR_LIT>" ) <EOL> naming = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> self . naming = distill_naming ( naming ) <EOL> self . mapper = StarSchemaMapper ( self . cube , self . naming ) <EOL> self . mapper . mappings = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> def test_logical_reference ( self ) : <EOL> dim = self . provider . dimension ( "<STR_LIT:date>" ) <EOL> attr = Attribute ( "<STR_LIT>" , dimension = dim ) <EOL> self . assertEqual ( "<STR_LIT>" , attr . ref ) <EOL> dim = self . provider . dimension ( "<STR_LIT>" ) <EOL> attr = Attribute ( "<STR_LIT>" , dimension = dim ) <EOL> self . assertEqual ( "<STR_LIT>" , attr . ref ) <EOL> dim = self . provider . dimension ( "<STR_LIT>" ) <EOL> attr = Attribute ( "<STR_LIT>" , dimension = dim ) <EOL> self . assertEqual ( "<STR_LIT>" , attr . ref ) <EOL> attr = Attribute ( "<STR_LIT>" , dimension = None ) <EOL> self . assertEqual ( "<STR_LIT>" , attr . ref ) <EOL> def assertMapping ( self , expected , logical_ref , mapper = None ) : <EOL> """<STR_LIT>""" <EOL> attr = self . cube . attribute ( logical_ref ) <EOL> mapper = mapper or self . mapper <EOL> ref = mapper [ attr ] <EOL> sref = ref [ <NUM_LIT:1> ] + "<STR_LIT:.>" + ref [ <NUM_LIT:2> ] <EOL> self . assertEqual ( expected , sref ) <EOL> def test_physical_refs_dimensions ( self ) : <EOL> """<STR_LIT>""" <EOL> self . mapper . naming . dimension_prefix = "<STR_LIT>" <EOL> self . mapper . naming . dimension_suffix = "<STR_LIT>" <EOL> self . assertMapping ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertMapping ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertMapping ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . mapper . naming . dimension_prefix = "<STR_LIT>" <EOL> self . assertMapping ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertMapping ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertMapping ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertMapping ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> def test_physical_refs_flat_dims ( self ) : <EOL> self . cube . fact = None <EOL> self . assertMapping ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> def test_physical_refs_facts ( self ) : <EOL> """<STR_LIT>""" <EOL> fact = self . cube . fact <EOL> self . cube . fact = None <EOL> self . assertMapping ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . cube . fact = fact <EOL> def test_physical_refs_with_mappings_and_locales ( self ) : <EOL> """<STR_LIT>""" <EOL> self . mapper . mappings = self . cube . mappings <EOL> sk_mapper = StarSchemaMapper ( self . cube , self . naming , locale = "<STR_LIT>" ) <EOL> de_mapper = StarSchemaMapper ( self . cube , self . naming , locale = "<STR_LIT>" ) <EOL> self . assertMapping ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertMapping ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> self . assertMapping ( "<STR_LIT>" , <EOL> "<STR_LIT>" , sk_mapper ) <EOL> self . assertMapping ( "<STR_LIT>" , <EOL> "<STR_LIT>" , de_mapper ) <EOL> self . assertMapping ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertMapping ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertMapping ( "<STR_LIT>" , "<STR_LIT>" , <EOL> sk_mapper ) <EOL> self . assertMapping ( "<STR_LIT>" , "<STR_LIT>" , <EOL> de_mapper ) <EOL> self . assertMapping ( "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> self . assertMapping ( "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> sk_mapper ) <EOL> self . assertMapping ( "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> de_mapper ) </s>
