From c985749e3e380df75c83f0233808c31229bc9162 Mon Sep 17 00:00:00 2001
From: root <r...@vm-058-184.abc.idm.lab.eng.brq.redhat.com>
Date: Fri, 8 Apr 2016 10:04:14 +0200
Subject: [PATCH] Ping module tests.

Test for ping module rewritten using non-declarative way.
No new functionality has been added.
---
 ipatests/test_xmlrpc/test_ping_plugin.py | 49 ++++++++++++++++----------------
 1 file changed, 24 insertions(+), 25 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_ping_plugin.py b/ipatests/test_xmlrpc/test_ping_plugin.py
index afd34fa1482735ac802b57a5d6cd387b18574f89..46cfaceeddf6625f1cea0e36bc4303a54467565e 100644
--- a/ipatests/test_xmlrpc/test_ping_plugin.py
+++ b/ipatests/test_xmlrpc/test_ping_plugin.py
@@ -1,7 +1,8 @@
 # Authors:
 #   Petr Viktorin <pvikt...@redhat.com>
+#   Peter Lacko   <pla...@redhat.com>
 #
-# Copyright (C) 2012  Red Hat
+# Copyright (C) 2016  Red Hat
 # see file 'COPYING' for use and warranty information
 #
 # This program is free software; you can redistribute it and/or modify
@@ -21,34 +22,32 @@
 Test the `ipalib/plugins/ping.py` module, and XML-RPC in general.
 """
 
-from ipalib import errors, _
-from ipatests.util import Fuzzy
-from ipatests.test_xmlrpc.xmlrpc_test import Declarative
 import pytest
 
+from ipalib import errors, _
+from ipatests.test_xmlrpc.tracker.base import Tracker
+from ipatests.util import assert_equal, Fuzzy
+from xmlrpc_test import XMLRPC_test, raises_exact
+
 
 @pytest.mark.tier1
-class test_ping(Declarative):
+class TestPing(XMLRPC_test):
+    """Test functionality of the `ipalib/plugins/ping.py` module."""
+    tracker = Tracker()
 
-    tests = [
-        dict(
-            desc='Ping the server',
-            command=('ping', [], {}),
-            expected=dict(
-                summary=Fuzzy('IPA server version .*. API version .*')),
-        ),
+    def test_ping(self):
+        """Ping the server."""
+        result = self.tracker.run_command('ping')
+        exp = {'summary': Fuzzy('IPA server version .*. API version .*')}
+        assert_equal(result, exp)
 
-        dict(
-            desc='Try to ping with an argument',
-            command=('ping', ['bad_arg'], {}),
-            expected=errors.ZeroArgumentError(name='ping'),
-        ),
+    def test_ping_with_argument(self):
+        """Try to ping with an argument."""
+        with raises_exact(errors.ZeroArgumentError(name='ping')):
+            self.tracker.run_command('ping', ['argument'])
 
-        dict(
-            desc='Try to ping with an option',
-            command=('ping', [], dict(bad_arg=True)),
-            expected=errors.OptionError(_('Unknown option: %(option)s'),
-                option='bad_arg'),
-        ),
-
-    ]
+    def test_ping_with_option(self):
+        """Try to ping with an option."""
+        with raises_exact(errors.OptionError(
+                _('Unknown option: %(option)s'), option='bad_arg')):
+            self.tracker.run_command('ping', bad_arg=True)
-- 
2.5.5

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to