Tests for cross-distro fallback when a manpage isn't in the preferred distro.
| 220 | |
| 221 | |
| 222 | class TestDistroFallback(unittest.TestCase): |
| 223 | """Tests for cross-distro fallback when a manpage isn't in the preferred distro.""" |
| 224 | |
| 225 | _RAW = RawManpage( |
| 226 | source_text=".TH TEST 1", |
| 227 | generated_at=datetime.datetime(2025, 1, 1, tzinfo=datetime.timezone.utc), |
| 228 | generator="test", |
| 229 | ) |
| 230 | |
| 231 | def _make_app(self, store): |
| 232 | app = create_app() |
| 233 | _use_store(app, store) |
| 234 | app.config["TESTING"] = True |
| 235 | return app |
| 236 | |
| 237 | def _store_with_ubuntu_and_arch(self) -> Store: |
| 238 | """Store where 'uonly' is ubuntu-only, 'aonly' is arch-only, |
| 239 | and 'both' exists in both distros.""" |
| 240 | store = Store.create(":memory:") |
| 241 | store.add_manpage( |
| 242 | ParsedManpage( |
| 243 | source="ubuntu/26.04/1/uonly.1.gz", |
| 244 | name="uonly", |
| 245 | synopsis="ubuntu only", |
| 246 | options=[Option(text="-u desc", short=["-u"], long=[])], |
| 247 | aliases=[("uonly", 10)], |
| 248 | ), |
| 249 | self._RAW, |
| 250 | ) |
| 251 | store.add_manpage( |
| 252 | ParsedManpage( |
| 253 | source="arch/latest/1/aonly.1.gz", |
| 254 | name="aonly", |
| 255 | synopsis="arch only", |
| 256 | options=[Option(text="-a desc", short=["-a"], long=[])], |
| 257 | aliases=[("aonly", 10)], |
| 258 | ), |
| 259 | self._RAW, |
| 260 | ) |
| 261 | store.add_manpage( |
| 262 | ParsedManpage( |
| 263 | source="ubuntu/26.04/1/both.1.gz", |
| 264 | name="both", |
| 265 | synopsis="both ubuntu", |
| 266 | options=[Option(text="-b desc", short=["-b"], long=[])], |
| 267 | aliases=[("both", 10)], |
| 268 | ), |
| 269 | self._RAW, |
| 270 | ) |
| 271 | store.add_manpage( |
| 272 | ParsedManpage( |
| 273 | source="arch/latest/1/both.1.gz", |
| 274 | name="both", |
| 275 | synopsis="both arch", |
| 276 | options=[Option(text="-b desc", short=["-b"], long=[])], |
| 277 | aliases=[("both", 10)], |
| 278 | ), |
| 279 | self._RAW, |