|
1 | | -from ..models import Release |
| 1 | +from ..models import Release, ReleaseFile |
2 | 2 | from .base import BaseDownloadTests |
3 | 3 |
|
4 | 4 |
|
@@ -95,3 +95,54 @@ def test_is_version_at_least_with_invalid_name(self): |
95 | 95 | self.assertFalse(invalid_release.is_version_at_least_3_5) |
96 | 96 | self.assertFalse(invalid_release.is_version_at_least_3_9) |
97 | 97 | self.assertFalse(invalid_release.is_version_at_least_3_14) |
| 98 | + |
| 99 | + def test_update_supernav(self): |
| 100 | + from ..models import update_supernav |
| 101 | + from boxes.models import Box |
| 102 | + |
| 103 | + release = Release.objects.create( |
| 104 | + name='Python install manager 25.0', |
| 105 | + version=Release.PYMANAGER, |
| 106 | + is_latest=True, |
| 107 | + is_published=True, |
| 108 | + ) |
| 109 | + |
| 110 | + for os, slug in [ |
| 111 | + (self.windows, 'python3.10-windows'), |
| 112 | + (self.osx, 'python3.10-macos'), |
| 113 | + (self.linux, 'python3.10-linux'), |
| 114 | + ]: |
| 115 | + ReleaseFile.objects.create( |
| 116 | + os=os, |
| 117 | + release=self.python_3, |
| 118 | + slug=slug, |
| 119 | + name='Python 3.10', |
| 120 | + url='/ftp/python/{}.zip'.format(slug), |
| 121 | + download_button=True, |
| 122 | + ) |
| 123 | + |
| 124 | + update_supernav() |
| 125 | + |
| 126 | + content = Box.objects.get(label='supernav-python-downloads').content.rendered |
| 127 | + self.assertIn('class="download-os-windows"', content) |
| 128 | + self.assertNotIn('pymanager-25.0.msix', content) |
| 129 | + self.assertIn('python3.10-windows.zip', content) |
| 130 | + self.assertIn('class="download-os-macos"', content) |
| 131 | + self.assertIn('python3.10-macos.zip', content) |
| 132 | + self.assertIn('class="download-os-linux"', content) |
| 133 | + self.assertIn('python3.10-linux.zip', content) |
| 134 | + |
| 135 | + ReleaseFile.objects.create( |
| 136 | + os=self.windows, |
| 137 | + release=release, |
| 138 | + name='MSIX', |
| 139 | + url='/ftp/python/pymanager/pymanager-25.0.msix', |
| 140 | + download_button=True, |
| 141 | + ) |
| 142 | + |
| 143 | + update_supernav() |
| 144 | + |
| 145 | + content = Box.objects.get(label='supernav-python-downloads').content.rendered |
| 146 | + self.assertIn('class="download-os-windows"', content) |
| 147 | + self.assertIn('pymanager-25.0.msix', content) |
| 148 | + self.assertIn('python3.10-windows.zip', content) |
0 commit comments