def test_comparison(self): """Validate we can compare VersionSplitPackageOrder together.""" inst1 = NullPackageOrder() inst2 = NullPackageOrder() self.assertTrue(inst1 == inst2) # __eq__ positive self.assertFalse(inst1 == "wrong_type") # __eq__ negative (wrong type) self.assertTrue(inst1 != "wrong_type") # __ne__ positive (wrong type) self.assertFalse(inst1 != inst2) # __ne__ negative
def test_pod(self): """Validate we can save and load a PerFamilyOrder to it's pod representation.""" self._test_pod( PerFamilyOrder(order_dict={'foo': NullPackageOrder()}, default_order=NullPackageOrder())) # No default_order self._test_pod(PerFamilyOrder(order_dict={'foo': NullPackageOrder()}))
def test_9(self): """test package orderers.""" from rez.package_order import NullPackageOrder, PerFamilyOrder, \ VersionSplitPackageOrder, TimestampPackageOrder, SortedOrder, \ to_pod, from_pod def _test(orderer, package_name, expected_order): it = iter_packages(package_name) descending = sorted(it, key=lambda x: x.version, reverse=True) pod = to_pod(orderer) orderer2 = from_pod(pod) for orderer_ in (orderer, orderer2): ordered = orderer_.reorder(descending) result = [str(x.version) for x in ordered] self.assertEqual(result, expected_order) null_orderer = NullPackageOrder() split_orderer = VersionSplitPackageOrder(Version("2.6.0")) # after v1.1.0 and before v1.1.1 timestamp_orderer = TimestampPackageOrder(timestamp=3001, rank=3) # after v2.1.0 and before v2.1.5 timestamp2_orderer = TimestampPackageOrder(timestamp=7001, rank=3) expected_null_result = ["7", "6", "5"] expected_split_result = ["2.6.0", "2.5.2", "2.7.0", "2.6.8"] expected_timestamp_result = [ "1.1.1", "1.1.0", "1.0.6", "1.0.5", "1.2.0", "2.0.0", "2.1.5", "2.1.0" ] expected_timestamp2_result = [ "2.1.5", "2.1.0", "2.0.0", "1.2.0", "1.1.1", "1.1.0", "1.0.6", "1.0.5" ] _test(null_orderer, "pysplit", expected_null_result) _test(split_orderer, "python", expected_split_result) _test(timestamp_orderer, "timestamped", expected_timestamp_result) _test(timestamp2_orderer, "timestamped", expected_timestamp2_result) fam_orderer = PerFamilyOrder( order_dict=dict(pysplit=null_orderer, python=split_orderer, timestamped=timestamp_orderer), default_order=SortedOrder(descending=False)) _test(fam_orderer, "pysplit", expected_null_result) _test(fam_orderer, "python", expected_split_result) _test(fam_orderer, "timestamped", expected_timestamp_result) _test(fam_orderer, "pymum", ["1", "2", "3"])
def test_reorder(self): """Test ordering.""" expected_null_result = ["7", "6", "5"] expected_split_result = ["2.6.0", "2.5.2", "2.7.0", "2.6.8"] expected_timestamp_result = [ "1.1.1", "1.1.0", "1.0.6", "1.0.5", "1.2.0", "2.0.0", "2.1.5", "2.1.0" ] orderer = PerFamilyOrder(order_dict=dict( pysplit=NullPackageOrder(), python=VersionSplitPackageOrder(Version("2.6.0")), timestamped=TimestampPackageOrder(timestamp=3001, rank=3)), default_order=SortedOrder(descending=False)) self._test_reorder(orderer, "pysplit", expected_null_result) self._test_reorder(orderer, "python", expected_split_result) self._test_reorder(orderer, "timestamped", expected_timestamp_result) self._test_reorder(orderer, "pymum", ["1", "2", "3"])
def test_comparison(self): """Validate we can compare PerFamilyOrder.""" inst1 = PerFamilyOrder(order_dict={'foo': NullPackageOrder()}, default_order=NullPackageOrder()) inst2 = PerFamilyOrder(order_dict={'foo': NullPackageOrder()}, default_order=NullPackageOrder()) inst3 = PerFamilyOrder(order_dict={'bar': NullPackageOrder()}, default_order=NullPackageOrder()) inst4 = PerFamilyOrder(order_dict={'foo': NullPackageOrder()}, default_order=None) self.assertTrue(inst1 == inst2) # __eq__ positive self.assertFalse( inst1 == inst3) # __eq__ negative (different order dict) self.assertFalse( inst1 == inst4) # __eq__ negative (different default_order) self.assertTrue( inst1 != inst3) # __ne__ positive (different order dict) self.assertTrue( inst1 != inst4) # __ne__ positive (different default order) self.assertFalse(inst1 != inst2) # __ne__ negative
def test_sha1(self): """Validate we can get a sha1 hash. """ self.assertEqual('bf7c2fa4e6bd198c02adeea2c3a382cf57242051', NullPackageOrder().sha1)
def test_pod(self): """Validate we can save and load a VersionSplitPackageOrder to it's pod representation.""" self._test_pod(NullPackageOrder())
def test_repr(self): """Validate we can represent a VersionSplitPackageOrder as a string.""" self.assertEqual("NullPackageOrder({})", repr(NullPackageOrder()))
def test_reorder_no_packages(self): """Validate ordering for a family with no packages.""" orderer = PerFamilyOrder(order_dict=dict( missing_package=NullPackageOrder())) self._test_reorder(orderer, "missing_package", [])