Пример #1
0
    def test_flat(self):
        final_versions = version_windows(self.versions,
                                         major=2,
                                         minor=2,
                                         point=1,
                                         flat=True)
        self.assertEqual(len(final_versions), 4)
        self.assertEqual(final_versions, [
            VersionIdentifier('1.2.0'),
            VersionIdentifier('1.3.0'),
            VersionIdentifier('2.2.0'),
            VersionIdentifier('2.3.3')
        ])

        final_versions = version_windows(self.versions,
                                         major=3,
                                         minor=2,
                                         point=1,
                                         flat=True)
        self.assertEqual(len(final_versions), 6)
        self.assertEqual(final_versions, [
            VersionIdentifier('0.2.1'),
            VersionIdentifier('0.3.1'),
            VersionIdentifier('1.2.0'),
            VersionIdentifier('1.3.0'),
            VersionIdentifier('2.2.0'),
            VersionIdentifier('2.3.3')
        ])

        final_versions = version_windows(self.versions,
                                         major=3,
                                         minor=2,
                                         point=2,
                                         flat=True)
        self.assertEqual(len(final_versions), 9)
Пример #2
0
    def test_flat(self):
        final_versions = version_windows(self.versions, major=2, minor=2, point=1, flat=True)
        self.assertEqual(len(final_versions), 4)
        self.assertEqual(
            final_versions,
            [
                VersionIdentifier("1.2.0"),
                VersionIdentifier("1.3.0"),
                VersionIdentifier("2.2.0"),
                VersionIdentifier("2.3.3"),
            ],
        )

        final_versions = version_windows(self.versions, major=3, minor=2, point=1, flat=True)
        self.assertEqual(len(final_versions), 6)
        self.assertEqual(
            final_versions,
            [
                VersionIdentifier("0.2.1"),
                VersionIdentifier("0.3.1"),
                VersionIdentifier("1.2.0"),
                VersionIdentifier("1.3.0"),
                VersionIdentifier("2.2.0"),
                VersionIdentifier("2.3.3"),
            ],
        )

        final_versions = version_windows(self.versions, major=3, minor=2, point=2, flat=True)
        self.assertEqual(len(final_versions), 9)
Пример #3
0
    def test_sort(self):
        final_versions = version_windows(self.versions,
                                         major=2,
                                         minor=2,
                                         point=1)
        self.assertTrue(final_versions[1][2][0] == VersionIdentifier('1.2.0'))
        self.assertTrue(final_versions[1][3][0] == VersionIdentifier('1.3.0'))
        self.assertTrue(final_versions[2][3][0] == VersionIdentifier('2.3.3'))
        self.assertTrue(final_versions[2][3][0] != VersionIdentifier('2.3.0'))

        final_versions = version_windows(self.versions,
                                         major=1,
                                         minor=2,
                                         point=2)
        # 1 major version
        self.assertEqual(final_versions[1], {})
        # 2 minor versions
        self.assertEqual(len(final_versions[2]), 2)
        # 2 point versions
        self.assertEqual(len(final_versions[2][3]), 2)
        final_versions = version_windows(self.versions,
                                         major=1,
                                         minor=2,
                                         point=3)
        # 2 point versions
        self.assertEqual(len(final_versions[2][3]), 3)
Пример #4
0
    def test_minor(self):
        minor_versions = version_windows(self.versions, minor=1)
        self.assertEqual(len(minor_versions[2]), 1)

        minor_versions = version_windows(self.versions, minor=2)
        self.assertEqual(len(minor_versions[2]), 2)

        minor_versions = version_windows(self.versions, minor=3)
        self.assertEqual(len(minor_versions[2]), 3)

        minor_versions = version_windows(self.versions, minor=4)
        self.assertEqual(len(minor_versions[2]), 3)
Пример #5
0
    def test_major(self):
        major_versions = version_windows(self.versions, major=1)
        self.assertEqual(len(major_versions), 1)

        major_versions = version_windows(self.versions, major=2)
        self.assertEqual(len(major_versions), 2)

        major_versions = version_windows(self.versions, major=3)
        self.assertEqual(len(major_versions), 3)

        major_versions = version_windows(self.versions, major=4)
        self.assertEqual(len(major_versions), 3)
Пример #6
0
    def test_minor(self):
        minor_versions = version_windows(self.versions, minor=1)
        self.assertEqual(len(minor_versions[2]), 1)

        minor_versions = version_windows(self.versions, minor=2)
        self.assertEqual(len(minor_versions[2]), 2)

        minor_versions = version_windows(self.versions, minor=3)
        self.assertEqual(len(minor_versions[2]), 3)

        minor_versions = version_windows(self.versions, minor=4)
        self.assertEqual(len(minor_versions[2]), 3)
Пример #7
0
    def test_major(self):
        major_versions = version_windows(self.versions, major=1)
        self.assertEqual(len(major_versions), 1)

        major_versions = version_windows(self.versions, major=2)
        self.assertEqual(len(major_versions), 2)

        major_versions = version_windows(self.versions, major=3)
        self.assertEqual(len(major_versions), 3)

        major_versions = version_windows(self.versions, major=4)
        self.assertEqual(len(major_versions), 3)
Пример #8
0
    def test_point(self):
        point_versions = version_windows(self.versions, point=1)
        self.assertEqual(len(point_versions[2][3]), 1)

        point_versions = version_windows(self.versions, point=2)
        self.assertEqual(len(point_versions[2][3]), 2)

        point_versions = version_windows(self.versions, point=3)
        self.assertEqual(len(point_versions[2][3]), 3)

        point_versions = version_windows(self.versions, point=4)
        self.assertEqual(len(point_versions[2][3]), 4)

        point_versions = version_windows(self.versions, point=5)
        self.assertEqual(len(point_versions[2][3]), 4)
Пример #9
0
    def test_point(self):
        point_versions = version_windows(self.versions, point=1)
        self.assertEqual(len(point_versions[2][3]), 1)

        point_versions = version_windows(self.versions, point=2)
        self.assertEqual(len(point_versions[2][3]), 2)

        point_versions = version_windows(self.versions, point=3)
        self.assertEqual(len(point_versions[2][3]), 3)

        point_versions = version_windows(self.versions, point=4)
        self.assertEqual(len(point_versions[2][3]), 4)

        point_versions = version_windows(self.versions, point=5)
        self.assertEqual(len(point_versions[2][3]), 4)
Пример #10
0
 def valid_versions(self, request, **kwargs):
     """
     Maintain state of versions that are wanted.
     """
     project = get_object_or_404(Project, pk=kwargs['pk'])
     if not project.num_major or not project.num_minor or not project.num_point:
         return Response({'error': 'Project does not support point version control'}, status=status.HTTP_400_BAD_REQUEST)
     versions = []
     for ver in project.versions.all():
         try:
             versions.append(BetterVersion(ver.verbose_name))
         except UnsupportedVersionError:
             # Probably a branch
             pass
     active_versions = version_windows(
         versions, 
         major=project.num_major, 
         minor=project.num_minor, 
         point=project.num_point,
         flat=True,
     )
     version_strings = [v._string for v in active_versions]
     # Disable making old versions inactive for now.
     #project.versions.exclude(verbose_name__in=version_strings).update(active=False)
     project.versions.filter(verbose_name__in=version_strings).update(active=True)
     return Response({
         'flat': version_strings,
         })
Пример #11
0
 def valid_versions(self, request, **kwargs):
     """
     Maintain state of versions that are wanted.
     """
     project = get_object_or_404(Project, pk=kwargs['pk'])
     if not project.num_major or not project.num_minor or not project.num_point:
         return Response(
             {'error': 'Project does not support point version control'},
             status=status.HTTP_400_BAD_REQUEST)
     versions = []
     for ver in project.versions.all():
         try:
             versions.append(BetterVersion(ver.verbose_name))
         except UnsupportedVersionError:
             # Probably a branch
             pass
     active_versions = version_windows(
         versions,
         major=project.num_major,
         minor=project.num_minor,
         point=project.num_point,
         flat=True,
     )
     version_strings = [v._string for v in active_versions]
     # Disable making old versions inactive for now.
     #project.versions.exclude(verbose_name__in=version_strings).update(active=False)
     project.versions.filter(verbose_name__in=version_strings).update(
         active=True)
     return Response({
         'flat': version_strings,
     })
Пример #12
0
    def test_sort(self):
        final_versions = version_windows(self.versions, major=2, minor=2, point=1)
        self.assertTrue(final_versions[1][2][0] == VersionIdentifier("1.2.0"))
        self.assertTrue(final_versions[1][3][0] == VersionIdentifier("1.3.0"))
        self.assertTrue(final_versions[2][3][0] == VersionIdentifier("2.3.3"))
        self.assertTrue(final_versions[2][3][0] != VersionIdentifier("2.3.0"))

        final_versions = version_windows(self.versions, major=1, minor=2, point=2)
        # 1 major version
        self.assertEqual(final_versions[1], {})
        # 2 minor versions
        self.assertEqual(len(final_versions[2]), 2)
        # 2 point versions
        self.assertEqual(len(final_versions[2][3]), 2)
        final_versions = version_windows(self.versions, major=1, minor=2, point=3)
        # 2 point versions
        self.assertEqual(len(final_versions[2][3]), 3)
Пример #13
0
    def test_flat(self):
        final_versions = version_windows(self.versions, major=2, minor=2, point=1, flat=True)
        self.assertEqual(len(final_versions), 4)
        self.assertEqual(
            final_versions, 
            [BetterVersion('1.2.0'), BetterVersion('1.3.0'), BetterVersion('2.2.0'), BetterVersion('2.3.3')]
        )

        final_versions = version_windows(self.versions, major=3, minor=2, point=1, flat=True)
        self.assertEqual(len(final_versions), 6)
        self.assertEqual(
            final_versions, 
            [BetterVersion('0.2.1'), BetterVersion('0.3.1'), BetterVersion('1.2.0'), BetterVersion('1.3.0'), BetterVersion('2.2.0'), BetterVersion('2.3.3')]
        )

        final_versions = version_windows(self.versions, major=3, minor=2, point=2, flat=True)
        self.assertEqual(len(final_versions), 9)
Пример #14
0
    def test_sort(self):
        final_versions = version_windows(self.versions, major=2, minor=2, point=1)
        self.assertTrue(final_versions[1][2][0] == BetterVersion('1.2.0'))
        self.assertTrue(final_versions[1][3][0] == BetterVersion('1.3.0'))
        self.assertTrue(final_versions[2][3][0] == BetterVersion('2.3.3'))
        self.assertTrue(final_versions[2][3][0] != BetterVersion('2.3.0'))

        final_versions = version_windows(self.versions, major=1, minor=2, point=2)
        # 1 major version
        self.assertEqual(final_versions[1], {})
        # 2 minor versions
        self.assertEqual(len(final_versions[2]), 2)
        # 2 point versions
        self.assertEqual(len(final_versions[2][3]), 2)
        final_versions = version_windows(self.versions, major=1, minor=2, point=3)
        # 2 point versions
        self.assertEqual(len(final_versions[2][3]), 3)
Пример #15
0
 def supported_versions(self, flat=True):
     """
     Get the list of supported versions.
     Returns a list of version strings.
     """
     if not self.num_major or not self.num_minor or not self.num_point:
         return None
     versions = []
     for ver in self.versions.all():
         try:
             versions.append(BetterVersion(ver.verbose_name))
         except UnsupportedVersionError:
             # Probably a branch
             pass
     active_versions = version_windows(
         versions, major=self.num_major, minor=self.num_minor, point=self.num_point, flat=flat
     )
     version_strings = [v._string for v in active_versions]
     return version_strings
Пример #16
0
 def supported_versions(self, flat=True):
     """
     Get the list of supported versions.
     Returns a list of version strings.
     """
     if not self.num_major or not self.num_minor or not self.num_point:
         return None
     versions = []
     for ver in self.versions.all():
         try:
             versions.append(BetterVersion(ver.verbose_name))
         except UnsupportedVersionError:
             # Probably a branch
             pass
     active_versions = version_windows(
         versions,
         major=self.num_major,
         minor=self.num_minor,
         point=self.num_point,
         flat=flat,
     )
     version_strings = [v._string for v in active_versions]
     return version_strings