def test_constructor_default(self): expected_level = dependency_highlighter.PriorityLevel.UP_TO_DATE expected_details = '' priority = dependency_highlighter.Priority() self.assertEqual(expected_level, priority.level) self.assertEqual(expected_details, priority.details)
def test_constructor_explicit(self): expected_level = dependency_highlighter.PriorityLevel.LOW_PRIORITY expected_details = 'this is a test' priority = dependency_highlighter.Priority(level=expected_level, details=expected_details) self.assertEqual(expected_level, priority.level) self.assertEqual(expected_details, priority.details)
class TestOutdatedDependency(unittest.TestCase): expected_pkgname = 'google-cloud-bigquery' expected_parent = 'apache-beam[gcp]' expected_priority = dependency_highlighter.Priority( dependency_highlighter.PriorityLevel.HIGH_PRIORITY, 'this dependency is 1 or more major versions behind the latest') expected_info = _get_dep_info()[expected_pkgname] expected_repr = ("OutdatedDependency<'google-cloud-bigquery', " "HIGH_PRIORITY>") expected_str = ('Dependency Name:\tgoogle-cloud-bigquery\n' 'Priority:\t\tHIGH_PRIORITY\n' 'Installed Version:\t0.25.0\n' 'Latest Available:\t1.5.0\n' 'Time Since Latest:\t14 days\n' 'this dependency is 1 or more major versions ' 'behind the latest\n') outdated = dependency_highlighter.OutdatedDependency( pkgname=expected_pkgname, parent=expected_parent, priority=expected_priority, info=expected_info) def test_constructor(self): self.assertEqual(self.expected_pkgname, self.outdated.name) self.assertEqual(self.expected_parent, self.outdated.parent) self.assertEqual(self.expected_priority, self.outdated.priority) self.assertEqual(self.expected_info['installed_version'], self.outdated.installed_version) self.assertEqual(self.expected_info['installed_version_time'], self.outdated.installed_version_time) self.assertEqual(self.expected_info['latest_version'], self.outdated.latest_version) self.assertEqual(self.expected_info['latest_version_time'], self.outdated.latest_version_time) self.assertEqual(self.expected_info['current_time'], self.outdated.current_time) def test_repr(self): self.assertEqual(self.expected_repr, self.outdated.__repr__()) def test_str(self): self.assertEqual(self.expected_str, str(self.outdated))
def expect(level, msg): return dependency_highlighter.Priority(level, msg)