def test_renders_channel_log_as_text(self, tmpdir): self._mock_log_dir(tmpdir) response = logger.logger(self.request, None, 'foo', '2014-12-01', as_text=True) self.request.setHeader.assert_any_call('Content-Type', 'text/plain') self.request.setHeader.assert_any_call('Content-Disposition', 'attachment; filename=2014-12-01.txt') # Output asserts assert response == '00:00:00 - foo - this is what i said'
def test_renders_channel_index(self, tmpdir): self._mock_log_dir(tmpdir) response = logger.logger(self.request, None, 'foo') self.request.setHeader.assert_called_with('Content-Type', 'text/html') # Output asserts assert '<title>#foo Channel Logs</title>' in response assert '<a href="/logger/foo/2014-12-01">2014-12-01</a>' in response
def test_renders_channel_log(self, tmpdir): self._mock_log_dir(tmpdir) response = logger.logger(self.request, None, 'foo', '2014-12-01') self.request.setHeader.assert_called_with('Content-Type', 'text/html') # Output asserts assert '<title>#foo Channel Logs for 2014-12-01</title>' in response assert '<td><a href="#00:00:00" name="00:00:00">00:00:00</a></td>' in response assert '<td>foo</td>' in response assert '<td><pre>this is what i said</pre></td>' in response
def test_raises_501(self): logger.settings.CHANNEL_LOGGING = False with pytest.raises(logger.HttpError): logger.logger(None, None)