~allenap/storm/blocked-references

« back to all changes in this revision

Viewing changes to tests/store/base.py

  • Committer: Gavin Panella
  • Date: 2011-05-04 14:44:18 UTC
  • Revision ID: gavin@gromper.net-20110504144418-y946anf33vyf80g2
Make it possible to block Reference gets that hit the database.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2729
2729
        self.assertTrue(bar.foo)
2730
2730
        self.assertEquals(bar.foo.title, "Title 30")
2731
2731
 
 
2732
    def test_reference_blocked(self):
 
2733
        bar = self.store.get(Bar, 100)
 
2734
        with Reference.blocked():
 
2735
            self.assertRaises(ConnectionBlockedError, getattr, bar, "foo")
 
2736
 
 
2737
    def test_reference_blocked_and_remote_loaded(self):
 
2738
        bar = self.store.get(Bar, 100)
 
2739
        self.assertTrue(bar.foo)
 
2740
        with Reference.blocked():
 
2741
            self.assertTrue(bar.foo)
 
2742
 
 
2743
    def test_reference_blocked_and_remote_loaded_but_invalidated(self):
 
2744
        bar = self.store.get(Bar, 100)
 
2745
        self.assertTrue(bar.foo)
 
2746
        self.store.invalidate(bar.foo)
 
2747
        with Reference.blocked():
 
2748
            self.assertRaises(ConnectionBlockedError, getattr, bar, "foo")
 
2749
 
 
2750
    def test_reference_blocked_and_unblocked(self):
 
2751
        bar = self.store.get(Bar, 100)
 
2752
        with Reference.blocked():
 
2753
            with Reference.unblocked():
 
2754
                self.assertTrue(bar.foo)
 
2755
 
2732
2756
    def test_reference_explicitly_with_wrapper(self):
2733
2757
        bar = self.store.get(Bar, 100)
2734
2758
        foo = Bar.foo.__get__(Wrapper(bar))