def test_url_replacement(self): url = "http://compute.bccvl.org.au/experiments/bioclim-unthemed/bioclim-unthemed-result-2013-11-20t00-47-41-120241/results.html/view/++widget++form.widgets.file/@@download/results.html" html_string = '''<html><img src="AUC.png" other_attr='12' other_attr="12" /><img src='ALL.png' other_attr='23' other_attr="12" /></html>''' expected_content = '''<html><img src="http://compute.bccvl.org.au/experiments/bioclim-unthemed/bioclim-unthemed-result-2013-11-20t00-47-41-120241/AUC.png/view/++widget++form.widgets.file/@@download/AUC.png" other_attr='12' other_attr="12" /><img src="http://compute.bccvl.org.au/experiments/bioclim-unthemed/bioclim-unthemed-result-2013-11-20t00-47-41-120241/ALL.png/view/++widget++form.widgets.file/@@download/ALL.png" other_attr='23' other_attr="12" /></html>''' out_content = HTMLAPIv1.replace_urls(html_string, url) self.assertEqual(out_content, expected_content)
def view(self): log = logging.getLogger(__name__) log.debug('Processing view request in HTML API v1') data_url = self.request.GET.getone('data_url') content = None MyDataMover = FDataMover.get_data_mover_class() with MyDataMover.open(data_url=data_url) as f: content = f.read() out_str = HTMLAPIv1.replace_urls(content, data_url) response = Response(out_str, content_type="text/html") return response