- f = wlp.image_file('r')
- f.close()
-
-def test_picture_parts():
- wlp = picture.WLPicture.from_file(open(get_fixture('picture', 'angelus-novus.xml')))
- parts = list(wlp.partiter())
- expect_parts = 4
- assert len(parts) == expect_parts, "there should be %d parts of the picture" % expect_parts
- motifs = set()
- names = set()
-
- print parts
- for p in parts:
- for m in p['themes']:
- motifs.add(m)
- for p in parts:
- if p['object']:
- names.add(p['object'])
-
- assert motifs == set([u'anioł historii', u'spojrzenie']), "missing motifs, got: %s" % motifs
- assert names == set([u'obraz cały', u'skrzydło']), 'missing objects, got: %s' % names
+ def test_load(self):
+ for fixture in get_all_fixtures('picture', '*.xml'):
+ with self.subTest(fixture=fixture):
+ self.check_load(fixture)
+
+ def test_wlpicture(self):
+ with open(get_fixture('picture', 'angelus-novus.xml')) as f:
+ wlp = picture.WLPicture.from_file(f)
+ pi = wlp.picture_info
+
+ self.assertEqual(pi.type[0], "Image")
+ self.assertEqual(pi.mime_type, 'image/jpeg')
+ self.assertEqual(wlp.mime_type, 'image/jpeg')
+ self.assertEqual(wlp.slug, 'angelus-novus')
+ self.assertTrue(path.exists(wlp.image_path))