Commit 769cc8c9 authored by Enrico Zini's avatar Enrico Zini
Browse files

Fixed the remaining tests. refs: #5

parent dae96feb
...@@ -44,12 +44,10 @@ class TestCheckLDAPConsistency(ProcessFixtureMixin, TestCase): ...@@ -44,12 +44,10 @@ class TestCheckLDAPConsistency(ProcessFixtureMixin, TestCase):
res = list(Inconsistency.objects.all()) res = list(Inconsistency.objects.all())
self.assertEqual(len(res), len(items)) self.assertEqual(len(res), len(items))
for inc, item in zip(res, items): for inc, item in zip(res, items):
person = item.get("person") if "person" in item:
if person is not None: self.assertEqual(inc.person, item["person"])
self.assertEqual(inc.person, person) if "text" in item:
text = item.get("text") self.assertEqual(inc.text, item["text"])
if text is not None:
self.assertEqual(inc.text, text)
def test_new_removed(self): def test_new_removed(self):
with mock.patch("dsa.udldap.list_people") as m: with mock.patch("dsa.udldap.list_people") as m:
...@@ -57,10 +55,11 @@ class TestCheckLDAPConsistency(ProcessFixtureMixin, TestCase): ...@@ -57,10 +55,11 @@ class TestCheckLDAPConsistency(ProcessFixtureMixin, TestCase):
MockEntry("newdd", supplementaryGid=["Debian"], cn="tcn", MockEntry("newdd", supplementaryGid=["Debian"], cn="tcn",
mn="tmn", sn="tsn", emailForward="test@example.org", accountStatus=None) mn="tmn", sn="tsn", emailForward="test@example.org", accountStatus=None)
] ]
self.hk.run(CheckLDAPConsistency) with self.assertLogs() as log:
self.assertInconsistenciesEqual([ self.hk.run(CheckLDAPConsistency)
{"person": self.persons.newdd, self.assertEqual(log.output, [
"text": "newdd: created to mirror a removed DD account from LDAP"}, "WARNING:dsa.housekeeping:test.CheckLDAPConsistency:"
" newdd: created to mirror a removed DD account from LDAP",
]) ])
p = Person.objects.get(ldap_fields__uid="newdd") p = Person.objects.get(ldap_fields__uid="newdd")
...@@ -85,7 +84,8 @@ class TestCheckLDAPConsistency(ProcessFixtureMixin, TestCase): ...@@ -85,7 +84,8 @@ class TestCheckLDAPConsistency(ProcessFixtureMixin, TestCase):
with self.assertLogs() as log: with self.assertLogs() as log:
self.hk.run(CheckLDAPConsistency) self.hk.run(CheckLDAPConsistency)
self.assertEqual(log.output, [ self.assertEqual(log.output, [
"WARNING:dsa.housekeeping:test.CheckLDAPConsistency: newguest: created to mirror a removed guest account from LDAP"]) "WARNING:dsa.housekeeping:test.CheckLDAPConsistency:"
" newguest: created to mirror a removed guest account from LDAP"])
p = Person.objects.get(ldap_fields__uid="newguest") p = Person.objects.get(ldap_fields__uid="newguest")
audit = ["{}:{}".format(l.author.lookup_key, l.notes) for l in p.audit_log.all()] audit = ["{}:{}".format(l.author.lookup_key, l.notes) for l in p.audit_log.all()]
...@@ -109,8 +109,8 @@ class TestCheckLDAPConsistency(ProcessFixtureMixin, TestCase): ...@@ -109,8 +109,8 @@ class TestCheckLDAPConsistency(ProcessFixtureMixin, TestCase):
] ]
self.hk.run(CheckLDAPConsistency) self.hk.run(CheckLDAPConsistency)
self.assertInconsistenciesEqual([ self.assertInconsistenciesEqual([
{"person": self.persons.newdd, {"person": None,
"text": "person has fingerprint 66B4DFB68CB24EBBD8650BC4F4B4B0CC797EBFAB and gid 800 in LDAP," "text": "newdd has fingerprint 66B4DFB68CB24EBBD8650BC4F4B4B0CC797EBFAB and gid 800 in LDAP,"
" but is not in our db"}, " but is not in our db"},
]) ])
...@@ -250,11 +250,14 @@ class TestCheckLDAPConsistency(ProcessFixtureMixin, TestCase): ...@@ -250,11 +250,14 @@ class TestCheckLDAPConsistency(ProcessFixtureMixin, TestCase):
with self.assertLogs() as log: with self.assertLogs() as log:
self.hk.run(CheckLDAPConsistency) self.hk.run(CheckLDAPConsistency)
self.assertEqual(log.output, [ self.assertEqual(log.output, [
"WARNING:dsa.housekeeping:None: dd_u has accountStatus 'retiring 2018-03-20' " "INFO:dsa.housekeeping:test.CheckLDAPConsistency: dd_u changing email_ldap"
'(comment: None) but in our db the state is Debian Developer, uploading ' " from dd_u@example.org to test@example.org (source: LDAP)",
'[retiring]', ])
"INFO:dsa.housekeeping:None: dd_u changing email_ldap from dd_u@example.org to test@example.org" self.assertInconsistenciesEqual([
" (source: LDAP)", {"person": self.persons.dd_u,
"text": "person has accountStatus 'retiring 2018-03-20' "
'(comment: None) but in our db the state is Debian Developer, uploading '
'[retiring]'},
]) ])
process.approved_by = self.persons.dam process.approved_by = self.persons.dam
...@@ -263,7 +266,7 @@ class TestCheckLDAPConsistency(ProcessFixtureMixin, TestCase): ...@@ -263,7 +266,7 @@ class TestCheckLDAPConsistency(ProcessFixtureMixin, TestCase):
with self.assertLogs() as log: with self.assertLogs() as log:
self.hk.run(CheckLDAPConsistency) self.hk.run(CheckLDAPConsistency)
self.assertEqual(log.output, [ self.assertEqual(log.output, [
"INFO:dsa.housekeeping:None: dd_u closed from dsa: retiring 2018-03-20", "INFO:dsa.housekeeping:test.CheckLDAPConsistency: dd_u closed from dsa: retiring 2018-03-20",
]) ])
p = self.persons.dd_u p = self.persons.dd_u
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment