def test_useremails(self):
        '''
        Create user_count users and test that useremails returns that many
        entries, plus two newlines.
        '''
        user_count = 20

        count_before = User.objects.count()
        dd = DevData()
        dd.create_attendees(user_count)

        self.assertEquals(User.objects.count() - count_before, user_count,
                          'created usercount test users')

        user = User.objects.all().first()
        user.contact_permission_date = None
        user.save()

        out = StringIO()
        args = []
        opts = {'stdout': out}
        call_command('useremails', *args, **opts)
        entries = len(out.getvalue().strip().split('\n'))
        self.assertEquals(entries, user_count - 1,
                          'all users except one have given permission')
 def setUpTestData(cls):
     cls.event = Event.objects.get(title="devdata.18")
     cls.devdata = DevData()
     cls.devdata.create_talk_formats()
     cls.devdata.update_events()
     # we need to create more users because of the stochastic
     # subsampling for attendees
     cls.devdata.create_users_and_attendees(
         amount=cls.devdata.SPEAKERS_PER_EVENT * 2, events=[cls.event])
     cls.devdata.create_speakers(events=[cls.event])
     cls.devdata.create_talks(events=[cls.event])
     cls.devdata.create_tracks(events=[cls.event])
     cls.devdata.create_rooms(events=[cls.event])
     cls.devdata.create_time_slots(events=[cls.event])
     cls.devdata.create_talk_slots(events=[cls.event])
 def test_twitterwall(self):
     self.maxDiff = None
     devdata = DevData()
     devdata.create_twitter_profiles()
     devdata.create_tweets(5)
     response = self.client.get(reverse('twitterwall'))
     self.assertEqual(response.status_code, 200)
     twitterwall = json.loads(response.content.decode("utf8"))
     self.assertIn("tweets", twitterwall)
     self.assertEqual(len(twitterwall["tweets"]), 5,
         "there should be five tweets")
     self.assertTrue(
         twitterwall["tweets"][0]["time"] >
         twitterwall["tweets"][1]["time"],
         "newest tweet first")
示例#4
0
 def setUpTestData(cls):
     cls.devdata = DevData()
     cls.devdata.create_talk_formats()
     cls.devdata.update_events()
示例#5
0
 def setUp(self):
     dev_data = DevData()
     dev_data.create_admin_user()
     dev_data.create_pages()
     self.event = Event.objects.current_event()
     self.url = "/"
示例#6
0
 def setUp(self):
     dev_data = DevData()
     dev_data.create_admin_user()
     self.url = reverse_lazy("send_email")
 def setUpTestData(cls):
     cls.stdout = StringIO()
     cls.devdata = DevData(stdout=OutputWrapper(cls.stdout))
示例#8
0
 def setUp(self):
     self.devdata = DevData()
     self.devdata.create_admin_user()
     self.devdata.create_pages()
     self.devdata.update_events()
     self.event = Event.objects.current_event()
示例#9
0
class DevDayMenuTest(TestCase):
    def setUp(self):
        self.devdata = DevData()
        self.devdata.create_admin_user()
        self.devdata.create_pages()
        self.devdata.update_events()
        self.event = Event.objects.current_event()

    def test_menu(self):
        entries = get_nodes()
        self.assertIn(cms_menus.USER_CAN_REGISTER, entries[0].attr)
        self.assertIn(cms_menus.SUBMISSION_OPEN, entries[1].attr)
        self.assertIn(cms_menus.SESSIONS_PUBLISHED, entries[2].attr)
        self.assertIn(cms_menus.CHILDREN, entries[3].attr)
        self.assertEqual(len(entries[3].children), 2,
                         "Archive should have two children")
        self.assertEqual(entries[4].url, reverse("auth_login"))

    def test_no_current(self):
        for event in Event.objects.all():
            event.published = False
            event.save()
        entries = get_nodes()
        self.assertEqual(len(entries), 1, "should have one entry")

    def test_registration_off(self):
        self.event.registration_open = False
        self.event.submission_open = True
        self.event.save()
        entries = get_nodes()
        self.assertIn(cms_menus.SUBMISSION_OPEN, entries[0].attr)
        self.assertIn(cms_menus.SESSIONS_PUBLISHED, entries[1].attr)

    def test_submission_off(self):
        self.event.registration_open = True
        self.event.submission_open = False
        self.event.save()
        entries = get_nodes()
        self.assertIn(cms_menus.USER_CAN_REGISTER, entries[0].attr)
        self.assertIn(cms_menus.SESSIONS_PUBLISHED, entries[1].attr)

    def test_logged_in(self):
        (user, _) = create_test_user()
        Attendee.objects.filter(user=user, event=self.event).delete()
        entries = get_nodes(user=user)
        self.assertEqual(entries[4].url, "#")
        children = entries[4].children
        self.assertEqual(children[0].url, reverse("user_profile"))
        self.assertEqual(children[1].url, reverse("auth_logout"))

        Attendee.objects.create(user=user, event=self.event)
        entries = get_nodes(user=user)
        self.assertEqual(entries[3].url, "#")
        children = entries[3].children
        self.assertEqual(len(children), 3,
                         "profile menu should have three entries")
        self.assertEqual(children[0].url, reverse("user_profile"))
        self.assertEqual(
            children[1].url,
            reverse("attendee_checkin_qrcode",
                    kwargs={"event": self.event.slug}),
        )
        self.assertEqual(children[2].url, reverse("auth_logout"))
示例#10
0
 def setUpTestData(cls):
     cls.event = Event.objects.get(title="devdata.18")
     cls.devdata = DevData()
     cls.devdata.create_talk_formats()
     cls.devdata.update_events()
     cls.devdata.create_users_and_attendees(amount=10, events=[cls.event])
 def test_export_with_talks_csv_file(self):
     dev_data = DevData()
     dev_data.SPEAKERS_PER_EVENT = 2
     events = [Event.objects.current_event()]
     dev_data.create_users_and_attendees(10, events=events)
     dev_data.create_speakers(events)
     dev_data.create_talk_formats()
     dev_data.create_talks(events=events)
     talks = Event.objects.current_event().talk_set
     outbuf = io.StringIO()
     errbuf = io.StringIO()
     tempfile = NamedTemporaryFile(mode="w", delete=False)
     try:
         call_command("export_talks_for_committee",
                      csv_file=tempfile,
                      stdout=outbuf,
                      stderr=errbuf)
         tempfile.close()
         self.assertEqual("", outbuf.getvalue().strip())
         self.assertEqual("", errbuf.getvalue().strip())
         with open(tempfile.name, "r") as output:
             output_lines = output.read().splitlines()
             self.assertEqual(talks.count() + 1, len(output_lines))
     finally:
         os.unlink(tempfile.name)
 def test_export_with_talks(self):
     dev_data = DevData()
     dev_data.SPEAKERS_PER_EVENT = 2
     events = [Event.objects.current_event()]
     dev_data.create_users_and_attendees(10, events=events)
     dev_data.create_speakers(events)
     dev_data.create_talk_formats()
     dev_data.create_talks(events=events)
     talks = Event.objects.current_event().talk_set
     outbuf = io.StringIO()
     errbuf = io.StringIO()
     call_command("export_talks_for_committee",
                  stdout=outbuf,
                  stderr=errbuf)
     output_lines = outbuf.getvalue().splitlines()
     self.assertEqual(talks.count() + 1, len(output_lines))
     self.assertEqual("", errbuf.getvalue().strip())