You can now add and remove users for ownership history

This commit is contained in:
Dion Moult
2021-10-01 17:32:58 +10:00
parent fe1e30702a
commit 4697e063af
23 changed files with 336 additions and 27 deletions
+7
View File
@@ -70,6 +70,13 @@ def context_editor():
prophet.verify()
@pytest.fixture
def owner():
prophet = Prophecy(blenderbim.core.tool.Owner)
yield prophet
prophet.verify()
class Prophecy:
def __init__(self, cls):
self.subject = cls
+39 -1
View File
@@ -18,7 +18,7 @@
import blenderbim.core.owner as subject
from test.core.bootstrap import ifc, blender, person_editor, role_editor, address_editor, organisation_editor
from test.core.bootstrap import ifc, blender, person_editor, role_editor, address_editor, organisation_editor, owner
class TestAddPerson:
@@ -181,3 +181,41 @@ class TestEditOrganisation:
ifc.run("owner.edit_organisation", organisation="organisation", attributes="attributes").should_be_called()
organisation_editor.clear_organisation().should_be_called()
subject.edit_organisation(ifc, organisation_editor)
class TestAddPersonAndOrganisation:
def test_run(self, ifc):
ifc.run(
"owner.add_person_and_organisation", person="person", organisation="organisation"
).should_be_called().will_return("person_and_organisation")
assert (
subject.add_person_and_organisation(ifc, person="person", organisation="organisation")
== "person_and_organisation"
)
class TestRemovePersonAndOrganisation:
def test_run(self, ifc, owner):
owner.get_user().should_be_called().will_return("user")
ifc.run(
"owner.remove_person_and_organisation", person_and_organisation="person_and_organisation"
).should_be_called()
subject.remove_person_and_organisation(ifc, owner, person_and_organisation="person_and_organisation")
def test_clearing_the_active_user_if_you_remove_it(self, ifc, owner):
owner.get_user().should_be_called().will_return("user")
owner.clear_user().should_be_called()
ifc.run("owner.remove_person_and_organisation", person_and_organisation="user").should_be_called()
subject.remove_person_and_organisation(ifc, owner, person_and_organisation="user")
class TestSetUser:
def test_run(self, owner):
owner.set_user("person_and_organisation").should_be_called()
subject.set_user(owner, user="person_and_organisation")
class TestGetUser:
def test_run(self, owner):
owner.get_user().should_be_called().will_return("person_and_organisation")
assert subject.get_user(owner) == "person_and_organisation"