def test_revision_is_cached(self, check_output): check_output.return_value = b'quux' r1 = get_revision() r2 = get_revision() check_output.assert_called_once_with(['foo', 'bar', 'baz']) self.assertEqual(r2, 'quux')
def test_all_command_variants_are_checked_in_order(self, check_output): check_output.side_effect = OSError() revision = get_revision() self.assertEqual(check_output.mock_calls, [call(['foo']), call(['bar']), call(['baz'])])
def test_command_returns_none_if_vcs_not_available2(self, check_output): check_output.return_value = b'\n' revision = get_revision() check_output.assert_called_once_with(['foo', 'bar', 'baz']) self.assertEqual(revision, None)
def test_command_returns_revision_if_available(self, check_output): check_output.return_value = b'quux\r\n' revision = get_revision() check_output.assert_called_once_with(['foo', 'bar', 'baz']) self.assertEqual(revision, 'quux')
def test_command_returns_none_if_vcs_not_available(self, check_output): check_output.side_effect = CalledProcessError(255, 'foo') check_output.return_value = b'bogus' revision = get_revision() check_output.assert_called_once_with(['foo', 'bar', 'baz']) self.assertEqual(revision, None)
def setUp(self): super(TestMiddleware, self).setUp() self.revision = get_revision()
def setUp(self): super(TestTemplateTag, self).setUp() self.revision = get_revision()
def test_revision_in_context(self): self.revision = get_revision() resp = self.client.get('/context') self.assertEqual(resp.context['SOURCE_REVISION'], self.revision) self.assertEqual(resp.content, self.revision.encode('ascii'))