Ejemplo n.º 1
0
 def test_dataset_html_two(self):
     """
     Test that dataset_html() lists a lone dataset associated
     with an Asset
     """
     dataset_title1 = ("Metro Denver Free and Reduced Lunch Trends by "
                      "School District")
     dataset_url1 = 'http://www.box.com/s/erutk9kacq6akzlvqcdr'
     asset = create_html_asset(type='image', title='Test Asset')
     dataset1 = create_external_dataset(
         title=dataset_title1,
         url=dataset_url1,
         source="Colorado Department of Education for Source",
         attribution="The Piton Foundation")
     dataset_url2 = 'http://www.example.com/somedata.csv'
     dataset_title2 = "Test Dataset"
     dataset2 = create_external_dataset(
         title=dataset_title2,
         url=dataset_url2,
         source="Test Dataset Source",
         attribution="Test Dataset Hacker")
     asset.datasets.add(dataset1)
     asset.datasets.add(dataset2)
     asset.save()
     self.assertIn(dataset_title1, asset.dataset_html()) 
     self.assertIn(dataset_url1, asset.dataset_html())
     self.assertIn(dataset_title2, asset.dataset_html()) 
     self.assertIn(dataset_url2, asset.dataset_html())
Ejemplo n.º 2
0
 def test_create_external_dataset(self):
     """Test create_external_dataset()"""
     user = User.objects.create(username='******')
     url = 'http://www.box.com/s/erutk9kacq6akzlvqcdr'
     title = ("Metro Denver Free and Reduced Lunch Trends by School "
              "District")
     source = "Colorado Department of Education for Source"
     attribution = "The Piton Foundation"
     dataset = create_external_dataset(title=title, url=url, 
                                       source=source, 
                                       attribution=attribution,
                                       owner=user)
     self.assertEqual(dataset.title, title)
     self.assertEqual(dataset.download_url(), url)
     self.assertEqual(dataset.owner, user)
     self.assertEqual(dataset.source, source)
     self.assertEqual(dataset.attribution, attribution)
Ejemplo n.º 3
0
 def test_full_html_caption_dataset_only(self):
     """
     Test that full_html_caption() includes listed datasets
     when only datasets are associated with an asset
     """
     asset = create_html_asset(type='image', title='Test Asset')
     dataset_title = ("Metro Denver Free and Reduced Lunch Trends by "
                      "School District")
     dataset_url = 'http://www.box.com/s/erutk9kacq6akzlvqcdr'
     dataset = create_external_dataset(
         title=dataset_title,
         url=dataset_url,
         source="Colorado Department of Education for Source",
         attribution="The Piton Foundation")
     asset.datasets.add(dataset)
     asset.save()
     self.assertIn(dataset_title, asset.full_caption_html())
Ejemplo n.º 4
0
    def test_dataset_html_download_text_links_to_file_false(self):
        """
        Test that dataset_html() has the correct interface text when the
        dataset URL doesn't point to a downloadable file.
        """
        dataset_title = ("Metro Denver Free and Reduced Lunch Trends by "
                         "School District")
        dataset_url = 'http://www.box.com/s/erutk9kacq6akzlvqcdr'
        asset = create_html_asset(type='image', title='Test Asset')
        dataset = create_external_dataset(
            title=dataset_title,
            url=dataset_url,
            source="Colorado Department of Education for Source",
            attribution="The Piton Foundation",
	    links_to_file=False)
        asset.datasets.add(dataset)
        asset.save()
        self.assertIn("View the data", asset.dataset_html())