def testDeprecationWarning(self): """Assert that deprecation message is printed.""" with self.assertWarnsRegex(DeprecationWarning, r"class is deprecated"): ProjectVersionUpdated() with self.assertWarnsRegex(DeprecationWarning, r"class is deprecated"): ProjectVersionUpdated( topic="org.release-monitoring.prod.anitya.project.version.update", body={}, )
class TestProjectVersionUpdated(unittest.TestCase): """ Tests for anitya_schema.project_messages.ProjectVersionUpdated class. """ def setUp(self): """ Set up the tests. """ self.message = ProjectVersionUpdated() @mock.patch( "anitya_schema.project_messages.ProjectVersionUpdated.summary", new_callable=mock.PropertyMock, ) def test__str__(self, mock_property): """ Assert that correct string is returned. """ mock_property.return_value = "Dummy" self.assertEqual(self.message.__str__(), "Dummy") @mock.patch( "anitya_schema.project_messages.ProjectVersionUpdated.name", new_callable=mock.PropertyMock, ) @mock.patch( "anitya_schema.project_messages.ProjectVersionUpdated.version", new_callable=mock.PropertyMock, ) def test_summary(self, mock_version, mock_name): """ Assert that correct summary string is returned. """ mock_name.return_value = "Dummy" mock_version.return_value = "1.0.0" exp = "A new version '1.0.0' was found for project Dummy in release-monitoring." self.assertEqual(self.message.summary, exp) def test_name(self): """ Assert that name string is returned. """ self.message.body = {"project": {"name": "Dummy"}} self.assertEqual(self.message.name, "Dummy") def test_version(self): """ Assert that version string is returned. """ self.message.body = {"message": {"upstream_version": "1.0.0"}} self.assertEqual(self.message.version, "1.0.0")
def setUp(self): """ Set up the tests. """ self.message = ProjectVersionUpdated()
class TestProjectVersionUpdated(unittest.TestCase): """ Tests for anitya_schema.project_messages.ProjectVersionUpdated class. """ def setUp(self): """ Set up the tests. """ self.message = ProjectVersionUpdated() @mock.patch( "anitya_schema.project_messages.ProjectVersionUpdated.summary", new_callable=mock.PropertyMock, ) def test__str__(self, mock_property): """ Assert that correct string is returned. """ mock_property.return_value = "Dummy" self.assertEqual(self.message.__str__(), "Dummy") @mock.patch( "anitya_schema.project_messages.ProjectVersionUpdated.project_name", new_callable=mock.PropertyMock, ) @mock.patch( "anitya_schema.project_messages.ProjectVersionUpdated.version", new_callable=mock.PropertyMock, ) def test_summary(self, mock_version, mock_name): """ Assert that correct summary string is returned. """ mock_name.return_value = "Dummy" mock_version.return_value = "1.0.0" exp = "A new version '1.0.0' was found for project Dummy in release-monitoring." self.assertEqual(self.message.summary, exp) def test_agent(self): """Assert that agent is returned.""" self.message.body = {"message": {"agent": "Dummy"}} self.assertEqual(self.message.agent, "Dummy") def test_old_version(self): """Assert that old version is returned.""" self.message.body = {"message": {"old_version": "Dummy"}} self.assertEqual(self.message.old_version, "Dummy") def test_mappings(self): """ Assert that array of mappings is returned. """ self.message.body = { "message": { "packages": [ { "distro": "Fedora", "package_name": "package_fedora" }, { "distro": "CentOS", "package_name": "package_centos" }, ] } } exp = [ { "distro": "Fedora", "package_name": "package_fedora" }, { "distro": "CentOS", "package_name": "package_centos" }, ] self.assertEqual(self.message.mappings, exp) def test_distros(self): """ Assert that array of distros is returned. """ self.message.body = { "message": { "packages": [{ "distro": "Fedora" }, { "distro": "CentOS" }] } } self.assertEqual(self.message.distros, ["Fedora", "CentOS"]) def test_version(self): """ Assert that version string is returned. """ self.message.body = {"message": {"upstream_version": "1.0.0"}} self.assertEqual(self.message.version, "1.0.0")