URL: https://github.com/freeipa/freeipa/pull/84
Author: stlaz
 Title: #84: Fix update_from_dict function testing
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/84/head:pr84
git checkout pr84
From 45b739afe88f8a482d2e6493cd641f26872d51e5 Mon Sep 17 00:00:00 2001
From: Stanislav Laznicka <slazn...@redhat.com>
Date: Thu, 15 Sep 2016 13:52:35 +0200
Subject: [PATCH] Remove update_from_dict() method

update_from_dict() method is not used anywhere in the project,
it only makes the tests fail. Removed it and its tests.

https://fedorahosted.org/freeipa/ticket/6311
---
 ipaserver/install/ldapupdate.py       | 14 ------
 ipatests/test_install/test_updates.py | 95 -----------------------------------
 2 files changed, 109 deletions(-)

diff --git a/ipaserver/install/ldapupdate.py b/ipaserver/install/ldapupdate.py
index 1b39745..7d87c8b 100644
--- a/ipaserver/install/ldapupdate.py
+++ b/ipaserver/install/ldapupdate.py
@@ -921,20 +921,6 @@ def update(self, files, ordered=True):
 
         return self.modified
 
-    def update_from_dict(self, updates):
-        """
-        Apply updates internally as opposed to from a file.
-        updates is a dictionary containing the updates
-        """
-        self.modified = False
-        try:
-            self.create_connection()
-            self._run_updates(updates)
-        finally:
-            self.close_connection()
-
-        return self.modified
-
     def close_connection(self):
         """Close ldap connection"""
         if self.conn:
diff --git a/ipatests/test_install/test_updates.py b/ipatests/test_install/test_updates.py
index 3fa2cd7..01e06ca 100644
--- a/ipatests/test_install/test_updates.py
+++ b/ipatests/test_install/test_updates.py
@@ -253,98 +253,3 @@ def test_9_badsyntax(self):
         with self.assertRaises(BadSyntax):
             modified = self.updater.update(
                 [os.path.join(self.testdir, "9_badsyntax.update")])
-
-    def test_from_dict(self):
-        """
-        Test updating from a dict.
-
-        This replicates what was done in test 1.
-        """
-
-        # First make sure we're clean
-        with self.assertRaises(errors.NotFound):
-            entries = self.ld.get_entries(
-                self.container_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
-
-        with self.assertRaises(errors.NotFound):
-            entries = self.ld.get_entries(
-                self.user_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
-
-
-        update = {
-            self.container_dn:
-                {'dn': self.container_dn,
-                 'updates': ['add:objectClass: top',
-                             'add:objectClass: nsContainer',
-                             'add:cn: test'
-                            ],
-                },
-            self.user_dn:
-                {'dn': self.user_dn,
-                 'updates': ['add:objectclass: top',
-                             'add:objectclass: person',
-                             'add:objectclass: posixaccount',
-                             'add:objectclass: krbprincipalaux',
-                             'add:objectclass: inetuser',
-                             'add:homedirectory: /home/tuser',
-                             'add:loginshell: /bin/bash',
-                             'add:sn: User',
-                             'add:uid: tuser',
-                             'add:uidnumber: 999',
-                             'add:gidnumber: 999',
-                             'add:cn: Test User',
-                            ],
-                },
-        }
-
-        modified = self.updater.update_from_dict(update)
-        self.assertTrue(modified)
-
-        entries = self.ld.get_entries(
-            self.container_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
-        self.assertEqual(len(entries), 1)
-        entry = entries[0]
-
-        objectclasses = entry.get('objectclass')
-        for item in ('top', 'nsContainer'):
-            self.assertTrue(item in objectclasses)
-
-        self.assertEqual(entry.single_value['cn'], 'test')
-
-        entries = self.ld.get_entries(
-            self.user_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
-        self.assertEqual(len(entries), 1)
-        entry = entries[0]
-
-        objectclasses = entry.get('objectclass')
-        for item in ('top', 'person', 'posixaccount', 'krbprincipalaux', 'inetuser'):
-            self.assertTrue(item in objectclasses)
-
-        self.assertEqual(entry.single_value['loginshell'], paths.BASH)
-        self.assertEqual(entry.single_value['sn'], 'User')
-        self.assertEqual(entry.single_value['uid'], 'tuser')
-        self.assertEqual(entry.single_value['cn'], 'Test User')
-
-        # Now delete
-
-        update = {
-            self.container_dn:
-                {'dn': self.container_dn,
-                 'deleteentry': None,
-                },
-            self.user_dn:
-                {'dn': self.user_dn,
-                 'deleteentry': 'deleteentry: reset: nada',
-                },
-        }
-
-        modified = self.updater.update_from_dict(update)
-        self.assertTrue(modified)
-
-        with self.assertRaises(errors.NotFound):
-            entries = self.ld.get_entries(
-                self.container_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
-
-        with self.assertRaises(errors.NotFound):
-            entries = self.ld.get_entries(
-                self.user_dn, self.ld.SCOPE_BASE, 'objectclass=*', ['*'])
-- 
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