Cleanup test code and comment it
@@ -478,6 +478,7 @@ class TestStableVersion(TestCase):
active=True,
)
+ # A pre-existing active stable branch that was machine created
Version.objects.create(
project=self.pip,
identifier='foo',
@@ -493,14 +494,11 @@ class TestStableVersion(TestCase):
'identifier': 'origin/master',
'verbose_name': 'master',
},
+ # A new user-defined stable branch
{
'identifier': 'origin/stable',
'verbose_name': 'stable',
},
- {
- 'identifier': 'origin/to_add',
- 'verbose_name': 'to_add',
- },
],
'tags': [
{
@@ -520,27 +518,21 @@ class TestStableVersion(TestCase):
content_type='application/json',
)
+ # Didn't update to newest tag
version_9 = Version.objects.get(slug='0.9')
self.assertFalse(version_9.active)
+ # Did update to user-defined stable version
version_stable = Version.objects.get(slug='stable')
self.assertFalse(version_stable.machine)
self.assertTrue(version_stable.active)
+ self.assertEqual('origin/stable', self.pip.get_stable_version().identifier)
- # Version 0.9 doesn't become stable, since we already had a user-defined stable
- self.assertEqual(
- 'origin/stable',
- self.pip.get_stable_version().identifier,
- )
-
+ # Check that posting again doesn't change anything from current state.
self.client.post(
'/api/v2/project/{}/sync_versions/'.format(self.pip.pk),
data=json.dumps(version_post_data),
content_type='application/json',
)
- # Version 0.9 doesn't become stable, since we already had a user-defined stable
- self.assertEqual(
- 'origin/stable',
- self.pip.get_stable_version().identifier,
- )
+ self.assertEqual('origin/stable', self.pip.get_stable_version().identifier)
