def apply_proposal(self, test_data, selenium): """Apply proposal.""" if test_data["proposal_to_apply"].status == object_states.PROPOSED: users.set_current_user(test_data["risk_creator"]) proposal_ui_facade.apply_proposal( selenium, test_data["risk"], test_data["proposal_to_apply"], [test_data["proposal_from_gr"], test_data["proposal_to_decline"]])
def test_permissions( self, users_with_all_roles, login_role, can_view, can_edit, selenium ): # pylint: disable=too-many-arguments """Test that users have permissions to objects created by other users according to their global role. """ objs = [] other_roles = [role for role in self.ALL_ROLES if role != login_role] for role in other_roles: users.set_current_user(users_with_all_roles[role]) program = rest_facade.create_program() control = rest_facade.create_control_mapped_to_program(program) objs.extend([program, control]) users.set_current_user(users_with_all_roles[login_role]) for obj in objs: if can_view: webui_facade.assert_can_view(selenium, obj) if obj.type == "Control": webui_facade.assert_can_edit_control(selenium, obj, can_edit) webui_facade.assert_cannot_delete_control(selenium, obj) else: webui_facade.assert_can_edit(selenium, obj, can_edit=can_edit) webui_facade.assert_can_delete(selenium, obj, can_delete=can_edit) else: webui_facade.assert_cannot_view(obj)
def test_obj_mark_reviewed(self, reviewer, program_with_review, selenium): """Confirm Reviewer with READ rights for an object able to Review an object.""" users.set_current_user(reviewer) webui_facade.approve_obj_review(selenium, program_with_review) actual_program = webui_facade.get_object(selenium, program_with_review) self.general_equal_assert(program_with_review.repr_ui(), actual_program)
def test_check_proposals_comparison_window( self, test_data, selenium ): """Check if proposal comparison window has correct info.""" users.set_current_user(test_data["risk_creator"]) proposal_ui_facade.assert_proposal_comparison_window_has_correct_info( selenium, test_data["risk"], test_data["proposal_to_apply"])
def test_add_evidence_url( self, program, login_role, obj, obj_role, selenium ): """Test that various users have possibility to add an evidence url into assessment. """ # pylint: disable=too-many-arguments login_user = rest_facade.create_user_with_role(login_role) obj_args = {obj_role: [login_user]} audit = rest_facade.create_audit( program, **obj_args if obj == "audit" else {}) asmt = rest_facade.create_asmt( audit, **obj_args if obj == "assessment" else {}) users.set_current_user(login_user) url = string_utils.StringMethods.random_string() asmt_service = webui_service.AssessmentsService(selenium) asmt_service.add_evidence_urls(asmt, [url]) actual_asmt = asmt_service.get_obj_from_info_page(obj=asmt) rest_asmt_obj = rest_facade.get_obj(asmt) asmt.update_attrs( updated_at=rest_asmt_obj.updated_at, modified_by=rest_asmt_obj.modified_by, status=object_states.IN_PROGRESS, evidence_urls=[url]).repr_ui() self.general_equal_assert(asmt, actual_asmt, "audit")
def test_check_proposals_email_connects_to_correct_obj( self, test_data, proposal, proposal_author, selenium ): """Check if proposal notification email connects to the correct obj.""" users.set_current_user(users.FAKE_SUPER_USER) proposal_ui_facade.assert_proposal_notification_connects_to_obj( selenium, test_data["risk"], test_data[proposal], test_data[proposal_author])
def test_check_proposals_declining( self, login_user, test_data, decline_proposal, selenium ): """Check if a proposal is declined.""" users.set_current_user(test_data[login_user]) actual_proposals = proposal_ui_facade.get_related_proposals( selenium, test_data["risk"]) assert test_data["proposal_to_decline"] in actual_proposals
def test_check_proposals_apply_btn_after_declining( self, test_data, decline_proposal, selenium ): """Check an applied proposal apply button does not exist.""" users.set_current_user(test_data["risk_creator"]) proposal_ui_facade.assert_proposal_apply_btns_exist( selenium, test_data["risk"], [test_data["proposal_to_decline"]], True)
def set_superuser_as_current_user(self): """Class fixtures are evaluated before function fixtures. This fixture is used by class `test_data` fixture so this one should be class as well. Code is copied from conftest.py. """ # pylint: disable=protected-access users._current_user = users.FakeSuperUser() users.set_current_user(entities_factory.PeopleFactory.superuser)
def test_auditor_cannot_view_control( self, selenium, test_data ): """Test that Auditor cannot view control""" # pylint: disable=invalid-name creator = test_data["creator"] users.set_current_user(creator) control = test_data["control"] webui_facade.assert_cannot_view(selenium, control)
def test_auditor_cannot_edit_audit( self, selenium, test_data ): """Test that Auditor cannot edit audit""" creator = test_data["creator"] users.set_current_user(creator) audit = test_data["audit"] webui_facade.assert_can_view(selenium, audit) webui_facade.assert_can_edit(selenium, audit, can_edit=False)
def test_object_creation(self, role, selenium): """Test that users with all global roles can create, then edit and delete objects. """ user = rest_facade.create_user_with_role(role_name=role) users.set_current_user(user) objs = [rest_facade.create_program(), rest_facade.create_control()] for obj in objs: webui_facade.assert_can_edit(selenium, obj, can_edit=True) webui_facade.assert_can_delete(selenium, obj, can_delete=True)
def test_check_proposals( self, login_user, test_data, selenium ): """Check proposal is created on Change Proposal tab.""" users.set_current_user(test_data[login_user]) exp_proposals = [ test_data["proposal_from_gr"], test_data["proposal_to_decline"], test_data["proposal_to_apply"]] actual_proposals = proposal_ui_facade.get_related_proposals( selenium, test_data["risk"]) self.check_ggrc_6591(login_user, actual_proposals == exp_proposals) assert exp_proposals == actual_proposals
def test_auditor_can_create_asmt( self, selenium, test_data ): """Preconditions: Global editor creates program with mapped control. Global editor creates audit and assigns Global Creator user as an auditor - log in as GC - navigate to audit page => Assessments tab Test that GC can create new asmt in audit.""" creator = test_data["creator"] users.set_current_user(creator) audit = test_data["audit"] expected_asmt = webui_facade.create_asmt(selenium, audit) webui_facade.assert_can_view(selenium, expected_asmt)
def test_check_proposals_apply_btn( self, login_user, apply_btns_exist, test_data, selenium ): """Check proposal apply buttons exist for proposal recipient and do not exist for proposal creators.""" users.set_current_user(test_data[login_user]) exp_proposals = [ test_data["proposal_from_gr"], test_data["proposal_to_decline"], test_data["proposal_to_apply"]] actual_proposals = proposal_ui_facade.get_related_proposals( selenium, test_data["risk"]) self.check_ggrc_6591(login_user, actual_proposals == exp_proposals) proposal_ui_facade.assert_proposal_apply_btns_exist( selenium, test_data["risk"], exp_proposals, apply_btns_exist)
def test_add_person_to_acl_list(self, program, audit, selenium): """Test that an assessment assignee can add a person to ACL""" assignee = rest_facade.create_user_with_role(roles.CREATOR) primary_contact = rest_facade.create_user_with_role(roles.CREATOR) asmt = rest_facade.create_assessment(audit, assignees=[assignee]) users.set_current_user(assignee) asmt_service = webui_service.AssessmentsService(selenium) asmt_service.add_primary_contact(asmt, primary_contact) selenium.refresh() actual_asmt = asmt_service.get_obj_from_info_page(asmt) asmt.update_attrs( updated_at=rest_facade.get_obj(asmt).updated_at, primary_contacts=[primary_contact], modified_by=assignee).repr_ui() self.general_equal_assert(asmt, actual_asmt, "audit")
def test_view_evidence_urls_as_verifier(self, program, audit, selenium): """Test that an assessment verifier can see evidence urls on assessment page """ verifier = rest_facade.create_user_with_role(roles.CREATOR) asmt = rest_facade.create_assessment(audit, verifiers=[verifier]) asmt_service = webui_service.AssessmentsService(selenium) url = string_utils.StringMethods.random_string() asmt_service.add_evidence_urls(asmt, [url]) users.set_current_user(verifier) actual_asmt = asmt_service.get_obj_from_info_page(asmt) asmt.update_attrs( status=object_states.IN_PROGRESS, updated_at=rest_facade.get_obj(asmt).updated_at, evidence_urls=[url]).repr_ui() self.general_equal_assert(asmt, actual_asmt, "audit")
def test_change_asmt_state_as_verifier( self, program, audit, initial_state, action, end_state, selenium ): """Tests for changing assessment state as assessment verifier""" verifier = rest_facade.create_user_with_role(roles.CREATOR) asmt = rest_facade.create_assessment( audit, status=initial_state, verifiers=[verifier]) users.set_current_user(verifier) asmt_service = webui_service.AssessmentsService(selenium) getattr(asmt_service, action)(asmt) actual_asmt = asmt_service.get_obj_from_info_page(asmt) asmt.update_attrs( updated_at=rest_facade.get_obj(asmt).updated_at, status=end_state, verified=(True if action == "verify_assessment" else False)).repr_ui() self.general_equal_assert(asmt, actual_asmt, "audit")
def test_data(self): """Objects structure: Program -> Control -> Audit (Auditor is a user with global creator role) """ editor = rest_facade.create_user_with_role(roles.EDITOR) creator = rest_facade.create_user_with_role(roles.CREATOR) users.set_current_user(editor) program = rest_facade.create_program() control = rest_facade.create_control(program=program) audit = rest_facade.create_audit(program, auditors=[creator]) return { "editor": editor, "creator": creator, "program": program, "audit": audit, "control": control }
def test_auditor_can_assign_user_to_asmt( self, selenium, test_data ): """Preconditions: Global editor creates program with mapped control. Global editor creates audit and assigns Global Creator user as an auditor - log in as GC - navigate to audit page => Assessments tab Test that GC can assign user to new asmt in audit.""" # pylint: disable=invalid-name creator = test_data["creator"] users.set_current_user(creator) audit = test_data["audit"] expected_asmt = rest_facade.create_assessment(audit) asmt_service = webui_service.AssessmentsService(selenium) asmt_service.add_asignee(expected_asmt, test_data["editor"]) expected_asmt.update_attrs( updated_at=rest_facade.get_obj(expected_asmt).updated_at, assignees=[creator.email, test_data["editor"].email], modified_by=users.current_user().email) webui_facade.assert_can_view(selenium, expected_asmt)
def test_data(self, risk_reader_role, selenium): """Create 2 GC users. GC 1 creates risk and adds GC 2 as a risk reader. """ if not self.__class__._data: risk_creator = rest_facade.create_user_with_role(roles.CREATOR) proposal_creator = rest_facade.create_user_with_role(roles.CREATOR) global_reader = rest_facade.create_user_with_role(roles.READER) users.set_current_user(risk_creator) risk_custom_roles = [ (risk_reader_role.name, risk_reader_role.id, [proposal_creator])] risk = rest_facade.create_risk( custom_roles=risk_custom_roles) users.set_current_user(proposal_creator) proposal_to_apply = proposal_ui_facade.create_proposal(selenium, risk) proposal_to_apply.datetime = ( proposal_rest_service.ProposalsService().get_proposal_creation_date( risk, proposal_to_apply)) proposal_to_decline = proposal_ui_facade.create_proposal( selenium, risk) proposal_to_decline.datetime = ( proposal_rest_service.ProposalsService().get_proposal_creation_date( risk, proposal_to_decline)) users.set_current_user(global_reader) proposal_from_gr = proposal_ui_facade.create_proposal(selenium, risk) proposal_from_gr.datetime = ( proposal_rest_service.ProposalsService().get_proposal_creation_date( risk, proposal_from_gr)) self.__class__._data = {"risk_creator": risk_creator, "proposal_creator": proposal_creator, "global_reader": global_reader, "risk": risk, "proposal_to_apply": proposal_to_apply, "proposal_to_decline": proposal_to_decline, "proposal_from_gr": proposal_from_gr} return self.__class__._data
def decline_proposal(self, test_data, selenium): """Decline proposal.""" if test_data["proposal_to_decline"].status == object_states.PROPOSED: users.set_current_user(test_data["risk_creator"]) proposal_ui_facade.decline_proposal( selenium, test_data["risk"], test_data["proposal_to_decline"])
def chrome_options(chrome_options, pytestconfig): """Set configuration to run Chrome with specific options.""" if selenium_utils.is_headless_chrome(pytestconfig): chrome_options.set_headless(True) chrome_options.add_argument("window-size={},{}".format( os.environ["SCREEN_WIDTH"], os.environ["SCREEN_HEIGHT"])) return chrome_options # `PeopleFactory.superuser` uses `environment.app_url` and `current user`. # It is used in @pytest.mark.parametrize parameters. # Parametrize parameters are evaluated before fixtures so # `environment.app_url` and `current user` should be already set. environment.app_url = os.environ["DEV_URL"] environment.app_url = urlparse.urljoin(environment.app_url, "/") users.set_current_user(users.FakeSuperUser()) @pytest.fixture(autouse=True) def set_superuser_as_current_user(): """Set super user as a current user""" # pylint: disable=protected-access users._current_user = users.FakeSuperUser() users.set_current_user(entities_factory.PeopleFactory.superuser) @pytest.fixture(autouse=True) def reset_logged_in_users(): """Reset cache of logged in users. This cache is used to check if user has already logged in. """
def ge_user(self): """Create GE user and set him as current.""" user = rest_facade.create_user_with_role(roles.EDITOR) users.set_current_user(user) return user
def set_superuser_as_current_user(): """Set super user as a current user""" # pylint: disable=protected-access users._current_user = users.FakeSuperUser() users.set_current_user(entities_factory.PeopleFactory.superuser)
def tested_events(self, selenium): """Create events to verify events functionality: 0. Save event log count before test data creation, 1. Create objective editor role, create 2 users with global creator role under admin 2. Create objective#1 under global creator#1 and set global creator#2 to newly created objective editor role 3. Create objective#2 under global objective#2 and map it objective#1 """ if not self.__class__._data: # generate enough data, so test can be executed independently for _ in xrange(6): rest_facade.create_user_with_role(roles.READER) initial_count = self.get_event_tab().tab_events.count objctv1_creator = rest_facade.create_user_with_role(roles.CREATOR) objctv2_creator = rest_facade.create_user_with_role(roles.CREATOR) objctv_editor_role = rest_facade.create_access_control_role( object_type="Objective", read=True, update=True, delete=True) admin = users.current_user() users.set_current_user(objctv1_creator) objctv_custom_roles = [(objctv_editor_role.name, objctv_editor_role.id, [objctv2_creator])] objctv1 = rest_facade.create_objective( custom_roles=objctv_custom_roles) # wait until notification and acl will assigned by background task rest_facade.get_obj(objctv1_creator) users.set_current_user(objctv2_creator) objctv2 = rest_facade.create_objective() rest_facade.map_objs(objctv1, objctv2) users.set_current_user(admin) # generate expected event data from lib.constants.roles import ACLRolesIDs # 3 predefined program roles and 1 predefined reviewer role acl_roles_len = len(ACLRolesIDs.object_roles(objctv1.type)) - 4 exp_event_data = [{ "actions": sorted([ objctv1_creator.email + " created", u"PersonProfile created" ]), "user_email": admin.email, "time": date_utils.iso8601_to_local_datetime( objctv1_creator.updated_at) }, { "actions": ["Creator linked to " + objctv1_creator.email], "user_email": admin.email, "time": date_utils.iso8601_to_local_datetime( objctv1_creator.updated_at) }, { "actions": sorted([ objctv2_creator.email + " created", u"PersonProfile created" ]), "user_email": admin.email, "time": date_utils.iso8601_to_local_datetime( objctv2_creator.updated_at) }, { "actions": ["Creator linked to " + objctv2_creator.email], "user_email": admin.email, "time": date_utils.iso8601_to_local_datetime( objctv2_creator.updated_at) }, { "actions": [objctv_editor_role.name + " created"], "user_email": admin.email, "time": date_utils.iso8601_to_local_datetime( objctv_editor_role.updated_at) }, { "actions": [u"AccessControlList created"] * acl_roles_len + [u"AccessControlPerson created"] * 2 + [objctv1.title + " created"], "user_email": objctv1_creator.email, "time": date_utils.iso8601_to_local_datetime(objctv1.updated_at) }, { "actions": [u"AccessControlList created"] * acl_roles_len + [u"AccessControlPerson created", objctv2.title + " created"], "user_email": objctv2_creator.email, "time": date_utils.iso8601_to_local_datetime(objctv2.updated_at) }, { "actions": [ u"{type2}:{id2} linked to {type1}:{id1}".format( id1=objctv1.id, id2=objctv2.id, type1=objctv1.type, type2=objctv2.type) ], "user_email": objctv2_creator.email, "time": date_utils.iso8601_to_local_datetime(objctv2.updated_at) }] exp_event_data.reverse() self.__class__._data = { "objctv1_creator": objctv1_creator, "objctv2_creator": objctv2_creator, "objctv_editor_role": objctv_editor_role, "objctv1": objctv1, "objctv2": objctv2, "exp_added_events": exp_event_data, "initial_count": initial_count } return self.__class__._data
def set_external_user_as_current_user(): """Set super user as a current user""" # pylint: disable=protected-access users._current_user = users.EXTERNAL_APP_USER users.set_current_user(entities_factory.PeopleFactory.external_app_user)
def test_auditor_cannot_view_control(self, selenium, test_data): """Test that Auditor cannot view control""" creator = test_data["creator"] users.set_current_user(creator) control = test_data["control"] webui_facade.assert_cannot_view(selenium, control)
def login_as_creator(creator): """Login by user with role 'Creator'.""" users.set_current_user(creator)
def program_w_approved_via_ui_review(self, reviewer, program_with_review, selenium): """Approve program review via UI. Returns program instance with approved review.""" users.set_current_user(reviewer) return webui_facade.approve_obj_review(selenium, program_with_review)
def test_check_proposals_comparison_window(self, test_data, selenium): """Check if proposal comparison window has correct info.""" users.set_current_user(test_data["control_creator"]) proposal_ui_facade.assert_proposal_comparison_window_has_correct_info( selenium, test_data["control"], test_data["proposal_to_apply"])
def set_superuser_as_current_user(): """Set super user as a current user""" # pylint: disable=protected-access users._current_user = users.FAKE_SUPER_USER users.set_current_user(entities_factory.PeopleFactory.superuser)
def chrome_options(chrome_options, pytestconfig): """Set configuration to run Chrome with specific options.""" if selenium_utils.is_headless_chrome(pytestconfig): chrome_options.set_headless(True) chrome_options.add_argument("window-size={},{}".format( os.environ["SCREEN_WIDTH"], os.environ["SCREEN_HEIGHT"])) return chrome_options # `PeopleFactory.superuser` uses `environment.app_url` and `current user`. # It is used in @pytest.mark.parametrize parameters. # Parametrize parameters are evaluated before fixtures so # `environment.app_url` and `current user` should be already set. environment.app_url = os.environ["DEV_URL"] environment.app_url = urlparse.urljoin(environment.app_url, "/") users.set_current_user(users.FAKE_SUPER_USER) @pytest.fixture(autouse=True) def set_superuser_as_current_user(): """Set super user as a current user""" # pylint: disable=protected-access users._current_user = users.FAKE_SUPER_USER users.set_current_user(entities_factory.PeopleFactory.superuser) @pytest.fixture(autouse=True) def reset_state(request): """Reset caches of logged in users and requests sessions. Cache with logged in users is used to check if user has already logged in. Cache with sessions is used to reuse REST sessions between requests.
def tested_events(self, selenium): """Create events to verify events functionality: 0. Save event log count before test data creation, 1. Create control editor role, create 2 users with global creator role under admin 2. Create control#1 under global creator#1 and set global creator#2 to newly created control editor role 3. Create control#2 under global creator#2 and map it control#1 """ if not self.__class__._data: # generate enough data, so test can be executed independently for _ in xrange(6): rest_facade.create_user_with_role(roles.READER) initial_count = self.get_event_tab().tab_events.count ctrl1_creator = rest_facade.create_user_with_role(roles.CREATOR) ctrl2_creator = rest_facade.create_user_with_role(roles.CREATOR) ctrl_editor_role = rest_facade.create_access_control_role( object_type="Control", read=True, update=True, delete=True) admin = users.current_user() users.set_current_user(ctrl1_creator) ctrl_custom_roles = [(ctrl_editor_role.name, ctrl_editor_role.id, [ctrl2_creator])] ctrl1 = rest_facade.create_control(custom_roles=ctrl_custom_roles) # wait until notification and acl will assigned by background task rest_facade.get_obj(ctrl1) users.set_current_user(ctrl2_creator) ctrl2 = rest_facade.create_control() rest_facade.map_objs(ctrl1, ctrl2) users.set_current_user(admin) # generate expected event data acl_roles_len = 7 exp_event_data = [{ "actions": sorted([ ctrl1_creator.email + " created", u"PersonProfile created" ]), "user_email": admin.email, "time": date_utils.iso8601_to_local_datetime(ctrl1_creator.updated_at) }, { "actions": ["Creator linked to " + ctrl1_creator.email], "user_email": admin.email, "time": date_utils.iso8601_to_local_datetime(ctrl1_creator.updated_at) }, { "actions": sorted([ ctrl2_creator.email + " created", u"PersonProfile created" ]), "user_email": admin.email, "time": date_utils.iso8601_to_local_datetime(ctrl2_creator.updated_at) }, { "actions": ["Creator linked to " + ctrl2_creator.email], "user_email": admin.email, "time": date_utils.iso8601_to_local_datetime(ctrl2_creator.updated_at) }, { "actions": [ctrl_editor_role.name + " created"], "user_email": admin.email, "time": date_utils.iso8601_to_local_datetime( ctrl_editor_role.updated_at) }, { "actions": [u"AccessControlList created"] * acl_roles_len + [u"AccessControlPerson created"] * 2 + [ctrl1.title + " created", u"Security created"], "user_email": ctrl1_creator.email, "time": date_utils.iso8601_to_local_datetime(ctrl1.updated_at) }, { "actions": [u"AccessControlList created"] * acl_roles_len + [ u"AccessControlPerson created", ctrl2.title + " created", u"Security created" ], "user_email": ctrl2_creator.email, "time": date_utils.iso8601_to_local_datetime(ctrl2.updated_at) }, { "actions": [ u"Control:{id2} linked to Control:{id1}".format( id1=ctrl1.id, id2=ctrl2.id) ], "user_email": ctrl2_creator.email, "time": date_utils.iso8601_to_local_datetime(ctrl2.updated_at) }] exp_event_data.reverse() self.__class__._data = { "ctrl1_creator": ctrl1_creator, "ctrl2_creator": ctrl2_creator, "ctrl_editor_role": ctrl_editor_role, "ctrl1": ctrl1, "ctrl2": ctrl2, "exp_added_events": exp_event_data, "initial_count": initial_count } return self.__class__._data
def decline_proposal(self, test_data, selenium): """Decline proposal.""" if test_data["proposal_from_gr"].status == object_states.PROPOSED: users.set_current_user(test_data["control_creator"]) proposal_ui_facade.decline_proposal(selenium, test_data["control"], test_data["proposal_from_gr"])
def program_w_approved_via_ui_review(self, second_creator, program_with_review, selenium): """Approve program review via UI. Returns program instance with approved review.""" users.set_current_user(second_creator) return webui_facade.approve_obj_review(selenium, program_with_review)
def tested_events(self, selenium): """Create events to verify events functionality: 0. Save event log count before test data creation, 1. Create objective editor role, create 2 users with global creator role under admin 2. Create objective#1 under global creator#1 and set global creator#2 to newly created objective editor role 3. Create objective#2 under global objective#2 and map it objective#1 """ if not self.__class__._data: # generate enough data, so test can be executed independently for _ in xrange(6): rest_facade.create_user_with_role(roles.READER) initial_count = self.get_event_tab().tab_events.count objctv1_creator = rest_facade.create_user_with_role(roles.CREATOR) objctv2_creator = rest_facade.create_user_with_role(roles.CREATOR) objctv_editor_role = rest_facade.create_access_control_role( object_type="Objective", read=True, update=True, delete=True) admin = users.current_user() users.set_current_user(objctv1_creator) objctv_custom_roles = [ (objctv_editor_role.name, objctv_editor_role.id, [objctv2_creator]) ] objctv1 = rest_facade.create_objective(custom_roles=objctv_custom_roles) # wait until notification and acl will assigned by background task rest_facade.get_obj(objctv1_creator) users.set_current_user(objctv2_creator) objctv2 = rest_facade.create_objective() rest_facade.map_objs(objctv1, objctv2) users.set_current_user(admin) # generate expected event data from lib.constants.roles import ACLRolesIDs # 3 predefined program roles and 1 predefined reviewer role acl_roles_len = len(ACLRolesIDs.object_roles(objctv1.type)) - 4 exp_event_data = [ {"actions": sorted( [objctv1_creator.email + " created", u"PersonProfile created"]), "user_email": admin.email, "time": date_utils.iso8601_to_local_datetime( objctv1_creator.updated_at)}, {"actions": ["Creator linked to " + objctv1_creator.email], "user_email": admin.email, "time": date_utils.iso8601_to_local_datetime( objctv1_creator.updated_at)}, {"actions": sorted( [objctv2_creator.email + " created", u"PersonProfile created"]), "user_email": admin.email, "time": date_utils.iso8601_to_local_datetime( objctv2_creator.updated_at)}, {"actions": ["Creator linked to " + objctv2_creator.email], "user_email": admin.email, "time": date_utils.iso8601_to_local_datetime( objctv2_creator.updated_at)}, {"actions": [objctv_editor_role.name + " created"], "user_email": admin.email, "time": date_utils.iso8601_to_local_datetime( objctv_editor_role.updated_at)}, {"actions": [u"AccessControlList created"] * acl_roles_len + [u"AccessControlPerson created"] * 2 + [objctv1.title + " created"], "user_email": objctv1_creator.email, "time": date_utils.iso8601_to_local_datetime(objctv1.updated_at)}, {"actions": [u"AccessControlList created"] * acl_roles_len + [u"AccessControlPerson created", objctv2.title + " created"], "user_email": objctv2_creator.email, "time": date_utils.iso8601_to_local_datetime(objctv2.updated_at)}, {"actions": [u"{type2}:{id2} linked to {type1}:{id1}".format( id1=objctv1.id, id2=objctv2.id, type1=objctv1.type, type2=objctv2.type)], "user_email": objctv2_creator.email, "time": date_utils.iso8601_to_local_datetime(objctv2.updated_at)} ] exp_event_data.reverse() self.__class__._data = { "objctv1_creator": objctv1_creator, "objctv2_creator": objctv2_creator, "objctv_editor_role": objctv_editor_role, "objctv1": objctv1, "objctv2": objctv2, "exp_added_events": exp_event_data, "initial_count": initial_count } return self.__class__._data
def apply_proposal(self, test_data, selenium): """Apply proposal.""" if test_data["proposal"].status == object_states.PROPOSED: users.set_current_user(test_data["control_creator"]) proposal_ui_facade.apply_proposal(selenium, test_data["control"], test_data["proposal"])
def program_with_approved_review(self, reviewer, program_with_review): """Approve program review. Returns program instance with approved review.""" users.set_current_user(reviewer) return rest_facade.approve_obj_review(program_with_review)