コード例 #1
0
    def test_clear_readonly(self):
        table_before_clear = dict(a=1, b=2, c=3)

        s = MemoryKeyValueStore()
        s._table = table_before_clear
        s.is_read_only = mock.MagicMock(return_value=True)

        nose.tools.assert_raises(ReadOnlyError, s.clear)
        nose.tools.assert_equal(s._table, table_before_clear)
コード例 #2
0
    def test_clear_readonly(self):
        """ Test trying to clear on a read-only store. """
        table_before_clear = dict(a=1, b=2, c=3)

        s = MemoryKeyValueStore()
        s._table = table_before_clear
        s.is_read_only = mock.MagicMock(return_value=True)

        self.assertRaises(ReadOnlyError, s.clear)
        self.assertEqual(s._table, table_before_clear)
コード例 #3
0
    def test_clear_readonly(self):
        """ Test trying to clear on a read-only store. """
        table_before_clear = dict(a=1, b=2, c=3)

        s = MemoryKeyValueStore()
        s._table = table_before_clear
        s.is_read_only = mock.MagicMock(return_value=True)

        self.assertRaises(
            ReadOnlyError,
            s.clear
        )
        self.assertEqual(s._table, table_before_clear)
コード例 #4
0
 def test_read_only_with_read_only_cache(self):
     s = MemoryKeyValueStore()
     s._cache_element = DataMemoryElement(readonly=True)
     nose.tools.assert_true(s.is_read_only())
コード例 #5
0
 def test_read_only_with_writable_cache(self):
     s = MemoryKeyValueStore()
     s._cache_element = DataMemoryElement(readonly=False)
     nose.tools.assert_false(s.is_read_only())
コード例 #6
0
 def test_read_only_no_cache(self):
     s = MemoryKeyValueStore()
     nose.tools.assert_is_none(s._cache_element)
     nose.tools.assert_false(s.is_read_only())
コード例 #7
0
 def test_read_only_with_read_only_cache(self):
     """ Test that read-only status reflects a read-only cache """
     s = MemoryKeyValueStore()
     s._cache_element = DataMemoryElement(readonly=True)
     self.assertTrue(s.is_read_only())
コード例 #8
0
 def test_read_only_with_writable_cache(self):
     """ Test that read-only status reflects a non-read-only cache """
     s = MemoryKeyValueStore()
     s._cache_element = DataMemoryElement(readonly=False)
     self.assertFalse(s.is_read_only())
コード例 #9
0
 def test_read_only_no_cache(self):
     """ Test that read_only is false when there is no cache. """
     s = MemoryKeyValueStore()
     self.assertIsNone(s._cache_element)
     self.assertFalse(s.is_read_only())
コード例 #10
0
 def test_read_only_with_read_only_cache(self):
     """ Test that read-only status reflects a read-only cache """
     s = MemoryKeyValueStore()
     s._cache_element = DataMemoryElement(readonly=True)
     self.assertTrue(s.is_read_only())
コード例 #11
0
 def test_read_only_with_writable_cache(self):
     """ Test that read-only status reflects a non-read-only cache """
     s = MemoryKeyValueStore()
     s._cache_element = DataMemoryElement(readonly=False)
     self.assertFalse(s.is_read_only())
コード例 #12
0
 def test_read_only_no_cache(self):
     """ Test that read_only is false when there is no cache. """
     s = MemoryKeyValueStore()
     self.assertIsNone(s._cache_element)
     self.assertFalse(s.is_read_only())