test_daklib_upload.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #! /usr/bin/env python3
  2. #
  3. # Copyright (C) 2018, Ansgar Burchardt <ansgar@debian.org>
  4. # License: GPL-2+
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. from base_test import DakTestCase
  19. import unittest
  20. import daklib.upload
  21. class DummySortableChanges(daklib.upload.Changes):
  22. def __init__(self, source, version, architectures, filename):
  23. self.changes = {
  24. 'Source': source,
  25. 'Version': version,
  26. 'Architecture': architectures,
  27. }
  28. self.filename = filename
  29. class TestSortableChanges(DakTestCase):
  30. def testEq(self):
  31. a = DummySortableChanges(
  32. 'source', '1.0-1', 'source all', 'source_1.0-1_amd64.changes')
  33. self.assertTrue(a == a)
  34. self.assertTrue(a <= a)
  35. self.assertTrue(a >= a)
  36. self.assertFalse(a < a)
  37. self.assertFalse(a > a)
  38. def testSourceDiffers1(self):
  39. a = DummySortableChanges(
  40. 'a', '1.0-1', 'all', 'a_1.0-1_amd64.changes')
  41. b = DummySortableChanges(
  42. 'b', '1.0-1', 'all', 'b_1.0-1_amd64.changes')
  43. self.assertTrue(a < b)
  44. self.assertFalse(a == b)
  45. def testSourceDiffers2(self):
  46. a = DummySortableChanges(
  47. 'a', '2.0-1', 'all', 'a_2.0-1_amd64.changes')
  48. b = DummySortableChanges(
  49. 'b', '1.0-1', 'all', 'b_1.0-1_amd64.changes')
  50. self.assertTrue(a < b)
  51. self.assertFalse(a == b)
  52. def testSourcefulSortsFirst(self):
  53. a = DummySortableChanges(
  54. 'a', '1.0-1', 'source powerpc', 'a_1.0-1_powerpc.changes')
  55. b = DummySortableChanges(
  56. 'a', '1.0-1', 'amd64', 'a_1.0-1_amd64.changes')
  57. self.assertTrue(a < b)
  58. self.assertFalse(a == b)