Esempio n. 1
0
 def test_full_html_caption_nothing(self):
     """
     Test that full_html_caption() returns an empty string when there
     is no asset metadata to include in the caption
     """
     asset = create_html_asset(type='image', title='Test Asset')
     self.assertEqual(asset.full_caption_html(), '')
Esempio n. 2
0
 def test_dataset_html_nothing(self):
     """
     Test that dataset_html() returns nothing when there are no
     associated datasets
     """
     asset = create_html_asset(type='image', title='Test Asset')
     self.assertEqual(asset.dataset_html(), "")
Esempio n. 3
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())
Esempio n. 4
0
 def test_full_html_caption_attribution_only(self):
     """
     Test that full_html_caption() includes the attribution field text
     when there is only an attribution to include in the caption
     """
     attribution = "Some photographer"
     asset = create_html_asset(type='image', title='Test Asset',
                               attribution=attribution)
     self.assertIn(attribution, asset.full_caption_html())
Esempio n. 5
0
 def test_full_html_caption_caption_only(self):
     """
     Test that full_html_caption() includes the caption field text
     when there is only a caption to include in the caption
     """
     caption = "This is a test caption"
     asset = create_html_asset(type='image', title='Test Asset',
                               caption=caption)
     self.assertIn(caption, asset.full_caption_html())
Esempio n. 6
0
 def test_full_html_caption_attribution_caption(self):
     """
     Test that full_html_caption() includes both the caption and
     attribution field text when both are set 
     """
     attribution = "Some photographer"
     caption = "This is a test caption"
     asset = create_html_asset(type='image', title='Test Asset',
                               attribution=attribution,
                               caption=caption)
     self.assertIn(caption, asset.full_caption_html())
     self.assertIn(attribution, asset.full_caption_html())
Esempio n. 7
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())
Esempio n. 8
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()) 
Esempio n. 9
0
    def test_create_html_asset(self):
        """ Test create_html_asset() """

        title = "Success Express"
        type = "quotation"
        attribution = "Ed Brennan, EdNews Colorado"
        source_url = "http://www.ednewsparent.org/teaching-learning/5534-denvers-success-express-rolls-out-of-the-station"
        asset_created = datetime.strptime('2011-06-03 00:00',
                                          '%Y-%m-%d %H:%M')
        status='published'
        body = """
        In both the Far Northeast and the Near Northeast, school buses 
        will no longer make a traditional series of stops in neighborhoods
        - once in the morning and once in the afternoon. Instead, a fleet
        of DPS buses will circulate between area schools, offering students
        up to three chances to catch the one that will get them to their
        school of choice on time.

        Martha Carranza, who has a child at Bruce Randolph, said that for
        students who have depended on RTD, "I was very worried because it
        is very dangerous for the children coming from Globeville and also
        from Swansea ... the kids were arriving late and sometimes missing
        classes altogether."

        And, said Carranza, "... we are very happy that with the new
        transportation system, no child will have any excuse to miss 
        school."
        """
        asset = create_html_asset(type, title, caption='', body=body,
            attribution=attribution, source_url=source_url, status=status,
            asset_created=asset_created)
        self.assertEqual(asset.title, title)
        self.assertEqual(asset.type, type)
        self.assertEqual(asset.attribution, attribution)
        self.assertEqual(asset.source_url, source_url)
        self.assertEqual(asset.asset_created, asset_created)
        self.assertEqual(asset.status, status)
        retrieved_asset = HtmlAsset.objects.get(pk=asset.pk)
        self.assertEqual(retrieved_asset.title, title)
        self.assertEqual(retrieved_asset.type, type)
        self.assertEqual(retrieved_asset.attribution, attribution)
        self.assertEqual(retrieved_asset.source_url, source_url)
        self.assertEqual(retrieved_asset.asset_created, asset_created)
        self.assertEqual(retrieved_asset.status, status)