def create_tables(self, add_default=True): """Initialise the database schema from an empty database.""" logging.info("Creating database tables") from pytrainer.core.sport import Sport from pytrainer.core.equipment import Equipment from pytrainer.waypoint import Waypoint from pytrainer.core.activity import Lap from pytrainer.athlete import Athletestat DeclarativeBase.metadata.create_all(self.engine) if add_default: for item in [Sport(name=u"Mountain Bike", weight=0.0, color=color_from_hex_string("0000ff")), Sport(name=u"Bike", weight=0.0, color=color_from_hex_string("00ff00")), Sport(name=u"Run", weight=0.0, color=color_from_hex_string("ffff00"))]: self.session.add(item) self.session.commit()
def _create_sport(self, row): sport = Sport() sport.id = row[0] sport.name = unicode(row[1]) sport.weight = row[2] sport.met = row[3] sport.max_pace = row[4] sport.color = color_from_hex_string(row[5]) return sport
def create_tables(self, add_default=True): """Initialise the database schema from an empty database.""" logging.info("Creating database tables") from pytrainer.core.sport import Sport from pytrainer.core.equipment import Equipment from pytrainer.waypoint import Waypoint from pytrainer.core.activity import Lap from pytrainer.athlete import Athletestat DeclarativeBase.metadata.create_all(self.engine) if add_default: for item in [ Sport(name=u"Mountain Bike", weight=0.0, color=color_from_hex_string("0000ff")), Sport(name=u"Bike", weight=0.0, color=color_from_hex_string("00ff00")), Sport(name=u"Run", weight=0.0, color=color_from_hex_string("ffff00")) ]: self.session.add(item) self.session.commit()
def test_color_from_hex_string_should_correctly_decode_hex_value(self): color = color_from_hex_string("fab") self.assertEquals(0xfab, color.rgb_val)
def test_color_from_hex_string_should_correctly_decode_hex_value(self): color = color_from_hex_string("fab") self.assertEqual(0xfab, color.rgb_val)
def process_result_value(self, value, dialect): return color_from_hex_string(value)