~unity-2d-team/unity-2d/Shell-MultiMonitor

« back to all changes in this revision

Viewing changes to grackle/testing/cassandra.py

  • Committer: Curtis Hovey
  • Date: 2012-01-30 18:31:19 UTC
  • mfrom: (6.2.2 client-get-messages-0)
  • mto: This revision was merged to the branch mainline in revision 45.
  • Revision ID: curtis.hovey@canonical.com-20120130183119-ylmo65mur5ogktud
Merged lint fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (c) 2011 Canonical Ltd
2
 
#
3
 
# This program is free software: you can redistribute it and/or modify
4
 
# it under the terms of the GNU Affero General Public License as published by
5
 
# the Free Software Foundation, either version 3 of the License, or
6
 
# (at your option) any later version.
7
 
#
8
 
# This program is distributed in the hope that it will be useful,
9
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
# GNU Affero General Public License for more details.
12
 
#
13
 
# You should have received a copy of the GNU Affero General Public
14
 
# License along with this program. If not, see
15
 
# <http://www.gnu.org/licenses/>.
16
 
 
17
 
"""Test helpers for working with cassandra."""
18
 
 
19
 
import os.path
20
 
 
21
 
from fixtures import Fixture, TempDir
22
 
from pycassa.system_manager import SystemManager
23
 
 
24
 
from grackle.cassandra import workaround_1779
25
 
from grackle.model import create_schema
26
 
 
27
 
 
28
 
class TemporaryKeyspace(Fixture):
29
 
    """Create a temporary keyspace.
30
 
 
31
 
    The keyspace is named after a tempdir.
32
 
    """
33
 
 
34
 
    def setUp(self):
35
 
        super(TemporaryKeyspace, self).setUp()
36
 
        tempdir = self.useFixture(TempDir())
37
 
        self.keyspace = os.path.basename(tempdir.path)
38
 
        self.mgr = SystemManager()
39
 
        workaround_1779(self.mgr.create_keyspace, self.keyspace,
40
 
            replication_factor=1)
41
 
        self.addCleanup(workaround_1779, self.mgr.drop_keyspace,
42
 
            self.keyspace)
43
 
 
44
 
 
45
 
class TemporaryDB(Fixture):
46
 
    """Create a temporary usable OOPS DB.
47
 
 
48
 
    The keyspace for it is at self.keyspace.
49
 
    """
50
 
 
51
 
    def setUp(self):
52
 
        super(TemporaryDB, self).setUp()
53
 
        self.keyspace = self.useFixture(TemporaryKeyspace()).keyspace
54
 
        create_schema('localhost', self.keyspace)