예제 #1
0
    def test_get_logs_data(self):
        # Get a couple of lines

        # Create the lines we'll get
        LINE1 = "Now is the time for all good folks to dance."
        LINE2 = "A completely different log line"
        USER1 = "Jim Bob"
        USER2 = "George Washington"
        now = datetime.datetime.now()
        # make sure they have different timestamps, and that microseconds
        # are preserved
        then = now + datetime.timedelta(microseconds=1)
        IRCLogLine.objects.create(proposal=self.proposal,
                                  line=LINE1,
                                  user=USER1,
                                  timestamp=now.strftime(DATETIME_FORMAT))
        IRCLogLine.objects.create(proposal=self.proposal,
                                  line=LINE2,
                                  user=USER2,
                                  timestamp=then.strftime(DATETIME_FORMAT))

        # Create another proposal and a line to make sure we
        # don't get it in the results
        self.proposal2 = PyConTalkProposalFactory.create()
        later = then + datetime.timedelta(seconds=2)
        IRCLogLine.objects.create(proposal=self.proposal2,
                                  line="wrong",
                                  user="******",
                                  timestamp=later.strftime(DATETIME_FORMAT))

        url = reverse('proposal_irc_logs',
                      kwargs={
                          'proposal_id': str(self.proposal.id),
                      })
        rsp = self.client.get(url, **self.get_signature(url))
        self.assertEqual(200, rsp.status_code)
        logs = json.loads(rsp.content)['data']
        self.assertEqual(2, len(logs))
        # They should come out in timestamp order. Data, including time
        # to the microsecond, should be preserved.
        self.assertEqual(LINE1, logs[0]['line'])
        self.assertEqual(USER1, logs[0]['user'])
        self.assertEqual(now.strftime(DATETIME_FORMAT), logs[0]['timestamp'])
        self.assertEqual(LINE2, logs[1]['line'])
        self.assertEqual(then.strftime(DATETIME_FORMAT), logs[1]['timestamp'])
        self.assertEqual(USER2, logs[1]['user'])
예제 #2
0
    def test_get_logs_data(self):
        # Get a couple of lines

        # Create the lines we'll get
        LINE1 = "Now is the time for all good folks to dance."
        LINE2 = "A completely different log line"
        USER1 = "Jim Bob"
        USER2 = "George Washington"
        now = datetime.datetime.now()
        # make sure they have different timestamps, and that microseconds
        # are preserved
        then = now + datetime.timedelta(microseconds=1)
        IRCLogLine.objects.create(proposal=self.proposal, line=LINE1,
                                  user=USER1,
                                  timestamp=now.strftime(DATETIME_FORMAT))
        IRCLogLine.objects.create(proposal=self.proposal, line=LINE2,
                                  user=USER2,
                                  timestamp=then.strftime(DATETIME_FORMAT))

        # Create another proposal and a line to make sure we
        # don't get it in the results
        self.proposal2 = PyConTalkProposalFactory.create()
        later = then + datetime.timedelta(seconds=2)
        IRCLogLine.objects.create(proposal=self.proposal2, line="wrong",
                                  user="******",
                                  timestamp=later.strftime(DATETIME_FORMAT))

        url = reverse('proposal_irc_logs', kwargs={
            'proposal_id': str(self.proposal.id),
        })
        rsp = self.client.get(url, **self.get_signature(url))
        self.assertEqual(200, rsp.status_code)
        logs = json.loads(rsp.content)['data']
        self.assertEqual(2, len(logs))
        # They should come out in timestamp order. Data, including time
        # to the microsecond, should be preserved.
        self.assertEqual(LINE1, logs[0]['line'])
        self.assertEqual(USER1, logs[0]['user'])
        self.assertEqual(now.strftime(DATETIME_FORMAT), logs[0]['timestamp'])
        self.assertEqual(LINE2, logs[1]['line'])
        self.assertEqual(then.strftime(DATETIME_FORMAT), logs[1]['timestamp'])
        self.assertEqual(USER2, logs[1]['user'])
예제 #3
0
 def setUp(self):
     self.auth_key = APIAuth.objects.create(name="test")
     self.proposal = PyConTalkProposalFactory.create()
예제 #4
0
 def setUp(self):
     self.auth_key = APIAuth.objects.create(name="test")
     self.proposal = PyConTalkProposalFactory.create()
예제 #5
0
 def test_skip_unsubmitted(self):
     PyConTalkProposalFactory.create(submitted=False)
     url = reverse('proposal_list') + '?type=talk'
     rsp = self.client.get(url, **self.get_signature(url))
     self.assertEqual(rsp.status_code, 200, rsp.content)
     self.assertEqual(len(json.loads(rsp.content)['data']), 1)