blob: 5bfdd9c73a142a010c811da567490c1ddc7bc183 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# -*- coding: UTF-8 -*-
# Copyright 2015 Red Hat, Inc.
# Part of clufter project
# Licensed under GPLv2+ (a copy included | http://gnu.org/licenses/gpl-2.0.txt)
"""Testing format manager"""
__author__ = "Jan Pokorný <jpokorny @at@ Red Hat .dot. com>"
from os.path import join, dirname as d; execfile(join(d(d((__file__))), '_go'))
from unittest import TestCase
from .format_manager import FormatManager
from .formats.ccs import ccs
from .formats.ccs import ccs_flat
from .formats.cib import cib
class FormatManagerTestCase(TestCase):
def setUp(self):
self.fmt_mgr = FormatManager()
def tearDown(self):
self.fmt_mgr.registry.setup(True) # start from scratch
self.fmt_mgr = None
class Default(FormatManagerTestCase):
def test_default(self):
formats = self.fmt_mgr.formats
#print formats
for cls in ccs, ccs_flat, cib:
self.assertTrue(cls.__name__ in formats)
# the first was needed in the past, but now the more restrictive
# one is ok
self.assertEqual(type(cls), type(formats[cls.__name__]))
self.assertEqual(cls, formats[cls.__name__])
class Injection(FormatManagerTestCase):
def setUp(self):
self.formats = {'frobniccs': ccs}
self.fmt_mgr = FormatManager(paths=None, plugins=self.formats)
def test_injection(self):
formats = self.fmt_mgr.formats
#print formats
self.assertTrue(len(formats) == len(self.formats))
for fmt_id, fmt_cls in self.formats.iteritems():
self.assertTrue(fmt_id in formats)
self.assertEqual(fmt_cls, formats[fmt_id])
from os.path import join, dirname as d; execfile(join(d(d(__file__)), '_gone'))
|