예제 #1
0
 def testInsertAlertTitle(self):
     mytest = Alert()
     result = mytest.put()
     self.assertEqual(None, ndb.get(result).title)
     
     mytest1 = Alert(title='title')
     result1 = mytest1.put()
     self.assertEqual('title', ndb.get(result1).title)
    def test_insert_device(self):
        mytest = RateItUser()
        result = mytest.put()
        self.assertEqual(None, ndb.get(result).user_device)

        mytest1 = RateItUser(user_device='iPhone')
        result1 = mytest1.put()
        self.assertEqual('iPhone', ndb.get(result1).user_device)
 def test_insert_user_sex(self):
     mytest = RateItUser(user_sex='Male')
     result = mytest.put()
     self.assertEqual('male', ndb.get(result).user_sex)
     mytest1 = RateItUser(user_sex = 'female')
     result1 = mytest1.put()
     self.assertEqual('female', ndb.get(result1).user_sex)
     # entered text neither 'male'('Male') or 'female'('Female')
     mytest2 = RateItUser(user_sex='other')
     result2 = mytest2.put()
     self.assertEqual(None, ndb.get(result2).user_sex)
예제 #4
0
 def testInsertAlertType(self):
     mytest = Alert()
     result = mytest.put()
     self.assertEqual(None, ndb.get(result).type)
     
     mytest1 = Alert(type='Bus')
     result1 = mytest1.put()
     self.assertEqual('Bus', ndb.get(result1).type)
     
     mytest2 = Alert(type='Route')
     result2 = mytest2.put()
     self.assertEqual('Route, ndb.get(result2).type)
     
     mytest3 = Alert(type='Regional')
     result3 = mytest3.put()
     self.assertEqual('Regional', ndb.get(result3).type)
예제 #5
0
 def testInsertMessage(self):
     mytest = Alert()
     result = mytest.put()
     self.assertEqual(None, ndb.get(result).type)
     
     mytest1 = Alert(message='testing')
     result1 = mytest1.put()
     self.assertEqual('testing', ndb.get(result1).message)
     
     mytest2 = Alert(message='234324')
     result2 = mytest2.put()
     self.assertEqual('234324', ndb.get(result2).message)
     
     mytest3 = Alert(incident_type='fdjgidgjidjgidjgirgjrigjfigjdfgijdfigjdfigjfigjfigjfijgifjgifjgfigj')
     result3 = mytest3.put()
     self.assertEqual('fdjgidgjidjgidjgirgjrigjfigjdfgijdfigjdfigjfigjfigjfijgifjgifjgfigj', ndb.get(result3).message)
예제 #6
0
 def get(self):
     allArt = ArtPiece.query()
     for art in allArt:
         artKey = art.key
         artpiece = ndb.get(artKey)
         artpiece.remove_from_search_index()
         artKey.delete()
예제 #7
0
    def default(self, o):
        # If this is a key, you might want to grab the actual model.
        if isinstance(o, ndb.Key):
            o = ndb.get(o)

        if isinstance(o, ndb.Model):
            return ndb.to_dict(o)
        elif isinstance(o, (datetime, date, time)):
            return str(o)  # Or whatever other date format you're OK with...
예제 #8
0
    def default(self, o):
        # If this is a key, you might want to grab the actual model.
        if isinstance(o, ndb.Key):
            o = ndb.get(o)

        if isinstance(o, ndb.Model):
            return Gifhov.to_dict(o)
        elif isinstance(o, (datetime, date, time)):
            return str(o)  # Or whatever other date format you're OK with...
예제 #9
0
  def get(self, post_id):
    key = ndb.Key.from_path('Post', int(post_id), parent=blog_key())
    post = ndb.get(key)

    if not post:
      self.error(404)
      return

    self.render("permalink.html", post = post)
예제 #10
0
    def default(self, o):
        # If this is a key, you might want to grab the actual model.
        if isinstance(o, ndb.Key):
            o = ndb.get(o)

        if isinstance(o, ndb.Model):
            return o.to_dict()
        elif isinstance(o, (datetime, date, time)):
            return str(o)
예제 #11
0
 def default(self, o):
     if isinstance(o, Session):
         return str(o.sid)
     if isinstance(o, OAuthHmacToken):
         return o.token
     if isinstance(o, datetime):
         return o.isoformat()
     if isinstance(o, ndb.Key):
         assert isinstance(o, ndb.Key)
         #debug("encoding ndb.Key %s to JSON" % o)
         entity = o.get()
         if entity is None: return None
         return unicode(o.get().to_dict())
     if isinstance(o, db.Key):
         assert isinstance(o, db.Key)
         #debug("encoding db.Key %s to JSON" % o)
         return unicode(o)
     if isinstance(o, ndb.Key):
         return self.default(ndb.get(o))
     if isinstance(o, model.Data.Data):
         d = {"dataId": o.dataId, "field": o.field, "string": o.string}
         return d
         # if isinstance(o, model.DataNdb.Data):
     #     l = [o.dataId, o.field, o.string]
     #     return l
     if isinstance(o, ndb.Model):
         #debug("encoding NdbModel %s to JSON" % o)
         return o.to_dict()
     if isinstance(o, Columns):
         assert isinstance(o, Columns)
         #debug("encoding Columns %s to JSON" % o)
         return o.getDataTableCols()
         # if isinstance(o, dict):
     #     return o
     #debug("encoding unknown object %s, %s " % (type(o), o))
     return _JSONEncoder.default(self, o)
 def test_insert_born_year(self):
     mytest = RateItUser(user_born_year='1990')
     result = mytest.put()
     self.assertEqual('1990', ndb.get(result).user_born_year)
예제 #13
0
def dbSafeDelete(key):
    if db.get(key): db.delete(key)
 def test_insert_user_type(self):
     mytest = RateItUser(user_type='passenger')
     result = mytest.put()
     self.assertEqual('passenger', ndb.get(result).user_type)
 def test_insert_user(self):
     mytest = RateItUser(user=users.get_current_user())
     result = mytest.put()
     self.assertEqual(users.get_current_user(), ndb.get(result).user)
 def test_empty_input(self):
     mytest = RateItUser()
     result = mytest.put()
     self.assertEqual(None, ndb.get(result).user)
     self.assertEqual(None, ndb.get(result).user_type)
     self.assertEqual(None, ndb.get(result).user_sex)
     self.assertEqual(None, ndb.get(result).user_born_year)
     self.assertEqual(None, ndb.get(result).user_household_type)
     self.assertEqual(None, ndb.get(result).user_postcode)
     self.assertEqual(None, ndb.get(result).user_education)
     self.assertEqual(None, ndb.get(result).user_occupation)
     self.assertEqual(None, ndb.get(result).user_monthly_income)
     self.assertEqual(None, ndb.get(result).user_mobility_impairment)
     self.assertEqual(None, ndb.get(result).user_device)
     self.assertEqual(None, ndb.get(result).user_driver_licence)
     self.assertEqual(None, ndb.get(result).user_often_use)
     self.assertEqual(None, ndb.get(result).user_purpose_use)
예제 #17
0
파일: model.py 프로젝트: gkso/micolog
 def _categories():
     try:
         return ndb.get(self.categorie_keys)
     except:
         return []
 def test_insert_user_often_use(self):
     mytest = RateItUser(user_often_use='often use')
     result = mytest.put()
     self.assertEqual('often use', ndb.get(result).user_often_use)
 def test_insert_user_driver_licence(self):
     mytest = RateItUser(user_driver_licence='drivers licence')
     result = mytest.put()
     self.assertEqual('drivers licence', ndb.get(result).user_driver_licence)
예제 #20
0
def get_obstask_key(entry_id):
    data = ndb.get(ndb.Key('ObservationTask', long(entry_id) ))
    if data:
        data = data.key
    return data
 def test_insert_user_monthly_income(self):
     mytest = RateItUser(user_monthly_income='monthly income')
     result = mytest.put()
     self.assertEqual('monthly income', ndb.get(result).user_monthly_income)
 def test_insert_user_occupation(self):
     mytest = RateItUser(user_occupation='occupation')
     result = mytest.put()
     self.assertEqual('occupation', ndb.get(result).user_occupation)
 def test_insert_user_postcode(self):
     mytest = RateItUser(user_postcode='2000')
     result = mytest.put()
     self.assertEqual('2000', ndb.get(result).user_postcode)
 def test_insert_user_household_type(self):
     mytest = RateItUser(user_household_type='household')
     result = mytest.put()
     self.assertEqual('household', ndb.get(result).user_household_type)
 def test_insert_user_purpose_use(self):
     mytest = RateItUser(user_purpose_use='purpose use')
     result = mytest.put()
     self.assertEqual('purpose use', ndb.get(result).user_purpose_use)
예제 #26
0
파일: main.py 프로젝트: kalasoo/sellmystuff
	def get(self):
		item = ndb.get(self.request.get('img_id'))
		if item.picture:
			self.response.out.write(greeting.picture)
 def test_insert_user_mobility_impairment(self):
     mytest = RateItUser(user_mobility_impairment='mobility impairment')
     result = mytest.put()
     self.assertEqual('mobility impairment', ndb.get(result).user_mobility_impairment)
예제 #28
0
def dbSafeDelete(key):
  if db.get(key) :  db.delete(key)