8
by William Grant
A little bit of server. |
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 |
||
21
by William Grant
Merge grackle.server into grackle. Alter Makefile to run all the tests. |
24 |
from grackle.cassandra import workaround_1779 |
25 |
from grackle.model import create_schema |
|
8
by William Grant
A little bit of server. |
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) |