Test the element
(self)
| 154 | self.assertIsString(pot_fragment("Foo", 'bar.xml')) |
| 155 | |
| 156 | def test_var(self): |
| 157 | """Test the <var> element""" |
| 158 | xml_str = r""" |
| 159 | <cleaner id="testvar"> |
| 160 | <label>cleaner label</label> |
| 161 | <description>cleaner description</description> |
| 162 | <var name="basepath"> |
| 163 | <value>%%LocalAppData%%\FooDoesNotExist</value> |
| 164 | <value>~/.config/FooDoesNotExist</value> |
| 165 | <value>{tempdir}/a</value> |
| 166 | <value>{tempdir}/b</value> |
| 167 | </var> |
| 168 | <option id="option1"> |
| 169 | <label>option1 label</label> |
| 170 | <description>option1 description</description> |
| 171 | <action search="file" command="delete" path="$$basepath$$/test.log" /> |
| 172 | </option> |
| 173 | </cleaner> |
| 174 | """.format(**{'tempdir': self.tempdir}) |
| 175 | # write XML cleaner |
| 176 | cml_path = os.path.join(self.tempdir, 'test.xml') |
| 177 | self.write_file(cml_path, xml_str.encode(sys.getdefaultencoding())) |
| 178 | |
| 179 | # create two canaries |
| 180 | test_log_path_a = os.path.join(self.tempdir, 'a', 'test.log') |
| 181 | test_log_path_b = os.path.join(self.tempdir, 'b', 'test.log') |
| 182 | common.touch_file(test_log_path_a) |
| 183 | common.touch_file(test_log_path_b) |
| 184 | self.assertExists(test_log_path_a) |
| 185 | self.assertExists(test_log_path_b) |
| 186 | |
| 187 | # parse XML to XML cleaner instance |
| 188 | xmlc = CleanerML(cml_path) |
| 189 | self.assertIsInstance(xmlc, CleanerML) |
| 190 | self.assertIsInstance(xmlc.cleaner, Cleaner.Cleaner) |
| 191 | self.assertTrue(xmlc.cleaner.is_usable()) |
| 192 | |
| 193 | # run preview |
| 194 | self.run_all(xmlc, False) |
| 195 | self.assertExists(test_log_path_a) |
| 196 | self.assertExists(test_log_path_b) |
| 197 | |
| 198 | # really delete |
| 199 | self.run_all(xmlc, True) |
| 200 | self.assertNotExists(test_log_path_a) |
| 201 | self.assertNotExists(test_log_path_b) |
nothing calls this directly
no test coverage detected