test and fixtures for Object class/static methods

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
remotes/origin/feature_files_export
Steven Armstrong 13 years ago
parent e27cd9e809
commit 7c12027311
  1. 61
      lib/cdist/test/object/__init__.py
  2. 0
      lib/cdist/test/object/fixtures/object/__first/.keep
  3. 0
      lib/cdist/test/object/fixtures/object/__first/man/.cdist/.keep
  4. 0
      lib/cdist/test/object/fixtures/object/__second/.keep
  5. 0
      lib/cdist/test/object/fixtures/object/__second/on-the/.cdist/.keep
  6. 0
      lib/cdist/test/object/fixtures/object/__third/.keep
  7. 0
      lib/cdist/test/object/fixtures/object/__third/moon/.cdist/.keep
  8. 0
      lib/cdist/test/object/fixtures/type/__first/.keep
  9. 0
      lib/cdist/test/object/fixtures/type/__second/.keep
  10. 0
      lib/cdist/test/object/fixtures/type/__third/.keep
  11. 46
      lib/cdist/test/test_object.py

@ -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')
object_base_path = op.join(fixtures, 'object')
type_base_path = op.join(fixtures, 'type')
class ObjectClassTestCase(unittest.TestCase):
def test_list_object_names(self):
object_names = list(cdist.core.Object.list_object_names(object_base_path))
self.assertEqual(object_names, ['__first/man', '__second/on-the', '__third/moon'])
def test_list_type_names(self):
type_names = list(cdist.core.Object.list_type_names(object_base_path))
self.assertEqual(type_names, ['__first', '__second', '__third'])
def test_list_objects(self):
objects = list(cdist.core.Object.list_objects(object_base_path, type_base_path))
objects_expected = [
cdist.core.Object(cdist.core.Type(type_base_path, '__first'), object_base_path, 'man'),
cdist.core.Object(cdist.core.Type(type_base_path, '__second'), object_base_path, 'on-the'),
cdist.core.Object(cdist.core.Type(type_base_path, '__third'), object_base_path, 'moon'),
]
self.assertEqual(objects, objects_expected)
'''
suite = unittest.TestLoader().loadTestsFromTestCase(ObjectTestCase)
def suite():
tests = []
return unittest.TestSuite(map(ObjectTestCase, tests))
'''

@ -1,46 +0,0 @@
# -*- 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 os.path as op
my_dir = op.abspath(op.dirname(__file__))
base_path = op.join(my_dir, 'fixtures')
class ObjectTestCase(unittest.TestCase):
def setUp(self):
# FIXME: use defined set of types for testing?
# FIXME: generate object tree or use predefined?
self.object_base_dir = tempfile.mkdtemp()
def tearDown(self):
shutil.rmtree(self.temp_dir)
'''
suite = unittest.TestLoader().loadTestsFromTestCase(ObjectTestCase)
def suite():
tests = []
return unittest.TestSuite(map(ObjectTestCase, tests))
'''
Loading…
Cancel
Save