Exemple #1
0
def request_obj_review(obj, reviewer):
    """Returns obj with requested review."""
    rest_service.ReviewService().create_obj({
        "reviewers": reviewer,
        "reviewable": obj.repr_min_dict()
    })
    return obj.update_attrs(review=entities_factory.ReviewsFactory().create(
        reviewers=reviewer))
Exemple #2
0
def undo_obj_review_approval(selenium, obj):
    """Cancel approved obj review.
  Returns obj with reverted to unreviewed status review."""
    _get_ui_service(selenium, obj).undo_review_approval(obj)
    return obj.update_attrs(review=entities_factory.ReviewsFactory().create(
        last_reviewed_by=users.current_user().email,
        last_reviewed_at=rest_facade.get_last_review_date(obj),
        reviewers=users.current_user()))
Exemple #3
0
def cancel_review_by_editing_obj(selenium, obj):
    """Edit obj title and revert obj review to unreviewed state.
  Returns updated obj with reverted to unreviewed status review."""
    new_title = element.Common.TITLE_EDITED_PART + obj.title
    _get_ui_service(selenium, obj).edit_obj(obj, title=new_title)
    return obj.update_attrs(title=new_title,
                            updated_at=rest_facade.get_obj(obj).updated_at,
                            modified_by=users.current_user().email,
                            review=entities_factory.ReviewsFactory().create())
Exemple #4
0
def approve_obj_review(selenium, obj):
    """Approve obj review.
  Returns obj with approved review."""
    _get_ui_service(selenium, obj).approve_review(obj)
    return obj.update_attrs(review=entities_factory.ReviewsFactory().create(
        status=element.ReviewStates.REVIEWED,
        last_reviewed_by=users.current_user().email,
        last_reviewed_at=rest_facade.get_last_review_date(obj),
        reviewers=users.current_user()))
Exemple #5
0
def approve_obj_review(obj):
    """Returns obj with approved review."""
    rest_review = get_obj_review(obj)
    rest_service.ReviewService().update_obj(
        obj=rest_review, status=element.ReviewStates.REVIEWED)
    return obj.update_attrs(review=entities_factory.ReviewsFactory().create(
        status=element.ReviewStates.REVIEWED,
        reviewers=users.current_user(),
        last_reviewed_by=users.current_user().email,
        last_reviewed_at=date_utils.iso8601_to_ui_str_with_zone(
            rest_review.last_reviewed_at)))
Exemple #6
0
def submit_obj_for_review(selenium, obj, reviewer):
    """Submit object for review scenario.
  Returns obj with assigned review."""
    _get_ui_service(selenium, obj).submit_for_review(
        obj, reviewer.email, string_utils.StringMethods.random_string())
    exp_review = entities_factory.ReviewsFactory().create(
        is_add_rest_attrs=True,
        reviewers=reviewer,
        status=element.ReviewStates.UNREVIEWED)
    obj.review = exp_review.convert_review_to_dict()
    obj.review_status = exp_review.status
    return obj
Exemple #7
0
def undo_obj_review_approval(selenium, obj):
    """Cancel approved obj review.
  Returns obj with reverted to unreviewed status review."""
    _get_ui_service(selenium, obj).undo_review_approval(obj)
    exp_review = entities_factory.ReviewsFactory().create(
        is_add_rest_attrs=True,
        status=element.ReviewStates.UNREVIEWED,
        last_reviewed_by=users.current_user().email,
        last_reviewed_at=rest_facade.get_last_review_date(obj),
        reviewers=users.current_user())
    obj.review = exp_review.convert_review_to_dict()
    obj.review_status = exp_review.status
    return obj
Exemple #8
0
def approve_obj_review(selenium, obj):
    """Approve obj review.
  Returns obj with approved review."""
    _get_ui_service(selenium, obj).approve_review(obj)
    exp_review = entities_factory.ReviewsFactory().create(
        is_add_rest_attrs=True,
        status=element.ReviewStates.REVIEWED,
        last_reviewed_by=users.current_user().email,
        last_reviewed_at=rest_facade.get_last_review_date(obj),
        reviewers=users.current_user())
    obj.review = exp_review.convert_review_to_dict()
    obj.review_status = exp_review.status
    return obj
Exemple #9
0
def request_obj_review(obj, reviewer):
    """Returns obj with requested review."""
    rest_service.ReviewService().create_obj({
        "reviewers": reviewer,
        "reviewable": obj.repr_min_dict()
    })
    exp_review = entities_factory.ReviewsFactory().create(
        is_add_rest_attrs=True,
        status=element.ReviewStates.UNREVIEWED,
        reviewers=reviewer)
    obj.review = exp_review.convert_review_to_dict()
    obj.review_status = exp_review.status
    return obj
Exemple #10
0
def approve_obj_review(obj):
    """Returns obj with approved review."""
    rest_review = get_obj_review(obj)
    rest_service.ReviewService().update_obj(
        obj=rest_review, status=element.ReviewStates.REVIEWED)
    exp_review = entities_factory.ReviewsFactory().create(
        is_add_rest_attrs=True,
        status=element.ReviewStates.REVIEWED,
        reviewers=users.current_user(),
        last_reviewed_by=users.current_user().email,
        last_reviewed_at=rest_review.last_reviewed_at)
    obj.review = exp_review.convert_review_to_dict()
    obj.review_status = exp_review.status
    return obj
Exemple #11
0
def submit_obj_for_review(selenium, obj, reviewer):
    """Submit object for review scenario.
  Returns obj with assigned review."""
    review_comment = string_utils.StringMethods.random_string()
    _get_ui_service(selenium, obj).submit_for_review(obj, reviewer.email,
                                                     review_comment)
    obj.update_attrs(review=entities_factory.ReviewsFactory().create(
        reviewers=reviewer))
    exp_comment = entities_factory.CommentsFactory(
    ).create(description=element.Common.REVIEW_COMMENT_PATTERN.format(
        # reviewers emails in review comment message need to be sorted
        # as they are displayed in UI in random order
        emails=', '.join(sorted(obj.review["reviewers"])),
        comment=review_comment))
    exp_comment.created_at = rest_service.ObjectsInfoService().get_comment_obj(
        paren_obj=obj, comment_description=review_comment).created_at
    obj.comments = [exp_comment.repr_ui()]
    return obj
Exemple #12
0
def get_obj_review(obj):
    """Get obj review instance."""
    rest_obj = get_obj(obj)
    return get_obj(entities_factory.ReviewsFactory().create(**rest_obj.review))