# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1234916643 -3600 # Node ID 4da6e0f4df2ae901eb561d981f34e40abf386ef0 # Parent 62ff117dc99c8f3499bb845680e4361dca255f1a test upgrade diff -r 62ff117dc99c -r 4da6e0f4df2a common/test/data/bootstrap_cubes --- a/common/test/data/bootstrap_cubes Wed Feb 18 01:23:14 2009 +0100 +++ b/common/test/data/bootstrap_cubes Wed Feb 18 01:24:03 2009 +0100 @@ -1,1 +1,1 @@ -file, tag + diff -r 62ff117dc99c -r 4da6e0f4df2a common/test/data/schema/relations.rel --- a/common/test/data/schema/relations.rel Wed Feb 18 01:23:14 2009 +0100 +++ b/common/test/data/schema/relations.rel Wed Feb 18 01:24:03 2009 +0100 @@ -9,8 +9,5 @@ Note ecrit_par Personne inline CONSTRAINT E concerns P, X version_of P Personne connait Personne symetric -Tag tags Note -Tag tags Personne - Affaire liee_a Societe Affaire liee_a Personne diff -r 62ff117dc99c -r 4da6e0f4df2a test/data/bootstrap_cubes --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/data/bootstrap_cubes Wed Feb 18 01:24:03 2009 +0100 @@ -0,0 +1,1 @@ +file, tag diff -r 62ff117dc99c -r 4da6e0f4df2a test/data/bootstrap_packages --- a/test/data/bootstrap_packages Wed Feb 18 01:23:14 2009 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ - diff -r 62ff117dc99c -r 4da6e0f4df2a test/data/entities.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/data/entities.py Wed Feb 18 01:24:03 2009 +0100 @@ -0,0 +1,15 @@ +from cubicweb.entities import AnyEntity, fetch_config + +class Personne(AnyEntity): + """customized class forne Person entities""" + id = 'Personne' + fetch_attrs, fetch_order = fetch_config(['nom', 'prenom']) + rest_attr = 'nom' + + +class Societe(AnyEntity): + id = 'Societe' + fetch_attrs = ('nom',) + +class Note(AnyEntity): + id = 'Note' diff -r 62ff117dc99c -r 4da6e0f4df2a test/data/schema.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/data/schema.py Wed Feb 18 01:24:03 2009 +0100 @@ -0,0 +1,27 @@ +class Personne(EntityType): + nom = String() + prenom = String() + type = String() + travaille = SubjectRelation('Societe') + evaluee = SubjectRelation(('Note', 'Personne')) + connait = SubjectRelation('Personne', symetric=True) + +class Societe(EntityType): + nom = String() + evaluee = SubjectRelation('Note') + +class Note(EntityType): + type = String() + ecrit_par = SubjectRelation('Personne') + +class SubNote(Note): + __specializes_schema__ = True + descr = String() + +class tags(RelationDefinition): + subject = 'Tag' + object = ('Personne', 'Note') + +class evaluee(RelationDefinition): + subject = 'EUser' + object = 'Note' diff -r 62ff117dc99c -r 4da6e0f4df2a test/unittest_entity.py --- a/test/unittest_entity.py Wed Feb 18 01:23:14 2009 +0100 +++ b/test/unittest_entity.py Wed Feb 18 01:24:03 2009 +0100 @@ -16,7 +16,7 @@ ## embed=False) def test_boolean_value(self): - e = self.etype_instance('Tag') + e = self.etype_instance('EUser') self.failUnless(e) def test_yams_inheritance(self): @@ -27,7 +27,7 @@ self.assertIs(e.__class__, e2.__class__) def test_has_eid(self): - e = self.etype_instance('Tag') + e = self.etype_instance('EUser') self.assertEquals(e.eid, None) self.assertEquals(e.has_eid(), False) e.eid = 'X' @@ -167,16 +167,17 @@ def test_related_rql(self): from cubicweb.entities import fetch_config Personne = self.vreg.etype_class('Personne') - Societe = self.vreg.etype_class('Societe') - Personne.fetch_attrs, Personne.fetch_order = fetch_config(('nom', 'prenom', 'sexe')) - Societe.fetch_attrs, Societe.fetch_order = fetch_config(('nom', 'web')) - aff = self.add_entity('Affaire', sujet=u'my subject', ref=u'the ref') - self.assertEquals(aff.related_rql('liee_a'), - 'Any X,AA,AB ORDERBY AA ASC WHERE E eid %(x)s, E liee_a X, ' - 'X nom AA, X modification_date AB') - Societe.fetch_attrs = ('web',) - self.assertEquals(aff.related_rql('liee_a'), - 'Any X ORDERBY Z DESC WHERE X modification_date Z, E eid %(x)s, E liee_a X') + Note = self.vreg.etype_class('Note') + Personne.fetch_attrs, Personne.fetch_order = fetch_config(('nom', 'type')) + Note.fetch_attrs, Note.fetch_order = fetch_config(('type',)) + aff = self.add_entity('Personne', nom=u'pouet') + self.assertEquals(aff.related_rql('evaluee'), + 'Any X,AA,AB ORDERBY AA ASC WHERE E eid %(x)s, E evaluee X, ' + 'X type AA, X modification_date AB') + Personne.fetch_attrs, Personne.fetch_order = fetch_config(('nom', )) + # XXX + self.assertEquals(aff.related_rql('evaluee'), + 'Any X,AA ORDERBY Z DESC WHERE X modification_date Z, E eid %(x)s, E evaluee X, X modification_date AA') def test_entity_unrelated(self): p = self.add_entity('Personne', nom=u'di mascio', prenom=u'adrien') @@ -265,6 +266,7 @@ ('owned_by', 'object'), ('bookmarked_by', 'object')]) e = self.etype_instance('Personne') + print rbc(e.relations_by_category('primary')) self.assertListEquals(rbc(e.relations_by_category('primary')), [('nom', 'subject'), ('eid', 'subject')]) self.assertListEquals(rbc(e.relations_by_category('secondary')), @@ -386,12 +388,10 @@ def test_entity_formatted_attrs(self): - e = self.etype_instance('Note') + e = self.etype_instance('EUser') self.assertEquals(e.formatted_attrs(), []) e = self.etype_instance('File') self.assertEquals(e.formatted_attrs(), ['description']) - e = self.etype_instance('AnotherNote') - self.assertEquals(e.formatted_attrs(), ['descr', 'descr2']) def test_fulltextindex(self):