def setUp(self): super(TestConstituencyPostcodeFinderView, self).setUp() wmc_area_type = AreaTypeFactory.create() gb_parties = PartySetFactory.create(slug='gb', name='Great Britain') commons = ParliamentaryChamberFactory.create() election = ElectionFactory.create( slug='2015', name='2015 General Election', area_types=(wmc_area_type,), organization=commons, ) area_extra = AreaExtraFactory.create( base__name="Dulwich and West Norwood", base__identifier='gss:E14000673', type=wmc_area_type, ) self.area = area_extra.base PostExtraFactory.create( elections=(election,), base__organization=commons, slug='65808', base__label='Member of Parliament for Dulwich and West Norwood', party_set=gb_parties, base__area=area_extra.base, )
def setUp(self): super(TestConstituencyPostcodeFinderView, self).setUp() wmc_area_type = AreaTypeFactory.create() gb_parties = PartySetFactory.create(slug='gb', name='Great Britain') commons = ParliamentaryChamberFactory.create() election = ElectionFactory.create( slug='2015', name='2015 General Election', area_types=(wmc_area_type, ), organization=commons, ) area_extra = AreaExtraFactory.create( base__name="Dulwich and West Norwood", base__identifier='gss:E14000673', type=wmc_area_type, ) self.area = area_extra.base PostExtraFactory.create( elections=(election, ), base__organization=commons, slug='65808', base__label='Member of Parliament for Dulwich and West Norwood', party_set=gb_parties, base__area=area_extra.base, )
def _setup_data(self): one_day = timedelta(days=1) self.future_date = date.today() + one_day london_assembly = ParliamentaryChamberFactory.create( slug="london-assembly", name="London Assembly") election_lac = ElectionFactory.create( slug="gla.c.2016-05-05", organization=london_assembly, name="2016 London Assembly Election (Constituencies)", election_date=self.future_date.isoformat(), ) self.election_gla = ElectionFactory.create( slug="gla.a.2016-05-05", organization=london_assembly, name="2016 London Assembly Election (Additional)", election_date=self.future_date.isoformat(), ) PostFactory.create( elections=(election_lac, ), organization=london_assembly, slug="lambeth-and-southwark", label="Assembly Member for Lambeth and Southwark", ) self.post = PostFactory.create( elections=(self.election_gla, ), organization=london_assembly, slug="london", label="Assembly Member", )
def _setup_extra_posts(self): # Create some extra posts and areas: london_assembly = ParliamentaryChamberFactory.create( slug="london-assembly", name="London Assembly") election_lac = ElectionFactory.create( slug="gla.c.2016-05-05", organization=london_assembly, name="2016 London Assembly Election (Constituencies)", ) election_gla = ElectionFactory.create( slug="gla.a.2016-05-05", organization=london_assembly, name="2016 London Assembly Election (Additional)", ) PostFactory.create( elections=(election_lac, ), organization=london_assembly, slug="lambeth-and-southwark", label="Assembly Member for Lambeth and Southwark", ) PostFactory.create( elections=(election_gla, ), organization=london_assembly, slug="london", label="2016 London Assembly Election (Additional)", )
def setUp(self): org = ParliamentaryChamberFactory.create() self.election = ElectionFactory.create( slug="2015", name="2015 Election", election_date=date.today(), organization=org, )
def setUp(self): election = ElectionFactory.create(slug="2015", name="2015 General Election") commons = ParliamentaryChamberFactory.create() self.post = PostFactory.create( elections=(election, ), organization=commons, slug="65808", label="Member of Parliament for Dulwich and West Norwood", )
def setUp(self): wmc_area_type = AreaTypeFactory.create() election = ElectionFactory.create(slug='2015', name='2015 General Election', area_types=(wmc_area_type, )) commons = ParliamentaryChamberFactory.create() self.post = PostExtraFactory.create( elections=(election, ), base__organization=commons, slug='65808', base__label='Member of Parliament for Dulwich and West Norwood')
def setUp(self): election = ElectionFactory.create(slug="parl.2015-05-07", name="2015 General Election") commons = ParliamentaryChamberFactory.create() self.post = PostFactory.create( elections=(election, ), organization=commons, slug="dulwich-and-west-norwood", label="Member of Parliament for Dulwich and West Norwood", ) self.ballot = self.post.ballot_set.get()
def setUp(self): wmc_area_type = AreaTypeFactory.create() election = ElectionFactory.create( slug='2015', name='2015 General Election', area_types=(wmc_area_type,) ) commons = ParliamentaryChamberFactory.create() self.post = PostExtraFactory.create( elections=(election,), base__organization=commons, slug='65808', base__label='Member of Parliament for Dulwich and West Norwood' )
def setUp(self): gb_parties = PartySetFactory.create(slug="gb", name="Great Britain") self.election = ElectionFactory.create( slug="parl.2015-05-07", name="2015 General Election", current=True ) commons = ParliamentaryChamberFactory.create() self.post = PostFactory.create( elections=(self.election,), organization=commons, slug="dulwich-and-west-norwood", label="Member of Parliament for Dulwich and West Norwood", party_set=gb_parties, ) self.ballot = self.post.ballot_set.get(election=self.election)
def setUp(self): super(TestModels, self).setUp() wmc_area_type = AreaTypeFactory.create() gb_parties = PartySetFactory.create(slug='gb', name='Great Britain') election = ElectionFactory.create(slug='2015', name='2015 General Election', area_types=(wmc_area_type, )) commons = ParliamentaryChamberFactory.create() self.post_extra = PostExtraFactory.create( elections=(election, ), base__organization=commons, slug='65808', base__label='Member of Parliament for Dulwich and West Norwood', party_set=gb_parties, )
def setUp(self): gb_parties = PartySetFactory.create(slug='gb', name='Great Britain') election = ElectionFactory.create( slug='2015', name='2015 General Election', current=True, ) commons = ParliamentaryChamberFactory.create() self.post_extra = PostExtraFactory.create( elections=(election, ), base__organization=commons, slug='65808', base__label='Member of Parliament for Dulwich and West Norwood', party_set=gb_parties, )
def setUp(self): gb_parties = PartySetFactory.create(slug="gb", name="Great Britain") commons = ParliamentaryChamberFactory.create() election = ElectionFactory.create( slug="parl.2017-03-23", name="2015 General Election", organization=commons, election_date="2017-03-23", ) PostFactory.create( elections=(election, ), organization=commons, slug="dulwich-and-west-norwood", label="Member of Parliament for Dulwich and West Norwood", party_set=gb_parties, )
def setUp(self): gb_parties = PartySetFactory.create(slug='gb', name='Great Britain') commons = ParliamentaryChamberFactory.create() election = ElectionFactory.create( slug='parl.2017-03-23', name='2015 General Election', organization=commons, election_date="2017-03-23", ) PostExtraFactory.create( elections=(election, ), base__organization=commons, slug='dulwich-and-west-norwood', base__label='Member of Parliament for Dulwich and West Norwood', party_set=gb_parties, )
def setUp(self): super(TestModels, self).setUp() wmc_area_type = AreaTypeFactory.create() gb_parties = PartySetFactory.create(slug='gb', name='Great Britain') election = ElectionFactory.create( slug='2015', name='2015 General Election', area_types=(wmc_area_type,) ) commons = ParliamentaryChamberFactory.create() self.post_extra = PostExtraFactory.create( elections=(election,), base__organization=commons, slug='65808', base__label='Member of Parliament for Dulwich and West Norwood', party_set=gb_parties, )
def setUp(self): wmc_area_type = AreaTypeFactory.create() self.election = ElectionFactory.create( slug='2015', name='2015 General Election', area_types=(wmc_area_type,) ) commons = ParliamentaryChamberFactory.create() self.post_extra = PostExtraFactory.create( elections=(self.election,), base__organization=commons, slug='65808', base__label='Member of Parliament for Dulwich and West Norwood' ) PartyExtraFactory.reset_sequence() PartyFactory.reset_sequence() self.parties = {} for i in xrange(0, 4): party_extra = PartyExtraFactory.create() self.parties[party_extra.slug] = party_extra person_extra = PersonExtraFactory.create( base__id='2009', base__name='Tessa Jowell' ) CandidacyExtraFactory.create( election=self.election, base__person=person_extra.base, base__post=self.post_extra.base, base__on_behalf_of=self.parties['party:63'].base ) person_extra = PersonExtraFactory.create( base__id='2010', base__name='Andrew Smith', base__email='*****@*****.**', ) CandidacyExtraFactory.create( election=self.election, base__person=person_extra.base, base__post=self.post_extra.base, base__on_behalf_of=self.parties['party:63'].base )
def setUp(self): election = Election.objects.get(slug='2015') wmc_area_type = election.area_types.get(name='WMC') gb_parties = PartySetFactory.create(slug='gb', name='Great Britain') commons = ParliamentaryChamberFactory.create() area_extra = AreaExtraFactory.create( base__name="Dulwich and West Norwood", type=wmc_area_type, ) self.area = area_extra.base PostExtraFactory.create( elections=(election, ), base__organization=commons, slug='65808', base__label='Member of Parliament for Dulwich and West Norwood', party_set=gb_parties, base__area=area_extra.base, )
def setUp(self): election = Election.objects.get(slug='2015') wmc_area_type = election.area_types.get(name='WMC') gb_parties = PartySetFactory.create(slug='gb', name='Great Britain') commons = ParliamentaryChamberFactory.create() area_extra = AreaExtraFactory.create( base__name="Dulwich and West Norwood", type=wmc_area_type, ) self.area = area_extra.base PostExtraFactory.create( elections=(election,), base__organization=commons, slug='65808', base__label='Member of Parliament for Dulwich and West Norwood', party_set=gb_parties, base__area=area_extra.base, )
def setUp(self): wmc_area_type = AreaTypeFactory.create() gb_parties = PartySetFactory.create(slug="gb", name="Great Britain") commons = ParliamentaryChamberFactory.create() election = ElectionFactory.create( slug="2015", name="2015 General Election", area_types=(wmc_area_type,), organization=commons ) area_extra = AreaExtraFactory.create( base__name="Dulwich and West Norwood", base__identifier="gss:E14000673", type=wmc_area_type ) self.area = area_extra.base PostExtraFactory.create( elections=(election,), base__organization=commons, slug="65808", base__label="Member of Parliament for Dulwich and West Norwood", party_set=gb_parties, base__area=area_extra.base, )
def setUp(self): wmc_area_type = AreaTypeFactory.create() self.election = ElectionFactory.create(slug='2015', name='2015 General Election', area_types=(wmc_area_type, )) commons = ParliamentaryChamberFactory.create() self.post_extra = PostExtraFactory.create( elections=(self.election, ), base__organization=commons, slug='65808', base__label='Member of Parliament for Dulwich and West Norwood') PartyExtraFactory.reset_sequence() PartyFactory.reset_sequence() self.parties = {} for i in range(0, 4): party_extra = PartyExtraFactory.create() self.parties[party_extra.slug] = party_extra person_extra = PersonExtraFactory.create(base__id='2009', base__name='Tessa Jowell') CandidacyExtraFactory.create( election=self.election, base__person=person_extra.base, base__post=self.post_extra.base, base__on_behalf_of=self.parties['party:63'].base) person_extra = PersonExtraFactory.create( base__id='2010', base__name='Andrew Smith', base__email='*****@*****.**', ) CandidacyExtraFactory.create( election=self.election, base__person=person_extra.base, base__post=self.post_extra.base, base__on_behalf_of=self.parties['party:63'].base)
def test_results_for_candidates_for_postcode(self, mock_requests): one_day = timedelta(days=1) self.future_date = date.today() + one_day london_assembly = ParliamentaryChamberFactory.create( slug="london-assembly", name="London Assembly" ) election_lac = ElectionFactory.create( slug="gla.c.2016-05-05", organization=london_assembly, name="2016 London Assembly Election (Constituencies)", election_date=self.future_date.isoformat(), ) self.election_gla = ElectionFactory.create( slug="gla.a.2016-05-05", organization=london_assembly, name="2016 London Assembly Election (Additional)", election_date=self.future_date.isoformat(), ) PostFactory.create( elections=(election_lac,), organization=london_assembly, slug="lambeth-and-southwark", label="Assembly Member for Lambeth and Southwark", ) self.post = PostFactory.create( elections=(self.election_gla,), organization=london_assembly, slug="london", label="Assembly Member", ) self.person.memberships.all().delete() MembershipFactory.create( person=self.person, post=self.post, party=self.labour_party, post_election=self.election_gla.postextraelection_set.get( post=self.post ), ) membership_pk = self.person.memberships.first().pk self.maxDiff = None mock_requests.get.side_effect = fake_requests_for_every_election response = self.app.get( "/api/next/candidates_for_postcode/?postcode=SE24+0AG" ) output = response.json self.assertEqual(len(output), 2) expected = [ { "candidates": [], "election_date": self.future_date.isoformat(), "election_id": "gla.c.2016-05-05", "election_name": "2016 London Assembly Election (Constituencies)", "organization": "London Assembly", "post": { "post_candidates": None, "post_name": "Assembly Member for Lambeth and Southwark", "post_slug": "lambeth-and-southwark", }, }, { "candidates": [ { "birth_date": "", "death_date": "", "email": None, "gender": "", "honorific_prefix": "", "honorific_suffix": "", "id": 2009, "images": [ { "copyright": "example-license", "id": self.person_image.pk, "image_url": "/media/images/images/imported.jpg", "is_primary": True, "md5sum": "md5sum", "notes": "", "source": "Found on the candidate's Flickr feed", "uploading_user": "******", "user_copyright": "", "user_notes": "Here's an image...", } ], "memberships": [ { "elected": None, "election": { "id": "gla.a.2016-05-05", "name": "2016 London Assembly Election (Additional)", "url": "http://testserver/api/next/elections/gla.a.2016-05-05/", }, "end_date": None, "id": membership_pk, "label": "", "party": { "ec_id": "PP53", "legacy_slug": "party:53", "name": "Labour Party", }, "party_list_position": None, "person": { "id": 2009, "name": "Tessa Jowell", "url": "http://testserver/api/next/persons/2009/", }, "post": { "id": "london", "label": "Assembly Member", "slug": "london", "url": "http://testserver/api/next/posts/london/", }, "role": "Candidate", "start_date": None, "url": "http://testserver/api/next/memberships/{}/".format( membership_pk ), } ], "name": "Tessa Jowell", "other_names": [], "sort_name": "", "thumbnail": "http://testserver/media/cache/69/5d/695d95b49b6a6ab3aebe728d2ec5162b.jpg", "url": "http://testserver/api/next/persons/2009/", } ], "election_date": self.future_date.isoformat(), "election_id": "gla.a.2016-05-05", "election_name": "2016 London Assembly Election (Additional)", "organization": "London Assembly", "post": { "post_candidates": None, "post_name": "Assembly Member", "post_slug": "london", }, }, ] self.assertEqual(expected, output)
def setUp(self): wmc_area_type = AreaTypeFactory.create() gb_parties = PartySetFactory.create(slug='gb', name='Great Britain') election = ElectionFactory.create( slug='2015', name='2015 General Election', area_types=(wmc_area_type,) ) area_extra = AreaExtraFactory.create( base__name="Dulwich and West Norwood", type=wmc_area_type, ) commons = ParliamentaryChamberFactory.create() post_extra = PostExtraFactory.create( elections=(election,), base__area=area_extra.base, base__organization=commons, slug='65808', party_set=gb_parties, base__label='Member of Parliament for Dulwich and West Norwood' ) camberwell_area_extra = AreaExtraFactory.create( base__identifier='65913', type=wmc_area_type, ) camberwell_post = PostExtraFactory.create( elections=(election,), base__area=camberwell_area_extra.base, base__organization=commons, slug='65913', candidates_locked=True, base__label='Member of Parliament for Camberwell and Peckham', party_set=gb_parties, ) person_extra = PersonExtraFactory.create( base__id='2009', base__name='Tessa Jowell' ) self.person = person_extra.base PartyExtraFactory.reset_sequence() PartyFactory.reset_sequence() self.parties = {} for i in range(0, 4): party_extra = PartyExtraFactory.create() gb_parties.parties.add(party_extra.base) self.parties[party_extra.slug] = party_extra CandidacyExtraFactory.create( election=election, base__person=person_extra.base, base__post=post_extra.base, base__on_behalf_of=self.parties['party:63'].base ) person_extra = PersonExtraFactory.create( base__id='2010', base__name='Angela Smith' ) self.person2 = person_extra.base CandidacyExtraFactory.create( election=election, base__person=person_extra.base, base__post=post_extra.base, base__on_behalf_of=self.parties['party:63'].base ) content_type = ContentType.objects.get_for_model(person_extra.base) last_sent = datetime.now(pytz.utc) - timedelta(days=2) self.alert = Alert.objects.create( user=self.user, target_content_type=content_type, target_object_id=self.person.id, last_sent=last_sent, frequency='hourly' ) self.alert2 = Alert.objects.create( user=self.user_who_can_lock, target_content_type=content_type, target_object_id=self.person2.id, last_sent=last_sent, frequency='daily' ) person_extra = PersonExtraFactory.create( base__id='2011', base__name='Martin Jones' ) self.person2 = person_extra.base CandidacyExtraFactory.create( election=election, base__person=person_extra.base, base__post=camberwell_post.base, base__on_behalf_of=self.parties['party:63'].base ) content_type = ContentType.objects.get_for_model( camberwell_area_extra.base ) self.alert3 = Alert.objects.create( user=self.user_who_can_merge, target_content_type=content_type, target_object_id=camberwell_area_extra.base.id, last_sent=last_sent, frequency='daily' ) aldershot_area_extra = AreaExtraFactory.create( base__identifier='65730', type=wmc_area_type, ) aldershot_post = PostExtraFactory.create( elections=(election,), base__area=aldershot_area_extra.base, base__organization=commons, slug='65730', base__label='Member of Parliament for Aldershot', party_set=gb_parties, ) person_extra = PersonExtraFactory.create( base__id='2012', base__name='Gillian Collins' ) self.person3 = person_extra.base CandidacyExtraFactory.create( election=election, base__person=person_extra.base, base__post=aldershot_post.base, base__on_behalf_of=self.parties['party:63'].base ) content_type = ContentType.objects.get_for_model( self.parties['party:90'].base ) self.alert4 = Alert.objects.create( user=self.user_who_can_rename, target_content_type=content_type, target_object_id=self.parties['party:90'].base.id, last_sent=last_sent, frequency='daily' ) content_type = ContentType.objects.get_for_model( camberwell_area_extra.base ) self.alert5 = Alert.objects.create( user=self.user, target_content_type=content_type, target_object_id=66101, last_sent=last_sent, frequency='hourly' )
def setUp(self): wmc_area_type = AreaTypeFactory.create() gb_parties = PartySetFactory.create(slug='gb', name='Great Britain') election = ElectionFactory.create(slug='2015', name='2015 General Election', area_types=(wmc_area_type, )) area_extra = AreaExtraFactory.create( base__name="Dulwich and West Norwood", type=wmc_area_type, ) commons = ParliamentaryChamberFactory.create() post_extra = PostExtraFactory.create( elections=(election, ), base__area=area_extra.base, base__organization=commons, slug='65808', party_set=gb_parties, base__label='Member of Parliament for Dulwich and West Norwood') camberwell_area_extra = AreaExtraFactory.create( base__identifier='65913', type=wmc_area_type, ) camberwell_post = PostExtraFactory.create( elections=(election, ), base__area=camberwell_area_extra.base, base__organization=commons, slug='65913', candidates_locked=True, base__label='Member of Parliament for Camberwell and Peckham', party_set=gb_parties, ) person_extra = PersonExtraFactory.create(base__id='2009', base__name='Tessa Jowell') self.person = person_extra.base PartyExtraFactory.reset_sequence() PartyFactory.reset_sequence() self.parties = {} for i in range(0, 4): party_extra = PartyExtraFactory.create() gb_parties.parties.add(party_extra.base) self.parties[party_extra.slug] = party_extra CandidacyExtraFactory.create( election=election, base__person=person_extra.base, base__post=post_extra.base, base__on_behalf_of=self.parties['party:63'].base) person_extra = PersonExtraFactory.create(base__id='2010', base__name='Angela Smith') self.person2 = person_extra.base CandidacyExtraFactory.create( election=election, base__person=person_extra.base, base__post=post_extra.base, base__on_behalf_of=self.parties['party:63'].base) content_type = ContentType.objects.get_for_model(person_extra.base) last_sent = datetime.now(pytz.utc) - timedelta(days=2) self.alert = Alert.objects.create(user=self.user, target_content_type=content_type, target_object_id=self.person.id, last_sent=last_sent, frequency='hourly') self.alert2 = Alert.objects.create(user=self.user_who_can_lock, target_content_type=content_type, target_object_id=self.person2.id, last_sent=last_sent, frequency='daily') person_extra = PersonExtraFactory.create(base__id='2011', base__name='Martin Jones') self.person2 = person_extra.base CandidacyExtraFactory.create( election=election, base__person=person_extra.base, base__post=camberwell_post.base, base__on_behalf_of=self.parties['party:63'].base) content_type = ContentType.objects.get_for_model( camberwell_area_extra.base) self.alert3 = Alert.objects.create( user=self.user_who_can_merge, target_content_type=content_type, target_object_id=camberwell_area_extra.base.id, last_sent=last_sent, frequency='daily') aldershot_area_extra = AreaExtraFactory.create( base__identifier='65730', type=wmc_area_type, ) aldershot_post = PostExtraFactory.create( elections=(election, ), base__area=aldershot_area_extra.base, base__organization=commons, slug='65730', base__label='Member of Parliament for Aldershot', party_set=gb_parties, ) person_extra = PersonExtraFactory.create(base__id='2012', base__name='Gillian Collins') self.person3 = person_extra.base CandidacyExtraFactory.create( election=election, base__person=person_extra.base, base__post=aldershot_post.base, base__on_behalf_of=self.parties['party:63'].base) content_type = ContentType.objects.get_for_model( self.parties['party:90'].base) self.alert4 = Alert.objects.create( user=self.user_who_can_rename, target_content_type=content_type, target_object_id=self.parties['party:90'].base.id, last_sent=last_sent, frequency='daily') content_type = ContentType.objects.get_for_model( camberwell_area_extra.base) self.alert5 = Alert.objects.create(user=self.user, target_content_type=content_type, target_object_id=66101, last_sent=last_sent, frequency='hourly')
def setUp(self): wmc_area_type = AreaTypeFactory.create() gb_parties = PartySetFactory.create(slug='gb', name='Great Britain') commons = ParliamentaryChamberFactory.create() area = AreaFactory.create( name="Dulwich and West Norwood", ) election = ElectionFactory.create( slug='2015', name='2015 General Election', area_types=(wmc_area_type,), organization=commons ) post_extra = PostExtraFactory.create( elections=(election,), base__organization=commons, base__id='65808', base__label='Member of Parliament for Dulwich and West Norwood', party_set=gb_parties, base__area=area, ) person_2009 = PersonExtraFactory.create( base__id='2009', base__name='Tessa Jowell' ) person_2007 = PersonExtraFactory.create( base__id='2007', base__name='Tessa Jowell' ) PartyFactory.reset_sequence() party_extra = PartyExtraFactory.create() CandidacyExtraFactory.create( election=election, base__person=person_2009.base, base__post=post_extra.base, base__on_behalf_of=party_extra.base ) CandidacyExtraFactory.create( election=election, base__person=person_2007.base, base__post=post_extra.base, base__on_behalf_of=party_extra.base ) self.site = Site.objects.create(domain='example.com', name='YNR') self.test_upload_user = User.objects.create_user( 'john', '*****@*****.**', 'notagoodpassword', ) self.test_upload_user.terms_agreement.assigned_to_dc = True self.test_upload_user.terms_agreement.save() self.test_reviewer = User.objects.create_superuser( 'jane', '*****@*****.**', 'alsonotagoodpassword', ) self.test_reviewer.terms_agreement.assigned_to_dc = True self.test_reviewer.terms_agreement.save() self.test_reviewer.groups.add( Group.objects.get(name=PHOTO_REVIEWERS_GROUP_NAME) ) self.q1 = QueuedImage.objects.create( why_allowed='public-domain', justification_for_use="It's their Twitter avatar", decision='undecided', image='pilot.jpg', person=person_2009.base, user=self.test_upload_user ) self.q2 = QueuedImage.objects.create( why_allowed='copyright-assigned', justification_for_use="I took this last week", decision='approved', image='pilot.jpg', person=person_2007.base, user=self.test_upload_user ) self.q3 = QueuedImage.objects.create( why_allowed='other', justification_for_use="I found it somewhere", decision='rejected', image='pilot.jpg', person=person_2007.base, user=self.test_reviewer )
def setUp(self): wmc_area_type = AreaTypeFactory.create() gb_parties = PartySetFactory.create(slug='gb', name='Great Britain') commons = ParliamentaryChamberFactory.create() area = AreaFactory.create(name="Dulwich and West Norwood", ) election = ElectionFactory.create(slug='2015', name='2015 General Election', area_types=(wmc_area_type, ), organization=commons) post_extra = PostExtraFactory.create( elections=(election, ), base__organization=commons, base__id='65808', base__label='Member of Parliament for Dulwich and West Norwood', party_set=gb_parties, base__area=area, ) person_2009 = PersonExtraFactory.create(base__id='2009', base__name='Tessa Jowell') person_2007 = PersonExtraFactory.create(base__id='2007', base__name='Tessa Jowell') PartyFactory.reset_sequence() party_extra = PartyExtraFactory.create() CandidacyExtraFactory.create(election=election, base__person=person_2009.base, base__post=post_extra.base, base__on_behalf_of=party_extra.base) CandidacyExtraFactory.create(election=election, base__person=person_2007.base, base__post=post_extra.base, base__on_behalf_of=party_extra.base) self.site = Site.objects.create(domain='example.com', name='YNR') self.test_upload_user = User.objects.create_user( 'john', '*****@*****.**', 'notagoodpassword', ) self.test_upload_user.terms_agreement.assigned_to_dc = True self.test_upload_user.terms_agreement.save() self.test_reviewer = User.objects.create_superuser( 'jane', '*****@*****.**', 'alsonotagoodpassword', ) self.test_reviewer.terms_agreement.assigned_to_dc = True self.test_reviewer.terms_agreement.save() self.test_reviewer.groups.add( Group.objects.get(name=PHOTO_REVIEWERS_GROUP_NAME)) self.q1 = QueuedImage.objects.create( why_allowed='public-domain', justification_for_use="It's their Twitter avatar", decision='undecided', image=self.storage_filename, person=person_2009.base, user=self.test_upload_user) self.q2 = QueuedImage.objects.create( why_allowed='copyright-assigned', justification_for_use="I took this last week", decision='approved', image=self.storage_filename, person=person_2007.base, user=self.test_upload_user) self.q3 = QueuedImage.objects.create( why_allowed='other', justification_for_use="I found it somewhere", decision='rejected', image=self.storage_filename, person=person_2007.base, user=self.test_reviewer)