##// END OF EJS Templates
db: use a wrapper on pull requests _last_merge_status to ensure this is always INT....
marcink -
r1968:ea1add97 default
parent child Browse files
Show More
@@ -3339,6 +3339,14 b' class _PullRequestBase(BaseModel):'
3339 3339 def revisions(self, val):
3340 3340 self._revisions = ':'.join(val)
3341 3341
3342 @hybrid_property
3343 def last_merge_status(self):
3344 return safe_int(self._last_merge_status)
3345
3346 @last_merge_status.setter
3347 def last_merge_status(self, val):
3348 self._last_merge_status = val
3349
3342 3350 @declared_attr
3343 3351 def author(cls):
3344 3352 return relationship('User', lazy='joined')
@@ -780,7 +780,7 b' class PullRequestModel(BaseModel):'
780 780
781 781 version._last_merge_source_rev = pull_request._last_merge_source_rev
782 782 version._last_merge_target_rev = pull_request._last_merge_target_rev
783 version._last_merge_status = pull_request._last_merge_status
783 version.last_merge_status = pull_request.last_merge_status
784 784 version.shadow_merge_ref = pull_request.shadow_merge_ref
785 785 version.merge_rev = pull_request.merge_rev
786 786 version.reviewer_data = pull_request.reviewer_data
@@ -1223,9 +1223,9 b' class PullRequestModel(BaseModel):'
1223 1223 pull_request, target_vcs, target_ref)
1224 1224 else:
1225 1225 possible = pull_request.\
1226 _last_merge_status == MergeFailureReason.NONE
1226 last_merge_status == MergeFailureReason.NONE
1227 1227 merge_state = MergeResponse(
1228 possible, False, None, pull_request._last_merge_status)
1228 possible, False, None, pull_request.last_merge_status)
1229 1229
1230 1230 return merge_state
1231 1231
@@ -1258,7 +1258,7 b' class PullRequestModel(BaseModel):'
1258 1258 pull_request._last_merge_source_rev = \
1259 1259 pull_request.source_ref_parts.commit_id
1260 1260 pull_request._last_merge_target_rev = target_reference.commit_id
1261 pull_request._last_merge_status = merge_state.failure_reason
1261 pull_request.last_merge_status = merge_state.failure_reason
1262 1262 pull_request.shadow_merge_ref = merge_state.merge_ref
1263 1263 Session().add(pull_request)
1264 1264 Session().commit()
@@ -155,7 +155,7 b' class TestPullRequestModel(object):'
155 155
156 156 assert pull_request._last_merge_source_rev is None
157 157 assert pull_request._last_merge_target_rev is None
158 assert pull_request._last_merge_status is None
158 assert pull_request.last_merge_status is None
159 159
160 160 status, msg = PullRequestModel().merge_status(pull_request)
161 161 assert status is True
@@ -168,7 +168,7 b' class TestPullRequestModel(object):'
168 168
169 169 assert pull_request._last_merge_source_rev == self.source_commit
170 170 assert pull_request._last_merge_target_rev == self.target_commit
171 assert pull_request._last_merge_status is MergeFailureReason.NONE
171 assert pull_request.last_merge_status is MergeFailureReason.NONE
172 172
173 173 self.merge_mock.reset_mock()
174 174 status, msg = PullRequestModel().merge_status(pull_request)
@@ -182,7 +182,7 b' class TestPullRequestModel(object):'
182 182
183 183 assert pull_request._last_merge_source_rev is None
184 184 assert pull_request._last_merge_target_rev is None
185 assert pull_request._last_merge_status is None
185 assert pull_request.last_merge_status is None
186 186
187 187 status, msg = PullRequestModel().merge_status(pull_request)
188 188 assert status is False
@@ -198,7 +198,7 b' class TestPullRequestModel(object):'
198 198 assert pull_request._last_merge_source_rev == self.source_commit
199 199 assert pull_request._last_merge_target_rev == self.target_commit
200 200 assert (
201 pull_request._last_merge_status is MergeFailureReason.MERGE_FAILED)
201 pull_request.last_merge_status is MergeFailureReason.MERGE_FAILED)
202 202
203 203 self.merge_mock.reset_mock()
204 204 status, msg = PullRequestModel().merge_status(pull_request)
@@ -214,7 +214,7 b' class TestPullRequestModel(object):'
214 214
215 215 assert pull_request._last_merge_source_rev is None
216 216 assert pull_request._last_merge_target_rev is None
217 assert pull_request._last_merge_status is None
217 assert pull_request.last_merge_status is None
218 218
219 219 status, msg = PullRequestModel().merge_status(pull_request)
220 220 assert status is False
@@ -229,7 +229,7 b' class TestPullRequestModel(object):'
229 229
230 230 assert pull_request._last_merge_source_rev is None
231 231 assert pull_request._last_merge_target_rev is None
232 assert pull_request._last_merge_status is None
232 assert pull_request.last_merge_status is None
233 233
234 234 self.merge_mock.reset_mock()
235 235 status, msg = PullRequestModel().merge_status(pull_request)
@@ -760,7 +760,7 b' def test_create_version_from_snapshot_up'
760 760 pull_request.status = PullRequest.STATUS_CLOSED
761 761 pull_request._last_merge_source_rev = "0" * 40
762 762 pull_request._last_merge_target_rev = "1" * 40
763 pull_request._last_merge_status = 1
763 pull_request.last_merge_status = 1
764 764 pull_request.merge_rev = "2" * 40
765 765
766 766 # Remember automatic values
@@ -787,7 +787,7 b' def test_create_version_from_snapshot_up'
787 787 assert version.target_ref == pr_util.create_parameters['target_ref']
788 788 assert version._last_merge_source_rev == pull_request._last_merge_source_rev
789 789 assert version._last_merge_target_rev == pull_request._last_merge_target_rev
790 assert version._last_merge_status == pull_request._last_merge_status
790 assert version.last_merge_status == pull_request.last_merge_status
791 791 assert version.merge_rev == pull_request.merge_rev
792 792 assert version.pull_request == pull_request
793 793
General Comments 0
You need to be logged in to leave comments. Login now