]> xenbits.xensource.com Git - xenrt-citrix/xenrt.git/commitdiff
Add unit test for a small part of the VMUser actor class
authorChris Harding <chris.harding@citrix.com>
Wed, 11 Nov 2015 09:33:07 +0000 (09:33 +0000)
committerChris Harding <chris.harding@citrix.com>
Wed, 11 Nov 2015 09:33:07 +0000 (09:33 +0000)
unittests/test_lib/test_dotnetagentlicensing.py [new file with mode: 0644]

diff --git a/unittests/test_lib/test_dotnetagentlicensing.py b/unittests/test_lib/test_dotnetagentlicensing.py
new file mode 100644 (file)
index 0000000..4bcd9b2
--- /dev/null
@@ -0,0 +1,28 @@
+
+import testing
+import xenrt.lib.xenserver.dotnetagentlicensing as dnl
+import mock
+
+
+class TestVMUserActorCheckKeyPresent(testing.XenRTUnitTestCase):
+
+    def __createMockOS(self, regKeyExists, regLookupReturnValue):
+        mockOS = mock.Mock()
+        mockOS.winRegExists = mock.Mock(return_value=regKeyExists)
+        mockOS.winRegLookup = mock.Mock(return_value=regLookupReturnValue)
+        return mockOS
+
+    @mock.patch("xenrt.TEC")
+    def test_checkKeyPresentFound(self, tec):
+        cut = dnl.VMUser(None, self.__createMockOS(True, "Fish fingers are the best"))
+        self.assertTrue(cut.checkKeyPresent(), "key is present")
+
+    @mock.patch("xenrt.TEC")
+    def test_checkKeyPresentNotFound(self, tec):
+        cut = dnl.VMUser(None, self.__createMockOS(False, "Hammer Time"))
+        self.assertFalse(cut.checkKeyPresent(), "key is present")
+
+    @mock.patch("xenrt.TEC")
+    def test_checkKeyPresentButNoValueSet(self, tec):
+        cut = dnl.VMUser(None, self.__createMockOS(True, None))
+        self.assertFalse(cut.checkKeyPresent(), "key is present")