def test_complex_tags_in_attribute(self): tagged_value = """<p style="display:none;" id="test">This is not a templated text<p> <div class="test_css">Something in ícontainer</div> <p>£682m</p>""" attribute_target_value = """This is not a templated text Something in ícontainer £682m""" r = ResourceBase() filtered_value = r._remove_html_tags(tagged_value) self.assertEqual(filtered_value, attribute_target_value)
def finalize_resource_update( self, geonode_resource: ResourceBase, harvested_info: base.HarvestedResourceInfo, harvestable_resource: models.HarvestableResource, harvesting_session_id: int) -> ResourceBase: is_document = (harvestable_resource.remote_resource_type == GeoNodeResourceType.DOCUMENT.value) if is_document: geonode_resource.thumbnail_url = ( harvested_info.resource_descriptor.distribution.thumbnail_url) geonode_resource.doc_url = (harvested_info.resource_descriptor. distribution.original_format_url) geonode_resource.save() return geonode_resource
def finalize_resource_update( self, geonode_resource: ResourceBase, harvested_info: base.HarvestedResourceInfo, harvestable_resource: harvesting_models.HarvestableResource, harvesting_session_id: int) -> ResourceBase: if harvestable_resource.remote_resource_type != PdnResourceType.DOCUMENT.value: raise RuntimeError( f"Unexpected resource type: {harvestable_resource.remote_resource_type}" ) else: geonode_resource.thumbnail_url = harvested_info.resource_descriptor.distribution.thumbnail_url geonode_resource.doc_url = harvested_info.resource_descriptor.distribution.original_format_url geonode_resource.save() return geonode_resource
def replace(self, instance: ResourceBase, vals: dict = {}) -> ResourceBase: if instance and isinstance(instance.get_real_instance(), Dataset): return self.import_dataset( 'import_dataset', instance.uuid, instance=instance, files=vals.get('files', None), user=vals.get('user', instance.owner), action_type='replace', importer_session_opts=vals.get('importer_session_opts', None)) return instance
def append(self, instance: ResourceBase, vals: dict = {}) -> ResourceBase: if instance and isinstance(instance.get_real_instance(), Layer): return self.import_layer('import_layer', instance.uuid, instance=instance, files=vals.get('files', None), user=vals.get('user', instance.owner), action_type='append', importer_session_opts=vals.get( 'importer_session_opts', None)) return instance
def test_converted_html_in_tags_with_with_multiple_tags(self): tagged_value = """<p><p><p><p>Abstract value & some text</p></p></p></p>""" attribute_target_value = """Abstract value & some text""" r = ResourceBase() filtered_value = r._remove_html_tags(tagged_value) self.assertEqual(filtered_value, attribute_target_value)
def test_converted_html_in_tags_with_char_references(self): tagged_value = """<p><p>Abstract value & some text</p></p>""" attribute_target_value = """Abstract value & some text""" r = ResourceBase() filtered_value = r._remove_html_tags(tagged_value) self.assertEqual(filtered_value, attribute_target_value)
def test_simple_tags_in_attribute(self): tagged_value = "<p>This is not a templated text<p>" attribute_target_value = "This is not a templated text" r = ResourceBase() filtered_value = r._remove_html_tags(tagged_value) self.assertEqual(filtered_value, attribute_target_value)
def test_not_tags_in_attribute(self): attribute_target_value = "This is not a templated text" r = ResourceBase() filtered_value = r._remove_html_tags(attribute_target_value) self.assertEqual(attribute_target_value, filtered_value)