Commit b8a689dece226ee7990f31969d0d0480a0cb34c0
Committed by
Lucas Kanashiro
1 parent
49b30092
Exists in
master
and in
28 other branches
Add gitlab url test for iid
Showing
1 changed file
with
73 additions
and
36 deletions
Show diff stats
colab/plugins/gitlab/tests/test_gitlab.py
| @@ -34,55 +34,92 @@ class GitlabTest(TestCase): | @@ -34,55 +34,92 @@ class GitlabTest(TestCase): | ||
| 34 | '/gitlab/softwarepublico/colab') | 34 | '/gitlab/softwarepublico/colab') |
| 35 | 35 | ||
| 36 | def test_merge_request_url(self): | 36 | def test_merge_request_url(self): |
| 37 | - self.assertEqual(GitlabMergeRequest.objects.get(iid=1).url, | 37 | + self.assertEqual(GitlabMergeRequest.objects.get(id=1).url, |
| 38 | '/gitlab/softwarepublico/colab/merge_requests/1') | 38 | '/gitlab/softwarepublico/colab/merge_requests/1') |
| 39 | + self.assertEqual(GitlabMergeRequest.objects.get(id=2).url, | ||
| 40 | + '/gitlab/softwarepublico/colabinc/merge_requests/1') | ||
| 39 | 41 | ||
| 40 | def test_issue_url(self): | 42 | def test_issue_url(self): |
| 41 | self.assertEqual(GitlabIssue.objects.get(id=1).url, | 43 | self.assertEqual(GitlabIssue.objects.get(id=1).url, |
| 42 | '/gitlab/softwarepublico/colab/issues/1') | 44 | '/gitlab/softwarepublico/colab/issues/1') |
| 45 | + self.assertEqual(GitlabIssue.objects.get(id=2).url, | ||
| 46 | + '/gitlab/softwarepublico/colabinc/issues/1') | ||
| 43 | 47 | ||
| 44 | def test_comment_on_mr_url(self): | 48 | def test_comment_on_mr_url(self): |
| 45 | url = '/gitlab/softwarepublico/colab/merge_requests/1#notes_1' | 49 | url = '/gitlab/softwarepublico/colab/merge_requests/1#notes_1' |
| 46 | - self.assertEqual(GitlabComment.objects.get(iid=1).url, url) | 50 | + self.assertEqual(GitlabComment.objects.get(id=1).url, url) |
| 47 | 51 | ||
| 48 | def test_comment_on_issue_url(self): | 52 | def test_comment_on_issue_url(self): |
| 49 | self.assertEqual(GitlabComment.objects.get(id=2).url, | 53 | self.assertEqual(GitlabComment.objects.get(id=2).url, |
| 50 | '/gitlab/softwarepublico/colab/issues/1#notes_2') | 54 | '/gitlab/softwarepublico/colab/issues/1#notes_2') |
| 51 | 55 | ||
| 52 | def create_gitlab_data(self): | 56 | def create_gitlab_data(self): |
| 53 | - g = GitlabProject() | ||
| 54 | - g.id = 1 | ||
| 55 | - g.name = "colab" | ||
| 56 | - g.name_with_namespace = "Software Public / Colab" | ||
| 57 | - g.path_with_namespace = "softwarepublico/colab" | ||
| 58 | - g.created_at = datetime.now() | ||
| 59 | - g.last_activity_at = datetime.now() | ||
| 60 | - g.save() | ||
| 61 | - | ||
| 62 | - mr = GitlabMergeRequest() | ||
| 63 | - mr.iid = 1 | ||
| 64 | - mr.project = g | ||
| 65 | - mr.title = "Include plugin support" | ||
| 66 | - mr.description = "Merge request for plugin support" | ||
| 67 | - mr.state = "Closed" | ||
| 68 | - mr.created_at = datetime.now() | ||
| 69 | - mr.update_user(self.user.username) | ||
| 70 | - mr.save() | ||
| 71 | - | ||
| 72 | - i = GitlabIssue() | ||
| 73 | - i.id = 1 | ||
| 74 | - i.project = g | ||
| 75 | - i.title = "Issue for colab" | ||
| 76 | - i.description = "Issue reported to colab" | ||
| 77 | - i.created_at = datetime.now() | ||
| 78 | - i.state = "Open" | ||
| 79 | - i.update_user(self.user.username) | ||
| 80 | - i.save() | ||
| 81 | - | 57 | + g1 = GitlabProject() |
| 58 | + g1.id = 1 | ||
| 59 | + g1.name = "colab" | ||
| 60 | + g1.name_with_namespace = "Software Public / Colab" | ||
| 61 | + g1.path_with_namespace = "softwarepublico/colab" | ||
| 62 | + g1.created_at = datetime.now() | ||
| 63 | + g1.last_activity_at = datetime.now() | ||
| 64 | + g1.save() | ||
| 65 | + | ||
| 66 | + g2 = GitlabProject() | ||
| 67 | + g2.id = 1 | ||
| 68 | + g2.name = "colabinc" | ||
| 69 | + g2.name_with_namespace = "Software Public / ColabInc" | ||
| 70 | + g2.path_with_namespace = "softwarepublico/colabinc" | ||
| 71 | + g2.created_at = datetime.now() | ||
| 72 | + g2.last_activity_at = datetime.now() | ||
| 73 | + g2.save() | ||
| 74 | + | ||
| 75 | + mr1 = GitlabMergeRequest() | ||
| 76 | + mr1.id = 1 | ||
| 77 | + mr1.iid = 1 | ||
| 78 | + mr1.project = g1 | ||
| 79 | + mr1.title = "Include plugin support" | ||
| 80 | + mr1.description = "Merge request for plugin support" | ||
| 81 | + mr1.state = "Closed" | ||
| 82 | + mr1.created_at = datetime.now() | ||
| 83 | + mr1.update_user(self.user.username) | ||
| 84 | + mr1.save() | ||
| 85 | + | ||
| 86 | + mr2 = GitlabMergeRequest() | ||
| 87 | + mr2.id = 2 | ||
| 88 | + mr2.iid = 1 | ||
| 89 | + mr2.project = g2 | ||
| 90 | + mr2.title = "Include test support" | ||
| 91 | + mr2.description = "Merge request for test support" | ||
| 92 | + mr2.state = "Closed" | ||
| 93 | + mr2.created_at = datetime.now() | ||
| 94 | + mr2.update_user(self.user.username) | ||
| 95 | + mr2.save() | ||
| 96 | + | ||
| 97 | + i1 = GitlabIssue() | ||
| 98 | + i1.id = 1 | ||
| 99 | + i1.iid = 1 | ||
| 100 | + i1.project = g1 | ||
| 101 | + i1.title = "Issue for colab" | ||
| 102 | + i1.description = "Issue reported to colab" | ||
| 103 | + i1.created_at = datetime.now() | ||
| 104 | + i1.state = "Open" | ||
| 105 | + i1.update_user(self.user.username) | ||
| 106 | + i1.save() | ||
| 107 | + | ||
| 108 | + i2 = GitlabIssue() | ||
| 109 | + i2.id = 2 | ||
| 110 | + i2.iid = 2 | ||
| 111 | + i2.project = g2 | ||
| 112 | + i2.title = "Issue for colab" | ||
| 113 | + i2.description = "Issue reported to colab" | ||
| 114 | + i2.created_at = datetime.now() | ||
| 115 | + i2.state = "Open" | ||
| 116 | + i2.update_user(self.user.username) | ||
| 117 | + i2.save() | ||
| 118 | + | ||
| 82 | c1 = GitlabComment() | 119 | c1 = GitlabComment() |
| 83 | - c1.iid = 1 | 120 | + c1.id = 1 |
| 84 | c1.parent_id = mr.iid | 121 | c1.parent_id = mr.iid |
| 85 | - c1.project = g | 122 | + c1.project = g1 |
| 86 | c1.body = "Comment to merge request" | 123 | c1.body = "Comment to merge request" |
| 87 | c1.created_at = datetime.now() | 124 | c1.created_at = datetime.now() |
| 88 | c1.issue_comment = False | 125 | c1.issue_comment = False |
| @@ -90,9 +127,9 @@ class GitlabTest(TestCase): | @@ -90,9 +127,9 @@ class GitlabTest(TestCase): | ||
| 90 | c1.save() | 127 | c1.save() |
| 91 | 128 | ||
| 92 | c2 = GitlabComment() | 129 | c2 = GitlabComment() |
| 93 | - c2.iid = 2 | ||
| 94 | - c2.parent_id = i.id | ||
| 95 | - c2.project = g | 130 | + c2.id = 2 |
| 131 | + c2.parent_id = i1.id | ||
| 132 | + c2.project = g1 | ||
| 96 | c2.body = "Comment to issue" | 133 | c2.body = "Comment to issue" |
| 97 | c2.created_at = datetime.now() | 134 | c2.created_at = datetime.now() |
| 98 | c2.issue_comment = True | 135 | c2.issue_comment = True |