~launchpad-pqm/python-oops-tools/trunk

« back to all changes in this revision

Viewing changes to src/oopstools/oops/test/test_amqp2disk.py

  • Committer: Robert Collins
  • Date: 2011-10-16 22:35:01 UTC
  • mto: This revision was merged to the branch mainline in revision 2.
  • Revision ID: robertc@robertcollins.net-20111016223501-jl5vg9mduh7n29df
Add an amqpd listener, tweak some docs to match reality.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2005-2011 Canonical Ltd.  All rights reserved.
 
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 License
 
14
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 
 
16
 
 
17
import os.path
 
18
 
 
19
import bson
 
20
from fixtures import TempDir
 
21
from testtools import TestCase
 
22
 
 
23
from oopstools.oops.models import Oops
 
24
from oopstools.scripts import amqp2disk
 
25
 
 
26
 
 
27
class TestOOPSConfig(TestCase):
 
28
 
 
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)