Skip to content

Commit

Permalink
Add: Unit tests for Package & Reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
n-thumann committed Feb 13, 2023
1 parent f6ee66a commit f55a1bc
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions tests/standalone_plugins/changed_packages/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from argparse import ArgumentError
from unittest import TestCase

from troubadix.standalone_plugins.changed_packages.package import (
Expand All @@ -30,25 +31,36 @@ def test_from_cli_argument(self):
Reasons.from_cli_argument("dropped-architecture"),
)

def test_from_cli_argument_not_okay(self):
with self.assertRaises(ArgumentError):
Reasons.from_cli_argument("foo")

def test_str(self):
self.assertEqual(str(Reasons.ADDED_EPOCH), "added-epoch")


class PackageTestCase(TestCase):
def test_lt(self):
def test_lt_by_name(self):
package = Package("a-foo", "1.2.3", "DEB11")
other_package = Package("b-foo", "1.2.3", "DEB11")

self.assertLess(package, other_package)

def test_lt_by_version(self):
package = Package("foo", "1.2.3", "DEB11")
other_package = Package("foo", "2.2.3", "DEB11")

print(
(package.release, package.name, package.version)
< (other_package.release, other_package.name, other_package.version)
)

self.assertLess(package, other_package)

def test_lt_by_release(self):
package = Package("foo", "1.2.3", "DEB10")
other_package = Package("foo", "1.2.3", "DEB11")

self.assertLess(package, other_package)

def test_lt_nothing_in_common(self):
package = Package("foo", "1.2.3", "DEB10")
other_package = Package("foo", "1.2.3", "DEB10")

self.assertFalse(package < other_package)
self.assertFalse(package > other_package)

0 comments on commit f55a1bc

Please sign in to comment.