Exemplo n.º 1
0
 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 &iacute;container</div> <p>&pound;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)
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
 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
Exemplo n.º 4
0
 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
Exemplo n.º 5
0
 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
Exemplo n.º 6
0
 def test_converted_html_in_tags_with_with_multiple_tags(self):
     tagged_value = """<p><p><p><p>Abstract value &amp; 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)
Exemplo n.º 7
0
 def test_converted_html_in_tags_with_char_references(self):
     tagged_value = """<p>&lt;p&gt;Abstract value &amp; some text&lt;/p&gt;</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)
Exemplo n.º 8
0
 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)
Exemplo n.º 9
0
 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)