Skip to content
Snippets Groups Projects

Add more tests of hierarchical_access to OUs

Merged Andreas Ellewsen requested to merge GREG-210-test-hierarchical-access into master
2 files
+ 51
0
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -71,3 +71,19 @@ def test_get_allowed_loop(loop_sponsor, looped_units, unit_foo):
units = loop_sponsor.get_allowed_units()
expected = [i.id for i in looped_units] + [unit_foo.id]
assert [x.id for x in units] == expected
@pytest.mark.django_db
def test_get_allowed(sponsor_foo, unit1, unit2):
"""Verify that hierarchical_access controls access to allowed units"""
spu = sponsor_ou_relation(sponsor=sponsor_foo, organizational_unit=unit1)
unit2.parent = unit1
unit2.save()
# Without hier access only get unit connected to
assert sponsor_foo.get_allowed_units() == {unit1}
# With hier access also get units below
spu.hierarchical_access = True
spu.save()
assert sponsor_foo.get_allowed_units() == {unit1, unit2}
Loading