def setUp(self): self.request_factory = RequestFactory() self.idea = IdeaFactory() self.gallups = [ Gallup.objects.create(idea=self.idea), Gallup.objects.create(idea=self.idea) ] self.questions = [ Question.objects.create(text="Question #1", gallup=self.gallups[0]), Question.objects.create(text="Question #2", gallup=self.gallups[0]), Question.objects.create(text="Question #3", gallup=self.gallups[1]), Question.objects.create(text="Question #4", gallup=self.gallups[1]) ] self.options = [ Option.objects.create(text="Option #1", question=self.questions[0]), Option.objects.create(text="Option #2", question=self.questions[0]), Option.objects.create(text="Option #3", question=self.questions[1]), Option.objects.create(text="Option #4", question=self.questions[1]), Option.objects.create(text="Option #5", question=self.questions[2]), Option.objects.create(text="Option #6", question=self.questions[2]), Option.objects.create(text="Option #7", question=self.questions[3]), Option.objects.create(text="Option #8", question=self.questions[3]) ]
def setUp(self): self.user1 = UserSettingsFactory().user self.user2 = UserSettingsFactory().user self.admin = UserFactory( groups=[Group.objects.get(name=GROUP_NAME_ADMINS)]) self.moderator = UserFactory( groups=[Group.objects.get(name=GROUP_NAME_MODERATORS)]) self.idea1 = IdeaFactory(owners=[self.user1], title="Public Initiative", visibility=Idea.VISIBILITY_PUBLIC) IdeaFactory(owners=[self.user1, self.user2], title="Shared Initiative", visibility=Idea.VISIBILITY_DRAFT) IdeaFactory(owners=[self.user1], title="Draft Initiative", visibility=Idea.VISIBILITY_DRAFT) IdeaFactory(owners=[self.user2], title="Non-Owned Initiative", visibility=Idea.VISIBILITY_DRAFT)
def test_post_kua_initiative_missing(self): idea = IdeaFactory() resp = self.client.post('/api/kua/1.0/initiative/%d/status/create/' % idea.pk, content_type='application/json', data=json.dumps({'status': 'published'})) self.assertEqual(resp.status_code, 404) self.assertEqual( json.loads(resp.content)['failure'], "KuaInitiative matching query does not exist.")
def test_organization_initiatives_show_organization_name_as_owner(self): organization = OrganizationFactory(admins=[self.user1]) idea = IdeaFactory(owners=[], initiator_organization=organization) Favorite.objects.create(user=self.user1, content_object=idea) self.client.login(username=self.user1.username, password=DEFAULT_PASSWORD) resp = self.client.get( '/fi/kayttaja/%d/lista/?initiative_ct_id=&ct_natural_key=content.idea' % self.user1.pk) self.assertContains(resp, organization.name, count=1)
def setUp(self): self.request_factory = RequestFactory() self.user = UserFactory() self.ideas = ( IdeaFactory(), IdeaFactory(), ) idea_content_type = ContentType.objects.get_for_model(Idea) self.comments = ( CustomComment.objects.create(content_type=idea_content_type, object_pk=self.ideas[0].pk, user_name="A Person", comment="Comment #1", site_id=1), CustomComment.objects.create(content_type=idea_content_type, object_pk=self.ideas[1].pk, user_name="Someone", comment="Comment #2", site_id=1), )
def setUp(self): self.idea = IdeaFactory() idea_content_type = ContentType.objects.get_for_model(Idea) self.comments = ( CustomComment.objects.create(content_type=idea_content_type, object_pk=self.idea.pk, user_name="A Person", comment="Comment #1", site_id=1), CustomComment.objects.create(content_type=idea_content_type, object_pk=self.idea.pk, user_name="Someone", comment="Comment #2", site_id=1), )
def manual_set_up(self, public=True, login=False): if public: status = Idea.STATUS_PUBLISHED visibility = Idea.VISIBILITY_PUBLIC else: status = Idea.STATUS_DRAFT visibility = Idea.VISIBILITY_DRAFT self.user = UserFactory() self.idea = IdeaFactory( creator=self.user, status=status, visibility=visibility, ) if login: self.user = self.idea.creator self.client.login(username=self.user.username, password=DEFAULT_PASSWORD)
def test_detail(self): idea = IdeaFactory() data = self.get_json('/api/open/0.1/ideas/%d/' % idea.pk) self.assertEqual(data['title'], idea.title) self.assertContainsKeys(data, 'webUrl', 'description', 'initiatorOrganization', 'targetOrganizations')
def test_list(self): idea = IdeaFactory() data = self.get_json('/api/open/0.1/ideas/') self.assertIsPaginated(data) self.assertEqual(data['results'][0]['title'], idea.title)
def test_idea_redirect(self): i = IdeaFactory() resp = self.client.get('/ideat/%d/' % i.pk) self.assertRedirects(resp, '/fi/ideat/%d/' % i.pk, status_code=302)
def setUp(self): self.request_factory = RequestFactory() self.idea = IdeaFactory()
def setUp(self): self.idea = IdeaFactory()