From 29da07cda8e456a7ffa678c1b28ae3f1a800a116 Mon Sep 17 00:00:00 2001 From: Timur Nurlygayanov Date: Tue, 26 Mar 2013 06:36:57 +0700 Subject: [PATCH] Added initial unit tests for RestAPI service. --- portas/portas/tests/sanity_tests.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 portas/portas/tests/sanity_tests.py diff --git a/portas/portas/tests/sanity_tests.py b/portas/portas/tests/sanity_tests.py new file mode 100644 index 0000000..d6258f2 --- /dev/null +++ b/portas/portas/tests/sanity_tests.py @@ -0,0 +1,24 @@ +import unittest2 +from mock import MagicMock + +import portas.api.v1.router as router + +def my_mock(link, controller, action, conditions): + return [link, controller, action, conditions] + +def func_mock(): + return True + +class SanityUnitTests(unittest2.TestCase): + + def test_api(self): + router.webservers = MagicMock(create_resource=func_mock) + router.sessions = MagicMock(create_resource=func_mock) + router.active_directories = MagicMock(create_resource=func_mock) + router.environments = MagicMock(create_resource=func_mock) + mapper = MagicMock(connect=my_mock) + + object = router.API(mapper) + + assert object._router is not None + \ No newline at end of file