Пример #1
0
class TestReporter(test_helper.MoxTestCase):
	def setUp(self):
		super(TestReporter, self).setUp()
		self.reporter = Reporter()

	def testFormattingNoCandidateVersion(self):
		v1 = self.struct()
		v1.string = '1.2'
		status = Status('apackage', v1, None)
		report = self.reporter.format(status)
		self.assertContains(report, '1.2->)')
		self.assertNotContains(report, '[')

	def testFormattingNoCurrentVersion(self):
		v1 = self.struct()
		v1.string = '1.2'
		status = Status('apackage', None, v1)
		report = self.reporter.format(status)
		self.assertContains(report, '(->1.2')
		self.assertNotContains(report, '[')

	def testFormatting(self):
		v1 = self.struct()
		v1.string = '1.2'
		v2 = self.struct()
		v2.string = '1.3'
		v3, v4 = self.struct(), self.struct()
		v3.string = '1.2.3'
		v4.string = 'x.y.z'
		status = Status('apackage', v1, v2, {'Debian': [v3, v4], 'another origin': [v3, v4]})
		report = self.reporter.format(status)
		self.assertContains(report, 'apackage (1.2->1.3) ')
		self.assertContains(report, ' [Debian: 1.2.3 x.y.z]')
		self.assertContains(report, ' [another origin: 1.2.3 x.y.z]')

	def testFormattingSameVersion(self):
		v = self.struct()
		v.string = '1.2'
		status = Status('apackage', v, v)
		report = self.reporter.format(status)
		self.assertNotContains(report, '[')
		self.assertContains(report, 'apackage (1.2)')

	def testReporting(self):
		"""Since this should print to stdout, we don't call it, just check the method's there."""
		mock_status = self.struct()
		self.assert_(self.reporter.report)