Add test to verify fetching of plugin details,
authorSateesh Kumar <sateeshkumarb@yahoo.com>
Wed, 2 Apr 2014 18:02:08 +0000 (23:32 +0530)
committerSateesh Kumar <sateeshkumarb@yahoo.com>
Wed, 2 Apr 2014 18:02:08 +0000 (23:32 +0530)
doc/source/using_jenkinsapi.rst
jenkinsapi_tests/unittests/test_plugins.py

index 7cedf5b..f1a6c46 100644 (file)
@@ -55,8 +55,26 @@ Example 3: Disable/Enable a Jenkins Job
             
 Use the call ``job_instance.enable()`` to enable a Jenkins Job.
 
+Example 4: Get Plugin details
+-----------------------------
 
-Example 4: Getting version information from a completed build
+Below chunk of code gets the details of the plugins currently installed in the
+Jenkins instance.
+
+::
+
+    def get_plugin_details():
+        # Refer Example #1 for definition of function 'get_server_instance'
+        server = get_server_instance()
+        for plugin in server.get_plugins().values():
+            print "Short Name:%s" %(plugin.shortName)
+            print "Long Name:%s" %(plugin.longName)
+            print "Version:%s" %(plugin.version)
+            print "URL:%s" %(plugin.url)
+            print "Active:%s" %(plugin.active)
+            print "Enabled:%s" %(plugin.enabled)
+    
+Example 5: Getting version information from a completed build
 -------------------------------------------------------------
 
 This is a typical use of JenkinsAPI - it was the very first use I had in mind when the project was first built: In a continuous-integration environment you want to be able to programatically detect the version-control information of the last succsessful build in order to trigger some kind of release process.::
index 62b0e12..93af922 100644 (file)
@@ -153,5 +153,15 @@ class TestPlugins(unittest.TestCase):
         plugin = self.J.get_plugins()['subversion']
         self.assertEquals(p, plugin)
 
+    @mock.patch.object(Plugins, '_poll')
+    def test_get_plugin_details(self, _poll_plugins):
+        _poll_plugins.return_value = self.DATA
+        plugin = self.J.get_plugins()['subversion']
+        self.assertEquals('1.45', plugin.version)
+        self.assertEquals('subversion', plugin.shortName)
+        self.assertEquals('Jenkins Subversion Plug-in', plugin.longName)
+        self.assertEquals('http://wiki.jenkins-ci.org/display/JENKINS/Subversion+Plugin',
+                           plugin.url)
+
 if __name__ == '__main__':
     unittest.main()