Exemplo n.º 1
0
    def accept_test(self):
        ms_inv_data = self.ms_inv_data
        admin_user = User.get_existing_user_by_email(PGDB_TEST, TestData.USER_ADMIN["email_addr"])
        ms_inv_data["creator"] = admin_user.user_id

        with AutoRollbackTransaction() as test_trans:
            creation_date_lb = DateTimeUtil.datetime_now_utc_aware()
            ms_invitation = MetaspaceInvitation.create_new_invitation(
                PGDB_TEST,
                ms_inv_data["metaspace_invitation_code"],
                ms_inv_data["invitee_email_addr"],
                ms_inv_data["initial_metaspace_privileges"],
                ms_inv_data["invitation_msg"],
                ms_inv_data["creator"],
            )
            creation_date_ub = DateTimeUtil.datetime_now_utc_aware()
            ms_inv_data["metaspace_invitation_id"] = ms_invitation.metaspace_invitation_id
            ms_inv_data["metaspace_invitation_code"] = ms_invitation.metaspace_invitation_code

            assert creation_date_lb <= ms_invitation.creation_date <= creation_date_ub
            assert ms_inv_data["metaspace_invitation_code"] is not None
            for field_name in MetaspaceInvitation.FIELD_NAMES:
                if field_name not in ["creation_date"]:
                    assert ms_inv_data[field_name] == vars(ms_invitation)[field_name]

            ms_invitation = MetaspaceInvitation.get_existing_invitation(
                PGDB_TEST, ms_inv_data["metaspace_invitation_code"]
            )

            for field_name in MetaspaceInvitation.FIELD_NAMES:
                if field_name not in ["creation_date"]:
                    assert ms_inv_data[field_name] == vars(ms_invitation)[field_name]

            decision_date_lb = DateTimeUtil.datetime_now_utc_aware()
            ms_invitation.create_user_and_accept_invitation(DB_TUPLE_PT_NM, "jasper", "passw0rd", "no comment")
            assert ms_invitation.was_accepted
            assert decision_date_lb <= ms_invitation.decision_date <= DateTimeUtil.datetime_now_utc_aware()
Exemplo n.º 2
0
    def decline_test(self):
        ms_inv_data = self.ms_inv_data
        admin_user = User.get_existing_user_by_email(PGDB_TEST, TestData.USER_ADMIN["email_addr"])
        ms_inv_data["creator"] = admin_user.user_id

        with AutoRollbackTransaction() as test_trans:
            ms_invitation = MetaspaceInvitation.create_new_invitation(
                PGDB_TEST,
                ms_inv_data["metaspace_invitation_code"],
                ms_inv_data["invitee_email_addr"],
                ms_inv_data["initial_metaspace_privileges"],
                ms_inv_data["invitation_msg"],
                ms_inv_data["creator"],
            )

            decision_date_lb = DateTimeUtil.datetime_now_utc_aware()
            ms_invitation.decline_invitation(PGDB_TEST)
            assert not ms_invitation.was_accepted
            assert decision_date_lb <= ms_invitation.decision_date <= DateTimeUtil.datetime_now_utc_aware()

            ms_invitation = MetaspaceInvitation.get_existing_invitation(
                PGDB_TEST, ms_inv_data["metaspace_invitation_code"]
            )
            assert not ms_invitation.was_accepted