예제 #1
0
 def add(self, **kw):
     statistic = model.Statistic()
     statistic.km = kw['km']
     statistic.lng = kw['lng']
     statistic.lat = kw['lat']
     statistic.device_id = kw['device_id']
     DBSession.add(statistic)
예제 #2
0
파일: root.py 프로젝트: puria/rocco
 def add(self, **kw):
     statistic = model.Statistic()
     statistic.km = kw["km"]
     statistic.lng = kw["lng"]
     statistic.lat = kw["lat"]
     statistic.device_id = kw["device_id"]
     DBSession.add(statistic)
예제 #3
0
파일: __init__.py 프로젝트: puria/rocco
 def setUp(self):
     """Prepare model test fixture."""
     try:
         new_attrs = {}
         new_attrs.update(self.attrs)
         new_attrs.update(self.do_get_dependencies())
         self.obj = self.klass(**new_attrs)
         DBSession.add(self.obj)
         DBSession.flush()
         return self.obj
     except:
         DBSession.rollback()
         raise
예제 #4
0
 def setUp(self):
     """Prepare model test fixture."""
     try:
         new_attrs = {}
         new_attrs.update(self.attrs)
         new_attrs.update(self.do_get_dependencies())
         self.obj = self.klass(**new_attrs)
         DBSession.add(self.obj)
         DBSession.flush()
         return self.obj
     except:
         DBSession.rollback()
         raise
예제 #5
0
 def by_user_name(cls, username):
     """Return the user object whose user name is ``username``."""
     return DBSession.query(cls).filter_by(user_name=username).first()
예제 #6
0
 def by_email_address(cls, email):
     """Return the user object whose email address is ``email``."""
     return DBSession.query(cls).filter_by(email_address=email).first()
예제 #7
0
파일: root.py 프로젝트: puria/rocco
 def me(self, device_id):
     query = DBSession.query(func.sum(model.Statistic.km)).filter(model.Statistic.device_id == device_id)
     distance = query.scalar()
     return str(round(distance * 1000))
예제 #8
0
파일: __init__.py 프로젝트: puria/rocco
 def test_query_obj(self):
     """Model objects can be queried"""
     obj = DBSession.query(self.klass).one()
     for key, value in self.attrs.iteritems():
         assert_equals(getattr(obj, key), value)
예제 #9
0
파일: __init__.py 프로젝트: puria/rocco
 def tearDown(self):
     """Finish model test fixture."""
     DBSession.rollback()
예제 #10
0
파일: auth.py 프로젝트: puria/rocco
 def by_email_address(cls, email):
     """Return the user object whose email address is ``email``."""
     return DBSession.query(cls).filter_by(email_address=email).first()
예제 #11
0
파일: auth.py 프로젝트: puria/rocco
 def by_user_name(cls, username):
     """Return the user object whose user name is ``username``."""
     return DBSession.query(cls).filter_by(user_name=username).first()
예제 #12
0
 def me(self, device_id):
     query = DBSession.query(func.sum(
         model.Statistic.km)).filter(model.Statistic.device_id == device_id)
     distance = query.scalar()
     return str(round(distance * 1000))
예제 #13
0
 def test_query_obj(self):
     """Model objects can be queried"""
     obj = DBSession.query(self.klass).one()
     for key, value in self.attrs.iteritems():
         assert_equals(getattr(obj, key), value)
예제 #14
0
 def tearDown(self):
     """Finish model test fixture."""
     DBSession.rollback()