def test_build_version_with_valid_package_name(self): package = Mock(project_name='foo', version='1.0.0') setattr(settings, 'HEARTBEAT', {'package_name': 'foo'}) with mock.patch.object(build.WorkingSet, 'find', return_value=package): distro = build.check(request=None) assert distro == {'name': 'foo', 'version': '1.0.0'}
def test_build_version_invalid_package_name(self): setattr(settings, 'HEARTBEAT', {'package_name': 'missing-package'}) distro = build.check(request=None) assert distro == {'error': 'no distribution found for missing-package'}
def test_build_version_missing_package_name(self, pkg): setattr(settings, 'HEARTBEAT', pkg) with pytest.raises(ImproperlyConfigured) as e: build.check(request=None) msg = 'Missing package_name key from heartbeat configuration' assert msg in str(e)