def test_completed_sort_none_completed(self): setup_onboarding(self.quest, self.mission) db.cypher_query('MATCH (a:OnboardingTask {title: "Mission Setup"}) ' 'SET a.completed=False RETURN a') uncompleted_sort, completed_count = order_tasks( self.mission.object_uuid) self.assertEqual(completed_count, 0)
def test_uncompleted_sort(self): setup_onboarding(self.quest, self.mission) db.cypher_query('MATCH (a:OnboardingTask {title: "Mission Setup"}) ' 'SET a.completed=False RETURN a') uncompleted_sort, completed_count = order_tasks( self.mission.object_uuid) self.assertEqual(len(uncompleted_sort), len(settings.ONBOARDING_TASKS)) for item in range(0, len(settings.ONBOARDING_TASKS) - 1): self.assertEqual(uncompleted_sort[item]['priority'], item + 1)
def test_set_bank_setup(self): self.quest.account_verified = "verified" self.quest.save() setup_onboarding(self.quest, self.mission) query = 'MATCH (a:Mission {object_uuid: "%s"})-[:MUST_COMPLETE]->' \ '(task:OnboardingTask {title: "%s"}) RETURN task' % ( self.mission.object_uuid, settings.BANK_SETUP_TITLE) res, _ = db.cypher_query(query) self.assertTrue(res.one['completed'])
def test_set_quest_about(self): self.quest.about = "some short summary" self.quest.save() setup_onboarding(self.quest, self.mission) query = 'MATCH (a:Mission {object_uuid: "%s"})-[:MUST_COMPLETE]->' \ '(task:OnboardingTask {title: "%s"}) RETURN task' % ( self.mission.object_uuid, settings.QUEST_ABOUT_TITLE) res, _ = db.cypher_query(query) self.assertTrue(res.one['completed'])
def test_set_wallpaper(self): self.quest.wallpaper_pic = "something.png" self.quest.save() setup_onboarding(self.quest, self.mission) query = 'MATCH (a:Mission {object_uuid: "%s"})-[:MUST_COMPLETE]->' \ '(task:OnboardingTask {title: "%s"}) RETURN task' % ( self.mission.object_uuid, settings.QUEST_WALLPAPER_TITLE) res, _ = db.cypher_query(query) self.assertTrue(res.one['completed'])
def test_completed_sort_one_completed(self): self.quest.account_verified = "verified" self.quest.save() setup_onboarding(self.quest, self.mission) db.cypher_query('MATCH (a:OnboardingTask {title: "Mission Setup"}) ' 'SET a.completed=False RETURN a') uncompleted_sort, completed_count = order_tasks( self.mission.object_uuid) self.assertEqual(completed_count, 1) self.assertTrue( uncompleted_sort[len(uncompleted_sort) - 1]['completed'])
def test_mission_settings_completed_about(self): self.quest.about = "some short summary" self.quest.save() setup_onboarding(self.quest, self.mission) self.client.login(username=self.user.username, password=self.password) url = reverse('mission_settings', kwargs={ 'object_uuid': self.mission.object_uuid, 'slug': self.mission.get_mission_title() }) res = self.client.get(url) self.assertEqual(res.status_code, status.HTTP_200_OK)
def test_mission_settings_completed_wallpaper(self): self.quest.wallpaper_pic = "helloworld.png" self.quest.save() setup_onboarding(self.quest, self.mission) self.client.login(username=self.user.username, password=self.password) url = reverse('mission_settings', kwargs={ 'object_uuid': self.mission.object_uuid, 'slug': self.mission.get_mission_title() }) res = self.client.get(url) self.assertEqual(res.status_code, status.HTTP_200_OK)
def setUp(self): db.cypher_query('MATCH (a) OPTIONAL MATCH (a)-[r]-() DELETE a, r') self.factory = APIRequestFactory() self.client = Client() self.email = "*****@*****.**" self.password = "******" create_user_util_test(self.email) self.pleb = Pleb.nodes.get(email=self.email) self.user = User.objects.get(email=self.email) self.pleb.email_verified = True self.pleb.save() cache.clear() self.mission = Mission(owner_username=self.user.username, title=str(uuid1()), focus_on_type="advocacy", focus_name="testing advocacy", district=None).save() self.quest = Quest(owner_username=self.pleb.username).save() self.quest.missions.connect(self.mission) self.quest.owner.connect(self.pleb) setup_onboarding(self.quest, self.mission)
def setup_onboarding_retroactive(self): for mission in Mission.nodes.all(): quest = Mission.get_quest(mission.object_uuid) setup_onboarding(quest, mission)
def test_verify_same_onboarding_task_list(self): temp_list = copy.deepcopy(settings.ONBOARDING_TASKS) setup_onboarding(self.quest, self.mission) self.assertEqual(temp_list, settings.ONBOARDING_TASKS)