def test_get_by_recent_miss_not_shared(self): Mission.create(editor=self.user.id, name="test mission 3", city="LA", state="CA", country='US') db.session.commit() recent = Mission.get_by_recent() self.assertEqual(len(recent), 2)
def setUp(self): self.user = User.register(email="*****@*****.**", username="******", password="******") self.mission = Mission.create(editor=self.user.id, name="test mission", city="Albany", state="NY", country='US') self.business = Business.create(name='Cuisine of Nepal', longitude=-122.42318, latitude=37.74097, id='iUockw0CUssKZLyoGJYEXA', city='San Francisco', state='CA', country='US') self.mission.businesses.append(self.business) self.report = Report.create(user_id=self.user.id, business_id='iUockw0CUssKZLyoGJYEXA', text='Best nepalese food I ever had!') db.session.commit() self.report2 = Report.create(user_id=self.user.id, mission_id=self.mission.id, text='The curry was devine!') db.session.commit()
def setUp(self): self.user = User.register(email="*****@*****.**", username="******", password="******") self.mission = Mission.create(editor=self.user.id, name="test mission", city="Albany", state="NY", country='US') self.mission.share() self.mission2 = Mission.create(editor=self.user.id, name="test mission 2", city="Ithica", state="NY", country='US') self.mission2.share() self.business = Business.create(name='Cuisine of Nepal', longitude=-122.42318, latitude=37.74097, id='iUockw0CUssKZLyoGJYEXA', city='San Francisco', state='CA', country='US') self.business2 = Business.create(name='Little Nepal', longitude=-122.41361, latitude=37.7391, id='Kx1WExNj5ogaFe0cyg9L6A', city='San Francisco', state='CA', country='US') self.mission.businesses.append(self.business) self.mission2.businesses.append(self.business2) db.session.commit()
def setUp(self): self.user = User.register(email="*****@*****.**", username="******", password="******") self.mission = Mission.create(editor=self.user.id, name="test mission", city="Albany", state="NY", country='US') self.mission.share() self.mission2 = Mission.create(editor=self.user.id, name="test mission 2", city="Ithica", state="NY", country='US') self.mission2.share() self.business = Business.create(name="Cusine of Nepal", id='82372347', city='San Francisco', state='CA', country='US', longitude=20.22, latitude=77.0) db.session.commit() self.report = Report.create(user_id=self.user.id, business_id=self.business.id, text="Amazing!") self.report = Report.create(user_id=self.user.id, mission_id=self.mission.id, text="Amazing Mission!") db.session.commit()
def test_get_by_recent(self): mission3 = Mission.create(editor=self.user.id, name="test mission 3", city="LA", state="CA", country='US') mission3.share() db.session.commit() recent = Mission.get_by_recent() self.assertEqual(len(recent), 3) self.assertEqual(recent[0], mission3)
def create_mission(): """Endpoint to create a mission.""" if not g.user: return Unauthorized() try: mission = Mission.create(editor=g.user.id, **request.json) db.session.commit() g.user.missions.append(mission) db.session.commit() except Exception as e: H.error_logging(e) return jsonify({'error': repr(e)}) return jsonify({'success': 'Mission Created!', 'mission': mission.serialize()})
def setUp(self): self.user = User.register( email='*****@*****.**', username='******', password='******') self.user2 = User.register( email='*****@*****.**', username='******', password='******') self.mission = Mission.create( editor=self.user.id, name='Food Truck Grand Tour', city='San Francisco', state='CA', country='US', description="The pletora of SF food trucks never ceases to amaze.") db.session.commit() self.client = app.test_client()
def post_team(room_code): sessid = request.cookies.get("sessid") you = Player.select(Player, Room).join(Room).where(Player.sessid == sessid, Room.code == room_code).get() room = you.room if you.queue_position != room.leader_queue: return HTTPError(400, "You are not the leader") team_ids = request.params.getall("team[]") team = room.players.where(Player.id << team_ids).execute() mission = Mission.create(room=room, leader=you, team_size=0) with db.atomic(): for plr in team: PlayerMission.insert(player=plr, mission=mission).execute() room.phase = "vote" room.save() message_data = { "mission_id": mission.id, "leader": {"id": you.id, "name": you.name}, "team": [{"id": plr.id, "name": plr.name} for plr in team], } post_message([Msg("team", message_data)], room=room)
def test_search_miss_not_shared(self): m3 = Mission.create( editor=self.user.id, name='I like cheese.', city='San Francisco', state='CA', country='US', description="What is there to explain. Let's get some cheese.") m3.businesses.append(self.business) db.session.commit() miss = Mission.search({ 'city': '', 'state': '', 'keywords': '', 'country': '', 'sort_by': 'recent' }) self.assertEqual(len(miss), 2)