|
17 | 17 | LATEST,
|
18 | 18 | EXTERNAL,
|
19 | 19 | )
|
| 20 | +from readthedocs.builds.constants import TAG |
20 | 21 | from readthedocs.builds.models import Build, Version
|
21 | 22 | from readthedocs.oauth.services import GitHubService, GitLabService
|
22 | 23 | from readthedocs.projects.constants import GITHUB_BRAND, GITLAB_BRAND
|
@@ -184,6 +185,45 @@ def test_update_stable_version_excludes_external_versions(self):
|
184 | 185 | # Test that External Version is not considered for stable.
|
185 | 186 | self.assertEqual(self.pip.update_stable_version(), None)
|
186 | 187 |
|
| 188 | + def test_update_stable_version_machine_false(self): |
| 189 | + # Initial stable version from fixture |
| 190 | + self.assertEqual(self.pip.update_stable_version().slug, '0.8.1') |
| 191 | + |
| 192 | + # None, when there is no stable to promote |
| 193 | + self.assertEqual(self.pip.update_stable_version(), None) |
| 194 | + |
| 195 | + get( |
| 196 | + Version, |
| 197 | + identifier='9.0', |
| 198 | + verbose_name='9.0', |
| 199 | + slug='9.0', |
| 200 | + type=TAG, |
| 201 | + project=self.pip, |
| 202 | + active=True, |
| 203 | + ) |
| 204 | + # New stable now is the newly created version |
| 205 | + self.assertEqual(self.pip.update_stable_version().slug, '9.0') |
| 206 | + |
| 207 | + # Make stable version machine=False |
| 208 | + stable = self.pip.get_stable_version() |
| 209 | + stable.machine = False |
| 210 | + stable.save() |
| 211 | + |
| 212 | + get( |
| 213 | + Version, |
| 214 | + identifier='10.0', |
| 215 | + verbose_name='10.0', |
| 216 | + slug='10.0', |
| 217 | + type=TAG, |
| 218 | + project=self.pip, |
| 219 | + active=True, |
| 220 | + ) |
| 221 | + # None, since the stable version is marked as machine=False and Read |
| 222 | + # the Docs does not have control over it |
| 223 | + with patch('readthedocs.projects.models.determine_stable_version') as m: |
| 224 | + self.assertEqual(self.pip.update_stable_version(), None) |
| 225 | + m.assert_not_called() |
| 226 | + |
187 | 227 | def test_has_good_build_excludes_external_versions(self):
|
188 | 228 | # Delete all versions excluding External Versions.
|
189 | 229 | self.pip.versions.exclude(type=EXTERNAL).delete()
|
|
0 commit comments