def test_import(self): '''Test that the admin panel can import Assignments.''' TestUsers.new_superuser(username='******', password='******') self.client.login(username='******', password='******') school = TestSchools.new_school() cm1 = TestCommittees.new_committee(name='SPD') cm2 = TestCommittees.new_committee(name='USS') co1 = TestCountries.new_country(name="Côte d'Ivoire") co2 = TestCountries.new_country(name='Barbara Boxer') f = TestFiles.new_csv([ ['Test School', 'SPD', "Côte d'Ivoire"], ['Test School', 'USS', 'Barbara Boxer'] ]) with closing(f) as f: self.client.post(reverse('admin:core_assignment_load'), {'csv': f}) self.assertTrue(Assignment.objects.filter( school=School.objects.get(name='Test School'), committee=Committee.objects.get(name='SPD'), country=Country.objects.get(name="Côte d'Ivoire") ).exists()) self.assertTrue(Assignment.objects.filter( school=School.objects.get(name='Test School'), committee=Committee.objects.get(name='USS'), country=Country.objects.get(name='Barbara Boxer') ).exists())
def test_import(self): '''Test that the admin panel can import Assignments.''' models.new_superuser(username='******', password='******') self.client.login(username='******', password='******') registration = models.new_registration() cm1 = models.new_committee(name='SPD') cm2 = models.new_committee(name='USS') co1 = models.new_country(name="Côte d'Ivoire") co2 = models.new_country(name='Barbara Boxer') f = TestFiles.new_csv([ ['Test School', 'SPD', "Côte d'Ivoire"], ['Test School', 'USS', 'Barbara Boxer'] ]) with closing(f) as f: self.client.post(reverse('admin:core_assignment_load'), {'csv': f}) self.assertTrue( Assignment.objects.filter( registration=registration, committee=Committee.objects.get(name='SPD'), country=Country.objects.get(name="Côte d'Ivoire")).exists()) self.assertTrue( Assignment.objects.filter( registration=registration, committee=Committee.objects.get(name='USS'), country=Country.objects.get(name='Barbara Boxer')).exists())
def test_import(self): '''Test that the admin panel can import countries. ''' TestUsers.new_superuser(username='******', password='******') self.client.login(username='******', password='******') f = TestFiles.new_csv([ ['United States of America', ''], ['Barbara Boxer', True], ["Côte d'Ivoire", ''] ]) with closing(f) as f: self.client.post(reverse('admin:core_country_load'), {'csv': f}) self.assertTrue(Country.objects.filter( name='United States of America', special=False ).exists()) self.assertTrue(Country.objects.filter( name='Barbara Boxer', special=True ).exists()) self.assertTrue(Country.objects.filter( name="Côte d'Ivoire", special=False ).exists())
def test_import(self): '''Test that the admin panel can import delegates. ''' models.new_superuser(username='******', password='******') self.client.login(username='******', password='******') school = models.new_school() cm1 = models.new_committee(name='SPD') cm2 = models.new_committee(name='USS') co1 = models.new_country(name="Côte d'Ivoire") co2 = models.new_country(name='Barbara Boxer') Assignment.objects.create(committee=cm1, country=co1, school=school) Assignment.objects.create(committee=cm2, country=co2, school=school) f = TestFiles.new_csv([ ['Name', 'Committee', 'Country', 'School'], ['John Doe', 'SPD', "Côte d'Ivoire", 'Test School'], ['Jane Doe', 'USS', 'Barbara Boxer', 'Test School'], ]) with closing(f) as f: self.client.post(reverse('admin:core_delegate_load'), {'csv': f}) self.assertTrue( Delegate.objects.filter(assignment=Assignment.objects.get( school=School.objects.get(name='Test School'), committee=Committee.objects.get(name='SPD'), country=Country.objects.get(name="Côte d'Ivoire")), name='John Doe').exists()) self.assertTrue( Delegate.objects.filter(assignment=Assignment.objects.get( school=School.objects.get(name='Test School'), committee=Committee.objects.get(name='USS'), country=Country.objects.get(name='Barbara Boxer')), name='Jane Doe').exists())
def test_import(self): '''Test that the admin panel can import committees.''' models.new_superuser(username='******', password='******') self.client.login(username='******', password='******') f = TestFiles.new_csv([ ['SPD', 'Special Pôlitical and Decolonization', 2, ''], ['USS', 'United States Senate', 2, True] ]) with closing(f) as f: self.client.post(reverse('admin:core_committee_load'), {'csv': f}) self.assertTrue(Committee.objects.filter( name='SPD', full_name='Special Pôlitical and Decolonization', delegation_size=2, special=False ).exists()) self.assertTrue(Committee.objects.filter( name='USS', full_name='United States Senate', delegation_size=2, special=True ).exists())
def test_import(self): '''Test that the admin panel can import committees.''' TestUsers.new_superuser(username='******', password='******') self.client.login(username='******', password='******') f = TestFiles.new_csv([ ['SPD', 'Special Pôlitical and Decolonization', 2, ''], ['USS', 'United States Senate', 2, True] ]) with closing(f) as f: self.client.post(reverse('admin:core_committee_load'), {'csv': f}) self.assertTrue(Committee.objects.filter( name='SPD', full_name='Special Pôlitical and Decolonization', delegation_size=2, special=False ).exists()) self.assertTrue(Committee.objects.filter( name='USS', full_name='United States Senate', delegation_size=2, special=True ).exists())
def test_import(self): '''Test that the admin panel can import countries. ''' models.new_superuser(username='******', password='******') self.client.login(username='******', password='******') f = TestFiles.new_csv([['United States of America', ''], ['Barbara Boxer', True], ["Côte d'Ivoire", '']]) with closing(f) as f: self.client.post(reverse('admin:core_country_load'), {'csv': f}) self.assertTrue( Country.objects.filter(name='United States of America', special=False).exists()) self.assertTrue( Country.objects.filter(name='Barbara Boxer', special=True).exists()) self.assertTrue( Country.objects.filter(name="Côte d'Ivoire", special=False).exists())
def test_import(self): '''Test that the admin panel can import committees.''' models.new_superuser(username='******', password='******') self.client.login(username='******', password='******') committee = models.new_committee(name='ICJ') f = TestFiles.new_csv([['Trent Gomberg', 'ICJ', ''], ['Ali Maloney', 'ICJ', 'TRUE']]) with closing(f) as f: self.client.post(reverse('admin:core_secretariatmember_load'), {'csv': f}) self.assertTrue( SecretariatMember.objects.filter(name='Trent Gomberg', committee=committee.id, is_head_chair=False).exists()) self.assertTrue( SecretariatMember.objects.filter(name='Ali Maloney', committee=committee.id, is_head_chair=True).exists())
def test_import(self): '''Test that the admin panel can import delegates. ''' TestUsers.new_superuser(username='******', password='******') self.client.login(username='******', password='******') school = TestSchools.new_school() cm1 = TestCommittees.new_committee(name='SPD') cm2 = TestCommittees.new_committee(name='USS') co1 = TestCountries.new_country(name="Côte d'Ivoire") co2 = TestCountries.new_country(name='Barbara Boxer') Assignment.objects.create(committee=cm1, country=co1, school=school) Assignment.objects.create(committee=cm2, country=co2, school=school) f = TestFiles.new_csv([ ['Name', 'Committee', 'Country', 'School'], ['John Doe', 'SPD', "Côte d'Ivoire", 'Test School'], ['Jane Doe', 'USS', 'Barbara Boxer', 'Test School'], ]) with closing(f) as f: self.client.post(reverse('admin:core_delegate_load'), {'csv': f}) self.assertTrue(Delegate.objects.filter( assignment=Assignment.objects.get( school=School.objects.get(name='Test School'), committee=Committee.objects.get(name='SPD'), country=Country.objects.get(name="Côte d'Ivoire") ), name='John Doe' ).exists()) self.assertTrue(Delegate.objects.filter( assignment=Assignment.objects.get( school=School.objects.get(name='Test School'), committee=Committee.objects.get(name='USS'), country=Country.objects.get(name='Barbara Boxer') ), name='Jane Doe' ).exists())
def test_import(self): '''Test that the admin panel can import committees.''' models.new_superuser(username='******', password='******') self.client.login(username='******', password='******') committee = models.new_committee(name='ICJ') f = TestFiles.new_csv([ ['Trent Gomberg', 'ICJ', ''], ['Ali Maloney', 'ICJ', 'TRUE'] ]) with closing(f) as f: self.client.post( reverse('admin:core_secretariatmember_load'), {'csv': f}) self.assertTrue( SecretariatMember.objects.filter( name='Trent Gomberg', committee=committee.id, is_head_chair=False).exists()) self.assertTrue( SecretariatMember.objects.filter( name='Ali Maloney', committee=committee.id, is_head_chair=True).exists())