Merge branch 'master' of git://github.com/asteven/cdist

This commit is contained in:
Nico Schottelius 2011-10-07 18:18:21 +02:00
commit 1cb86cb66b
5 changed files with 62 additions and 1 deletions

View file

@ -52,7 +52,7 @@ class Type(object):
# name is second argument
name = args[1]
if not name in cls._instances:
instance = super(Type, cls).__new__(cls, *args, **kwargs)
instance = super(Type, cls).__new__(cls)
cls._instances[name] = instance
return cls._instances[name]

View file

View file

@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
#
# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc)
#
# This file is part of cdist.
#
# cdist is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cdist is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
#
import os
import tempfile
import unittest
import shutil
import cdist.core
import os.path as op
my_dir = op.abspath(op.dirname(__file__))
fixtures = op.join(my_dir, 'fixtures')
class TypeTestCase(unittest.TestCase):
def setUp(self):
# FIXME: use defined set of types for testing?
# FIXME: generate object tree or use predefined?
self.temp_dir = tempfile.mkdtemp()
self.object_base_path = op.join(self.temp_dir, '')
def tearDown(self):
shutil.rmtree(self.temp_dir)
def test_singleton_is_singleton(self):
base_path = fixtures
cdist_type = cdist.core.Type(base_path, '__singleton')
self.assertTrue(cdist_type.is_singleton)
def test_not_singleton_is_singleton(self):
base_path = fixtures
cdist_type = cdist.core.Type(base_path, '__not_singleton')
self.assertFalse(cdist_type.is_singleton)
'''
suite = unittest.TestLoader().loadTestsFromTestCase(ObjectTestCase)
def suite():
tests = []
return unittest.TestSuite(map(ObjectTestCase, tests))
'''