def test_post_adds_points_to_location(self): self.policy.SetProbability(1) user = self.make_user('chris', location='Austin TX') user.add_auth_id('email:[email protected]') self.app.post('/api/v1/github', self.POST) location = Location.get_by_id('austin-tx') # TODO: figure out how to test this! if location is not None: self.assertEqual(location.total, 2)
def test_post_adds_points_to_location(self): self.policy.SetProbability(1) user = self.make_user('marcus', location='Austin TX') user.add_auth_id('email:[email protected]') self.app.post('/api/v1/bitbucket', self.POST) location = Location.get_by_id('austin-tx') # TODO: figure out how to test this! if location is not None: self.assertEqual(location.total, 1)
def users_by_location(request, location_slug, template_name='people/people_list.html'): users = User.query(User.location_slug == location_slug) users.order(-ndb.GenericProperty('total')).fetch(1000) location = Location.get_by_id(location_slug) return render_to_response(template_name, {'users':users, 'location': location, 'slug': location_slug}, context_instance=RequestContext(request))
def test_post_adds_points_to_location(self): self.policy.SetProbability(1) user = self.make_user('marcus', location='Austin TX') user.add_auth_id('email:[email protected]') self.app.post('/api/v1/bitbucket', self.POST) tasks = self.taskqueue_stub.GetTasks('default') self.assertEqual(3, len(tasks)) # Run the task task = tasks[0] deferred.run(base64.b64decode(task['body'])) location = Location.get_by_id('austin-tx') self.assertEqual(location.total, 11)
def test_post_adds_points_to_location(self): self.policy.SetProbability(1) user = self.make_user('chris', location='Austin TX') user.add_auth_id('email:[email protected]') self.app.post('/api/v1/github', self.POST) tasks = self.taskqueue_stub.GetTasks('default') self.assertEqual(5, len(tasks)) # Run the task task = tasks[0] deferred.run(base64.b64decode(task['body'])) location = Location.get_by_id('austin-tx') self.assertEqual(location.total, 12)
def users_by_location(request, location_slug, template_name='people/people_list.html'): limit = 100 cursor = request.GET.get('cursor') if cursor: cursor = Cursor(urlsafe=cursor) query = User.query(User.location_slug == location_slug) query = query.order(-ndb.GenericProperty('total')) models, next_cursor, more = query.fetch_page(limit, start_cursor=cursor) location = Location.get_by_id(location_slug) return render_to_response(template_name, {'next':next_cursor, 'more':more, 'users':models, 'location': location, 'slug': location_slug}, context_instance=RequestContext(request))