Exemplo n.º 1
0
 def test_updated_dict(self):
     heather_raw = "./fixtures/HeatherPiwowar_070914.json"
     heather_json = open(heather_raw)
     raw_dict = json.load(heather_json)
     product_list = raw_dict.get('products', [])
     ImpactStory._updated_dict(self.heather, product_list)
     self.assertFalse(self.heather._new_attributes)
Exemplo n.º 2
0
    def test__parse_products(self):
        brian_raw = "./fixtures/BrianNosek_070814.json"
        product_json = open(brian_raw)
        product_dict = json.load(product_json)
        product_list = product_dict.get('products', None)
        ImpactStory._parse_products(self.brian, product_list)

        self.assertTrue(self.brian.articles)
        self.assertFalse(self.brian.datasets)
        self.assertFalse(self.brian.figures)
        self.assertFalse(self.brian.slides)
        self.assertTrue(self.brian.software)
        self.assertTrue(self.brian.unknown)
        self.assertFalse(self.brian.videos)
        self.assertTrue(self.brian.webpages)
Exemplo n.º 3
0
    def test__parse_products_none(self):
        saman_raw = "./fixtures/SamanEhsan_070814.json"
        product_json = open(saman_raw)
        product_dict = json.load(product_json)
        product_list = product_dict.get('products', [])
        ImpactStory._parse_products(self.saman, product_list)

        self.assertFalse(self.saman.articles)
        self.assertFalse(self.saman.datasets)
        self.assertFalse(self.saman.figures)
        self.assertFalse(self.saman.slides)
        self.assertFalse(self.saman.software)
        self.assertFalse(self.saman.unknown)
        self.assertFalse(self.saman.videos)
        self.assertFalse(self.saman.webpages)
Exemplo n.º 4
0
    def test__parse_products_all(self):
        heather_raw = "./fixtures/HeatherPiwowar_070914.json"
        heather_json = open(heather_raw)
        raw_dict = json.load(heather_json)
        product_list = raw_dict.get('products', [])
        ImpactStory._parse_products(self.heather, product_list)

        self.assertTrue(self.heather.articles)
        self.assertTrue(self.heather.datasets)
        self.assertTrue(self.heather.figures)
        self.assertTrue(self.heather.slides)
        self.assertTrue(self.heather.software)
        self.assertTrue(self.heather.unknown)
        self.assertTrue(self.heather.videos)
        self.assertTrue(self.heather.webpages)
Exemplo n.º 5
0
 def test_from_file_csv(self):
     csv_file = "./fixtures/HeatherPiwowar_070814.csv"
     ImpactStory.from_file(csv_file)
     self.assertTrue("File type is not JSON")
Exemplo n.º 6
0
 def test_from_file_corrupted(self):
     corrupted_json = "./fixtures/Corrupted_JSON.json"
     with self.assertRaises(ImpactStoryParseException) as cm:
         ImpactStory.from_file(corrupted_json)
     exception = cm.exception
     self.failUnlessRaises(exception)
Exemplo n.º 7
0
 def test_from_file_json(self):
     json_file = "./fixtures/HeatherPiwowar_070914.json"
     impact_story_obj = ImpactStory.from_file(json_file)
     self.assertIsInstance(impact_story_obj, ImpactStory)
Exemplo n.º 8
0
 def test_from_id_invalid(self):
     with self.assertRaises(ImpactStoryHTTPException) as cm:
         ImpactStory.from_id("Htr Pwr")
     exception = cm.exception
     self.failUnlessRaises(exception)
Exemplo n.º 9
0
 def test_from_id_valid(self):
     impact_story_obj = ImpactStory.from_id("Heather Piwowar")
     self.assertIsInstance(impact_story_obj, ImpactStory)
Exemplo n.º 10
0
 def setUp(self):
     self.heather = ImpactStory.from_id("Heather Piwowar")
     self.saman = ImpactStory.from_file("./fixtures/SamanEhsan_070814.json")
     self.brian = ImpactStory.from_id("Brian Nosek")