Page MenuHomeDevCentral

test_forest.py
No OneTemporary

test_forest.py

import imp
import unittest
salt_test_case = imp.load_source('salt_test_case', "salt_test_case.py")
forest = imp.load_source('forest', "../_modules/forest.py")
class Testinstance(unittest.TestCase, salt_test_case.SaltTestCase):
def setUp(self):
self.initialize_mocks()
self.instance = forest
self.mock_pillar('data/forests.yaml')
self.mock_grains()
self.grains['id'] = 'egladil'
def test_exists(self):
self.assertTrue(forest.exists('lothlorien'))
self.assertFalse(forest.exists('notexisting'))
def test_get(self):
self.assertEqual("lothlorien", forest.get())
def test_get_when_key_not_exists(self):
self.grains['id'] = 'notexisting'
self.assertRaises(KeyError, forest.get)
def test_list_groups(self):
self.assertEqual(['caras_galadhon', 'ubiquity'],
sorted(forest.list_groups()))
def test_list_groups_when_there_are_none_for_the_foreest(self):
self.grains['id'] = 'entwash'
self.assertEqual(['ubiquity'], forest.list_groups())
def test_get_groups(self):
self.assertEqual(['caras_galadhon', 'ubiquity'],
sorted(forest.get_groups().keys()))
def test_list_users(self):
self.assertEqual(['amdir', 'amroth'],
sorted(forest.list_users()))
def test_get_users(self):
self.assertEqual(['amdir', 'amroth'],
sorted(forest.get_users().keys()))
if __name__ == '__main__':
unittest.main()

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 26, 01:36 (5 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2283992
Default Alt Text
test_forest.py (1 KB)

Event Timeline