def test_mismatched_versions(self, mock_log): """Assert when libraries.io and Anitya disagree on version, it's logged""" project = Project( name="ImageMetaTag", homepage="https://pypi.org/project/ImageMetaTag/", ecosystem_name="pypi", backend="PyPI", ) self.session.add(project) self.session.commit() event = sseclient.Event( data="{" '"name": "ImageMetaTag",' '"platform": "PyPi",' '"version": "0.6.11",' '"package_manager_url": "https://pypi.org/project/ImageMetaTag/"' "}" ) self.client.process_message(event) project = self.session.query(Project).first() self.assertEqual("0.6.9", project.latest_version) self.assertIn( "libraries.io has found an update (version 0.6.11) for project ImageMetaTag", mock_log.info.call_args_list[0][0][0], )
def test_existing_project_check_failure(self, mock_check): """Assert that when an existing project fails a version check nothing happens""" mock_check.side_effect = AnityaPluginException() project = Project( name="ImageMetaTag", homepage="https://pypi.python.org/pypi/ImageMetaTag", ecosystem_name="pypi", backend="PyPI", ) self.session.add(project) self.session.commit() event = sseclient.Event( data="{" '"name": "ImageMetaTag",' '"platform": "PyPi",' '"version": "0.6.9",' '"package_manager_url": "https://pypi.org/project/ImageMetaTag/"' "}" ) self.assertEqual(1, self.session.query(Project).count()) self.client.process_message(event) self.assertEqual(1, self.session.query(Project).count()) project = self.session.query(Project).first() self.assertIs(project.latest_version, None)
def test_existing_project(self): """Assert that a libraries.io event about an existing project updates that project""" project = Project( name="ImageMetaTag", homepage="https://pypi.org/project/ImageMetaTag/", ecosystem_name="pypi", backend="PyPI", ) self.session.add(project) self.session.commit() event = sseclient.Event( data="{" '"name": "ImageMetaTag",' '"platform": "PyPi",' '"version": "0.6.9",' '"package_manager_url": "https://pypi.org/project/ImageMetaTag/"' "}" ) self.assertEqual(1, self.session.query(Project).count()) self.client.process_message(event) self.assertEqual(1, self.session.query(Project).count()) project = self.session.query(Project).first() self.assertEqual("ImageMetaTag", project.name) self.assertEqual("pypi", project.ecosystem_name) self.assertEqual("0.6.9", project.latest_version)
def test_existing_project_check_failure(self, mock_check): """Assert that when an existing project fails a version check nothing happens""" consumer = LibrariesioConsumer(self.mock_hub) mock_check.side_effect = AnityaPluginException() project = Project( name='ImageMetaTag', homepage='https://pypi.python.org/pypi/ImageMetaTag', ecosystem_name='pypi', backend='PyPI', ) self.session.add(project) self.session.commit() self.assertEqual(1, self.session.query(Project).count()) consumer.consume(self.supported_fedmsg) self.assertEqual(1, self.session.query(Project).count()) project = self.session.query(Project).first() self.assertIs(project.latest_version, None)
def test_mismatched_versions(self, mock_log): """Assert when libraries.io and Anitya disagree on version, it's logged""" consumer = LibrariesioConsumer(self.mock_hub) project = Project( name='ImageMetaTag', homepage='https://pypi.org/project/ImageMetaTag/', ecosystem_name='pypi', backend='PyPI', ) self.session.add(project) self.session.commit() self.supported_fedmsg['body']['msg']['data']['version'] = '0.6.11' consumer.consume(self.supported_fedmsg) project = self.session.query(Project).first() self.assertEqual('0.6.9', project.latest_version) self.assertIn( 'libraries.io has found an update (version %s) for project %r', mock_log.info.call_args_list[1][0], )
def test_existing_project(self): """Assert that a libraries.io event about an existing project updates that project""" project = Project( name='ImageMetaTag', homepage='https://pypi.org/project/ImageMetaTag/', ecosystem_name='pypi', backend='PyPI', ) self.session.add(project) self.session.commit() consumer = LibrariesioConsumer(self.mock_hub) self.assertEqual(1, self.session.query(Project).count()) consumer.consume(self.supported_fedmsg) self.assertEqual(1, self.session.query(Project).count()) project = self.session.query(Project).first() self.assertEqual('ImageMetaTag', project.name) self.assertEqual('pypi', project.ecosystem_name) self.assertEqual('0.6.9', project.latest_version)
def test_mismatched_versions(self, mock_log): """Assert when libraries.io and Anitya disagree on version, it's logged""" consumer = LibrariesioConsumer(self.mock_hub) project = Project( name="ImageMetaTag", homepage="https://pypi.org/project/ImageMetaTag/", ecosystem_name="pypi", backend="PyPI", ) self.session.add(project) self.session.commit() self.supported_fedmsg["body"]["msg"]["data"]["version"] = "0.6.11" consumer.consume(self.supported_fedmsg) project = self.session.query(Project).first() self.assertEqual("0.6.9", project.latest_version) self.assertIn( "libraries.io has found an update (version %s) for project %r", mock_log.info.call_args_list[1][0], )