1
# Copyright 2005-2011 Canonical Ltd. All rights reserved.
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.
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.
13
# You should have received a copy of the GNU Affero General Public License
14
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
from fixtures import TempDir
21
from testtools import TestCase
23
from oopstools.oops.models import Oops
24
from oopstools.scripts import amqp2disk
27
class TestOOPSConfig(TestCase):
29
def test_publishes_disk_and_DB(self):
30
self.root_dir = self.useFixture(TempDir()).path
31
config = amqp2disk.make_amqp_config(self.root_dir)
32
orig_report = {'id': '12345'}
33
report = dict(orig_report)
34
ids = config.publish(report)
35
self.assertEqual(['12345', '12345'], ids)
36
with open(report['datedir_repo_filepath'], 'rb') as fp:
37
disk_report = bson.loads(fp.read())
38
self.assertEqual(disk_report, orig_report)
39
model_report = Oops.objects.get(oopsid='12345')
40
self.assertNotEqual(None, model_report)