diff options
Diffstat (limited to 'tests/test_manifest_xml.py')
-rw-r--r-- | tests/test_manifest_xml.py | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py index 3f03272a..3d1fde96 100644 --- a/tests/test_manifest_xml.py +++ b/tests/test_manifest_xml.py | |||
@@ -1049,6 +1049,91 @@ class RemoveProjectElementTests(ManifestParseTestCase): | |||
1049 | self.assertTrue(found_proj1_path1) | 1049 | self.assertTrue(found_proj1_path1) |
1050 | self.assertTrue(found_proj2) | 1050 | self.assertTrue(found_proj2) |
1051 | 1051 | ||
1052 | def test_base_revision_checks_on_patching(self): | ||
1053 | manifest_fail_wrong_tag = self.getXmlManifest( | ||
1054 | """ | ||
1055 | <manifest> | ||
1056 | <remote name="default-remote" fetch="http://localhost" /> | ||
1057 | <default remote="default-remote" revision="tag.002" /> | ||
1058 | <project name="project1" path="tests/path1" /> | ||
1059 | <extend-project name="project1" revision="new_hash" base-rev="tag.001" /> | ||
1060 | </manifest> | ||
1061 | """ | ||
1062 | ) | ||
1063 | with self.assertRaises(error.ManifestParseError): | ||
1064 | manifest_fail_wrong_tag.ToXml() | ||
1065 | |||
1066 | manifest_fail_remove = self.getXmlManifest( | ||
1067 | """ | ||
1068 | <manifest> | ||
1069 | <remote name="default-remote" fetch="http://localhost" /> | ||
1070 | <default remote="default-remote" revision="refs/heads/main" /> | ||
1071 | <project name="project1" path="tests/path1" revision="hash1" /> | ||
1072 | <remove-project name="project1" base-rev="wrong_hash" /> | ||
1073 | </manifest> | ||
1074 | """ | ||
1075 | ) | ||
1076 | with self.assertRaises(error.ManifestParseError): | ||
1077 | manifest_fail_remove.ToXml() | ||
1078 | |||
1079 | manifest_fail_extend = self.getXmlManifest( | ||
1080 | """ | ||
1081 | <manifest> | ||
1082 | <remote name="default-remote" fetch="http://localhost" /> | ||
1083 | <default remote="default-remote" revision="refs/heads/main" /> | ||
1084 | <project name="project1" path="tests/path1" revision="hash1" /> | ||
1085 | <extend-project name="project1" revision="new_hash" base-rev="wrong_hash" /> | ||
1086 | </manifest> | ||
1087 | """ | ||
1088 | ) | ||
1089 | with self.assertRaises(error.ManifestParseError): | ||
1090 | manifest_fail_extend.ToXml() | ||
1091 | |||
1092 | manifest_fail_unknown = self.getXmlManifest( | ||
1093 | """ | ||
1094 | <manifest> | ||
1095 | <remote name="default-remote" fetch="http://localhost" /> | ||
1096 | <default remote="default-remote" revision="refs/heads/main" /> | ||
1097 | <project name="project1" path="tests/path1" /> | ||
1098 | <extend-project name="project1" revision="new_hash" base-rev="any_hash" /> | ||
1099 | </manifest> | ||
1100 | """ | ||
1101 | ) | ||
1102 | with self.assertRaises(error.ManifestParseError): | ||
1103 | manifest_fail_unknown.ToXml() | ||
1104 | |||
1105 | manifest_ok = self.getXmlManifest( | ||
1106 | """ | ||
1107 | <manifest> | ||
1108 | <remote name="default-remote" fetch="http://localhost" /> | ||
1109 | <default remote="default-remote" revision="refs/heads/main" /> | ||
1110 | <project name="project1" path="tests/path1" revision="hash1" /> | ||
1111 | <project name="project2" path="tests/path2" revision="hash2" /> | ||
1112 | <project name="project3" path="tests/path3" revision="hash3" /> | ||
1113 | <project name="project4" path="tests/path4" revision="hash4" /> | ||
1114 | |||
1115 | <remove-project name="project1" /> | ||
1116 | <remove-project name="project2" base-rev="hash2" /> | ||
1117 | <project name="project2" path="tests/path2" revision="new_hash2" /> | ||
1118 | <extend-project name="project3" base-rev="hash3" revision="new_hash3" /> | ||
1119 | <extend-project name="project3" base-rev="new_hash3" revision="newer_hash3" /> | ||
1120 | <remove-project path="tests/path4" base-rev="hash4" /> | ||
1121 | </manifest> | ||
1122 | """ | ||
1123 | ) | ||
1124 | found_proj2 = False | ||
1125 | found_proj3 = False | ||
1126 | for proj in manifest_ok.projects: | ||
1127 | if proj.name == "project2": | ||
1128 | found_proj2 = True | ||
1129 | if proj.name == "project3": | ||
1130 | found_proj3 = True | ||
1131 | self.assertNotEqual(proj.name, "project1") | ||
1132 | self.assertNotEqual(proj.name, "project4") | ||
1133 | self.assertTrue(found_proj2) | ||
1134 | self.assertTrue(found_proj3) | ||
1135 | self.assertTrue(len(manifest_ok.projects) == 2) | ||
1136 | |||
1052 | 1137 | ||
1053 | class ExtendProjectElementTests(ManifestParseTestCase): | 1138 | class ExtendProjectElementTests(ManifestParseTestCase): |
1054 | """Tests for <extend-project>.""" | 1139 | """Tests for <extend-project>.""" |