Changeset 3268

Show
Ignore:
Timestamp:
05/30/07 10:55:55 (1 year ago)
Author:
pobrien
Message:

Failing tests.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Schevo/tests/test_on_delete.py

    r3266 r3268  
    105105                  .-------.bat = Bat[1] |     | RESTRICT 
    106106                  |     `---------------`     | 
    107                  |                           | 
     107         RESTRICT |                           | 
    108108                  |     .---------------.     | 
    109109                  `---->| Bat[1]        |     | 
     
    131131 
    132132        bam = f.entity('Bam') 
     133 
     134 
     135    # ---------------------------------------------------------------- 
     136 
     137 
     138    class Bamc(E.Entity): 
     139        """Bamc and Batc circularly reference eachother. 
     140 
     141        The relationships created upon a creation of a Bamc entity 
     142        can be visualized as follows:: 
     143 
     144                        .-----------------. 
     145                        | Bamc[1]         |<----. 
     146                        |                 |     | 
     147                  .-------.batc = Batc[1] |     | CASCADE 
     148                  |     `-----------------`     | 
     149         RESTRICT |                             | 
     150                  |     .-----------------.     | 
     151                  `---->| Batc[1]         |     | 
     152                        |                 |     | 
     153                        | .bamc = Bamc[1]-------` 
     154                        `-----------------` 
     155        """ 
     156 
     157        batc = f.entity('Batc') 
     158 
     159        class _Create(T.Create): 
     160 
     161            def _setup(self): 
     162                # We assign this internally. 
     163                del self.f.batc 
     164 
     165            def _after_execute(self, db, bamc): 
     166                create = db.Batc.t.create 
     167                # Every bamc has one batc. 
     168                batc = db.execute(create(bamc=bamc)) 
     169                db.execute(bamc.t.update(batc=batc)) 
     170 
     171 
     172    class Batc(E.Entity): 
     173 
     174        bamc = f.entity('Bamc', on_delete=CASCADE) 
    133175 
    134176 
     
    363405        assert alpha_bravo not in db.AlphaBravo 
    364406 
    365     def test_cascade_bam(self): 
     407    def test_cascade_bamc(self): 
     408        bamc = db.execute(db.Bamc.t.create()) 
     409        tx = bamc.t.delete() 
     410        db.execute(tx) 
     411        assert bamc not in db.Bamc 
     412 
     413    def test_restrict_bam(self): 
    366414        bam = db.execute(db.Bam.t.create()) 
    367415        tx = bam.t.delete() 
    368         db.execute(tx) 
    369         assert bam not in db.Bam 
     416        assert raises(error.DeleteRestricted, db.execute, tx) 
    370417 
    371418    def test_cascade_bamm(self):