test for nonexistent type

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
Steven Armstrong 2011-10-18 12:43:14 +02:00
parent 16ab494628
commit bd81045caf
1 changed files with 30 additions and 26 deletions

View File

@ -22,7 +22,7 @@
import os
import unittest
import cdist.core
from cdist import core
import os.path as op
my_dir = op.abspath(op.dirname(__file__))
@ -33,113 +33,117 @@ class TypeTestCase(unittest.TestCase):
def test_list_type_names(self):
base_path = op.join(fixtures, 'list_types')
type_names = cdist.core.Type.list_type_names(base_path)
type_names = core.Type.list_type_names(base_path)
self.assertEqual(type_names, ['__first', '__second', '__third'])
def test_list_types(self):
base_path = op.join(fixtures, 'list_types')
types = list(cdist.core.Type.list_types(base_path))
types = list(core.Type.list_types(base_path))
types_expected = [
cdist.core.Type(base_path, '__first'),
cdist.core.Type(base_path, '__second'),
cdist.core.Type(base_path, '__third'),
core.Type(base_path, '__first'),
core.Type(base_path, '__second'),
core.Type(base_path, '__third'),
]
self.assertEqual(types, types_expected)
def test_only_one_instance(self):
base_path = fixtures
cdist_type1 = cdist.core.Type(base_path, '__name_path')
cdist_type2 = cdist.core.Type(base_path, '__name_path')
cdist_type1 = core.Type(base_path, '__name_path')
cdist_type2 = core.Type(base_path, '__name_path')
self.assertEqual(id(cdist_type1), id(cdist_type2))
def test_nonexistent_type(self):
base_path = fixtures
self.assertRaises(core.NoSuchTypeError, core.Type, base_path, '__i-dont-exist')
def test_name(self):
base_path = fixtures
cdist_type = cdist.core.Type(base_path, '__name_path')
cdist_type = core.Type(base_path, '__name_path')
self.assertEqual(cdist_type.name, '__name_path')
def test_path(self):
base_path = fixtures
cdist_type = cdist.core.Type(base_path, '__name_path')
cdist_type = core.Type(base_path, '__name_path')
self.assertEqual(cdist_type.path, '__name_path')
def test_base_path(self):
base_path = fixtures
cdist_type = cdist.core.Type(base_path, '__name_path')
cdist_type = core.Type(base_path, '__name_path')
self.assertEqual(cdist_type.base_path, base_path)
def test_absolute_path(self):
base_path = fixtures
cdist_type = cdist.core.Type(base_path, '__name_path')
cdist_type = core.Type(base_path, '__name_path')
self.assertEqual(cdist_type.absolute_path, os.path.join(base_path, '__name_path'))
def test_manifest_path(self):
base_path = fixtures
cdist_type = cdist.core.Type(base_path, '__name_path')
cdist_type = core.Type(base_path, '__name_path')
self.assertEqual(cdist_type.manifest_path, os.path.join('__name_path', 'manifest'))
def test_explorer_path(self):
base_path = fixtures
cdist_type = cdist.core.Type(base_path, '__name_path')
cdist_type = core.Type(base_path, '__name_path')
self.assertEqual(cdist_type.explorer_path, os.path.join('__name_path', 'explorer'))
def test_gencode_local_path(self):
base_path = fixtures
cdist_type = cdist.core.Type(base_path, '__name_path')
cdist_type = core.Type(base_path, '__name_path')
self.assertEqual(cdist_type.gencode_local_path, os.path.join('__name_path', 'gencode-local'))
def test_gencode_remote_path(self):
base_path = fixtures
cdist_type = cdist.core.Type(base_path, '__name_path')
cdist_type = core.Type(base_path, '__name_path')
self.assertEqual(cdist_type.gencode_remote_path, os.path.join('__name_path', 'gencode-remote'))
def test_singleton_is_singleton(self):
base_path = fixtures
cdist_type = cdist.core.Type(base_path, '__singleton')
cdist_type = 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')
cdist_type = core.Type(base_path, '__not_singleton')
self.assertFalse(cdist_type.is_singleton)
def test_install_is_install(self):
base_path = fixtures
cdist_type = cdist.core.Type(base_path, '__install')
cdist_type = core.Type(base_path, '__install')
self.assertTrue(cdist_type.is_install)
def test_not_install_is_install(self):
base_path = fixtures
cdist_type = cdist.core.Type(base_path, '__not_install')
cdist_type = core.Type(base_path, '__not_install')
self.assertFalse(cdist_type.is_install)
def test_with_explorers(self):
base_path = fixtures
cdist_type = cdist.core.Type(base_path, '__with_explorers')
cdist_type = core.Type(base_path, '__with_explorers')
self.assertEqual(cdist_type.explorers, ['whatever'])
def test_without_explorers(self):
base_path = fixtures
cdist_type = cdist.core.Type(base_path, '__without_explorers')
cdist_type = core.Type(base_path, '__without_explorers')
self.assertEqual(cdist_type.explorers, [])
def test_with_required_parameters(self):
base_path = fixtures
cdist_type = cdist.core.Type(base_path, '__with_required_parameters')
cdist_type = core.Type(base_path, '__with_required_parameters')
self.assertEqual(cdist_type.required_parameters, ['required1', 'required2'])
def test_without_required_parameters(self):
base_path = fixtures
cdist_type = cdist.core.Type(base_path, '__without_required_parameters')
cdist_type = core.Type(base_path, '__without_required_parameters')
self.assertEqual(cdist_type.required_parameters, [])
def test_with_optional_parameters(self):
base_path = fixtures
cdist_type = cdist.core.Type(base_path, '__with_optional_parameters')
cdist_type = core.Type(base_path, '__with_optional_parameters')
self.assertEqual(cdist_type.optional_parameters, ['optional1', 'optional2'])
def test_without_optional_parameters(self):
base_path = fixtures
cdist_type = cdist.core.Type(base_path, '__without_optional_parameters')
cdist_type = core.Type(base_path, '__without_optional_parameters')
self.assertEqual(cdist_type.optional_parameters, [])
'''