def test_get_mission(self): quest = Quest(owner_username=self.pleb.username).save() quest.owner.connect(self.pleb) mission = Mission(owner_username=self.pleb.username).save() quest.missions.connect(mission) mission.associated_with.connect(self.question) res = Question.get_mission(self.question.object_uuid) self.assertEqual(res['id'], mission.object_uuid) mission.delete() quest.delete()
def test_get_can_downvote_mission_owner(self): quest = Quest(owner_username=self.pleb.username).save() quest.owner.connect(self.pleb) mission = Mission(owner_username=self.pleb.username).save() quest.missions.connect(mission) question = Question(content='test content title', title=str(uuid1())).save() mission.associated_with.connect(question) factory = APIRequestFactory() request = factory.get('') request.user = self.user res = VotableContentSerializer( question, context={'request': request}).data self.assertTrue(res['can_downvote']['status']) mission.delete() quest.delete()
def test_create_with_mission(self): from sb_quests.neo_models import Quest from sb_missions.neo_models import Mission self.client.force_authenticate(user=self.user) url = reverse("question-solutions", kwargs={'object_uuid': self.question.object_uuid}) quest = Quest(owner_username=self.pleb.username).save() quest.owner.connect(self.pleb) mission = Mission(owner_username=self.pleb.username).save() quest.missions.connect(mission) mission.associated_with.connect(self.question) data = { "question": self.question.object_uuid, "content": self.solution.content } response = self.client.post(url, data, format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) mission.delete() quest.delete()
def test_rep_already_has_campaign(self): try: official = PublicOfficial.nodes.get(bioguideid="MIL000290") official.delete() except (PublicOfficial.DoesNotExist, DoesNotExist): pass official = PublicOfficial(bioguideid="MIL000290", first_name="Kathy", last_name="Crawford", state_district="38", state_chamber="lower", state="mi").save() campaign = Quest(first_name=official.first_name, last_name=official.last_name).save() official.quest.connect(campaign) res = create_and_attach_state_level_reps.apply_async( kwargs={'rep_data': self.json_data}) while not res.ready(): time.sleep(1) self.assertTrue(res.result) official.delete() campaign.delete()
def test_get_can_downvote_comment_mission_owner(self): quest = Quest(owner_username=self.pleb.username).save() quest.owner.connect(self.pleb) mission = Mission(owner_username=self.pleb.username).save() quest.missions.connect(mission) question = Question(content='test content title', title=str(uuid1())).save() mission.associated_with.connect(question) question.comments.connect(self.comment) self.comment.parent_type = "question" self.comment.parent_id = question.object_uuid self.comment.owner_username = "******" self.comment.save() factory = APIRequestFactory() request = factory.get('') request.user = self.user res = VotableContentSerializer( self.comment, context={'request': request}).data self.assertTrue(res['can_flag']['status']) mission.delete() quest.delete() self.comment.owner_username = self.pleb.username self.comment.save()