def testTags(self): a = Artist() a.addTag(Tag('foo', 1)) a.addTag(Tag('bar', 2)) a.addTag(Tag('bar', 5)) self.assertEquals(len(a.tags), 2) self.assertEquals(a.getTag('foo').count, 1) self.assertEquals(a.getTag('bar').count, 7)
def testAddRelation(self): rel = Relation(NS_REL_1+'Producer', Relation.TO_RELEASE, 'a_id', attributes=[NS_REL_1+'Co']) artist = Artist('ar_id', 'Tori Amos', 'Person') artist.addRelation(rel) rel2 = artist.getRelations(Relation.TO_RELEASE)[0] self.assertEquals(rel.getType(), rel2.getType()) self.assertEquals(rel.getTargetType(), rel2.getTargetType()) self.assertEquals(rel.getTargetId(), rel2.getTargetId()) self.assertEquals(rel.getAttributes(), rel2.getAttributes()) self.assertEquals(rel.getBeginDate(), rel2.getBeginDate()) self.assertEquals(rel.getEndDate(), rel2.getEndDate()) self.assertEquals(artist.getRelationTargetTypes(), [ Relation.TO_RELEASE ]) # works because we only have one relation self.assertEquals(artist.getRelations(), artist.getRelations(Relation.TO_RELEASE)) rel3 = artist.getRelations(Relation.TO_RELEASE, NS_REL_1 + 'Producer') self.assertEquals(len(rel3), 1) rel4 = artist.getRelations(Relation.TO_RELEASE, NS_REL_1 + 'Producer', [NS_REL_1 + 'Co']) self.assertEquals(len(rel4), 1) rel5 = artist.getRelations(Relation.TO_RELEASE, NS_REL_1 + 'Producer', [NS_REL_1 + 'NotThere']) self.assertEquals(len(rel5), 0) rel6 = artist.getRelations(Relation.TO_RELEASE, NS_REL_1 + 'Producer', [NS_REL_1 + 'Co'], 'none') self.assertEquals(len(rel6), 1) rel6 = artist.getRelations(Relation.TO_RELEASE, NS_REL_1 + 'Producer', [NS_REL_1 + 'Co'], 'forward') self.assertEquals(len(rel6), 0)
def testAddRelease(self): release = Release() artist = Artist() artist.addRelease(release) self.assertEquals(artist.releases, [release])