##// END OF EJS Templates
tests: fixed some broken tests
milka -
r4563:98909132 default
parent child Browse files
Show More
@@ -608,23 +608,23 b' class TestPullrequestsView(object):'
608 pull_request.source_repo, pull_request=pull_request)
608 pull_request.source_repo, pull_request=pull_request)
609 assert status == ChangesetStatus.STATUS_REJECTED
609 assert status == ChangesetStatus.STATUS_REJECTED
610
610
611 comment_id = response.json.get('comment_id', None)
611 for comment_id in response.json.keys():
612 test_text = 'test'
612 test_text = 'test'
613 response = self.app.post(
613 response = self.app.post(
614 route_path(
614 route_path(
615 'pullrequest_comment_edit',
615 'pullrequest_comment_edit',
616 repo_name=target_scm_name,
616 repo_name=target_scm_name,
617 pull_request_id=pull_request_id,
617 pull_request_id=pull_request_id,
618 comment_id=comment_id,
618 comment_id=comment_id,
619 ),
619 ),
620 extra_environ=xhr_header,
620 extra_environ=xhr_header,
621 params={
621 params={
622 'csrf_token': csrf_token,
622 'csrf_token': csrf_token,
623 'text': test_text,
623 'text': test_text,
624 },
624 },
625 status=403,
625 status=403,
626 )
626 )
627 assert response.status_int == 403
627 assert response.status_int == 403
628
628
629 def test_comment_and_comment_edit(self, pr_util, csrf_token, xhr_header):
629 def test_comment_and_comment_edit(self, pr_util, csrf_token, xhr_header):
630 pull_request = pr_util.create_pull_request()
630 pull_request = pr_util.create_pull_request()
@@ -644,27 +644,27 b' class TestPullrequestsView(object):'
644 )
644 )
645 assert response.json
645 assert response.json
646
646
647 comment_id = response.json.get('comment_id', None)
647 for comment_id in response.json.keys():
648 assert comment_id
648 assert comment_id
649 test_text = 'test'
649 test_text = 'test'
650 self.app.post(
650 self.app.post(
651 route_path(
651 route_path(
652 'pullrequest_comment_edit',
652 'pullrequest_comment_edit',
653 repo_name=target_scm_name,
653 repo_name=target_scm_name,
654 pull_request_id=pull_request.pull_request_id,
654 pull_request_id=pull_request.pull_request_id,
655 comment_id=comment_id,
655 comment_id=comment_id,
656 ),
656 ),
657 extra_environ=xhr_header,
657 extra_environ=xhr_header,
658 params={
658 params={
659 'csrf_token': csrf_token,
659 'csrf_token': csrf_token,
660 'text': test_text,
660 'text': test_text,
661 'version': '0',
661 'version': '0',
662 },
662 },
663
663
664 )
664 )
665 text_form_db = ChangesetComment.query().filter(
665 text_form_db = ChangesetComment.query().filter(
666 ChangesetComment.comment_id == comment_id).first().text
666 ChangesetComment.comment_id == comment_id).first().text
667 assert test_text == text_form_db
667 assert test_text == text_form_db
668
668
669 def test_comment_and_comment_edit(self, pr_util, csrf_token, xhr_header):
669 def test_comment_and_comment_edit(self, pr_util, csrf_token, xhr_header):
670 pull_request = pr_util.create_pull_request()
670 pull_request = pr_util.create_pull_request()
@@ -684,26 +684,25 b' class TestPullrequestsView(object):'
684 )
684 )
685 assert response.json
685 assert response.json
686
686
687 comment_id = response.json.get('comment_id', None)
687 for comment_id in response.json.keys():
688 assert comment_id
688 test_text = 'init'
689 test_text = 'init'
689 response = self.app.post(
690 response = self.app.post(
690 route_path(
691 route_path(
691 'pullrequest_comment_edit',
692 'pullrequest_comment_edit',
692 repo_name=target_scm_name,
693 repo_name=target_scm_name,
693 pull_request_id=pull_request.pull_request_id,
694 pull_request_id=pull_request.pull_request_id,
694 comment_id=comment_id,
695 comment_id=comment_id,
695 ),
696 ),
696 extra_environ=xhr_header,
697 extra_environ=xhr_header,
697 params={
698 params={
698 'csrf_token': csrf_token,
699 'csrf_token': csrf_token,
699 'text': test_text,
700 'text': test_text,
700 'version': '0',
701 'version': '0',
701 },
702 },
702 status=404,
703 status=404,
704
703
705 )
704 )
706 assert response.status_int == 404
705 assert response.status_int == 404
707
706
708 def test_comment_and_try_edit_already_edited(self, pr_util, csrf_token, xhr_header):
707 def test_comment_and_try_edit_already_edited(self, pr_util, csrf_token, xhr_header):
709 pull_request = pr_util.create_pull_request()
708 pull_request = pr_util.create_pull_request()
@@ -722,48 +721,46 b' class TestPullrequestsView(object):'
722 extra_environ=xhr_header,
721 extra_environ=xhr_header,
723 )
722 )
724 assert response.json
723 assert response.json
725 comment_id = response.json.get('comment_id', None)
724 for comment_id in response.json.keys():
726 assert comment_id
725 test_text = 'test'
727
726 self.app.post(
728 test_text = 'test'
727 route_path(
729 self.app.post(
728 'pullrequest_comment_edit',
730 route_path(
729 repo_name=target_scm_name,
731 'pullrequest_comment_edit',
730 pull_request_id=pull_request.pull_request_id,
732 repo_name=target_scm_name,
731 comment_id=comment_id,
733 pull_request_id=pull_request.pull_request_id,
732 ),
734 comment_id=comment_id,
733 extra_environ=xhr_header,
735 ),
734 params={
736 extra_environ=xhr_header,
735 'csrf_token': csrf_token,
737 params={
736 'text': test_text,
738 'csrf_token': csrf_token,
737 'version': '0',
739 'text': test_text,
738 },
740 'version': '0',
741 },
742
739
743 )
740 )
744 test_text_v2 = 'test_v2'
741 test_text_v2 = 'test_v2'
745 response = self.app.post(
742 response = self.app.post(
746 route_path(
743 route_path(
747 'pullrequest_comment_edit',
744 'pullrequest_comment_edit',
748 repo_name=target_scm_name,
745 repo_name=target_scm_name,
749 pull_request_id=pull_request.pull_request_id,
746 pull_request_id=pull_request.pull_request_id,
750 comment_id=comment_id,
747 comment_id=comment_id,
751 ),
748 ),
752 extra_environ=xhr_header,
749 extra_environ=xhr_header,
753 params={
750 params={
754 'csrf_token': csrf_token,
751 'csrf_token': csrf_token,
755 'text': test_text_v2,
752 'text': test_text_v2,
756 'version': '0',
753 'version': '0',
757 },
754 },
758 status=409,
755 status=409,
759 )
756 )
760 assert response.status_int == 409
757 assert response.status_int == 409
761
758
762 text_form_db = ChangesetComment.query().filter(
759 text_form_db = ChangesetComment.query().filter(
763 ChangesetComment.comment_id == comment_id).first().text
760 ChangesetComment.comment_id == comment_id).first().text
764
761
765 assert test_text == text_form_db
762 assert test_text == text_form_db
766 assert test_text_v2 != text_form_db
763 assert test_text_v2 != text_form_db
767
764
768 def test_comment_and_comment_edit_permissions_forbidden(
765 def test_comment_and_comment_edit_permissions_forbidden(
769 self, autologin_regular_user, user_regular, user_admin, pr_util,
766 self, autologin_regular_user, user_regular, user_admin, pr_util,
General Comments 0
You need to be logged in to leave comments. Login now