API: Apprise() Disabled Plugin States
()
| 1395 | |
| 1396 | |
| 1397 | def test_apprise_disabled_plugins(): |
| 1398 | """ |
| 1399 | API: Apprise() Disabled Plugin States |
| 1400 | |
| 1401 | """ |
| 1402 | # Ensure there are no other drives loaded |
| 1403 | N_MGR.unload_modules(disable_native=True) |
| 1404 | assert len(N_MGR) == 0 |
| 1405 | |
| 1406 | class TestDisabled01Notification(NotifyBase): |
| 1407 | """This class is used to test a pre-disabled state.""" |
| 1408 | |
| 1409 | # Just flat out disable our service |
| 1410 | enabled = False |
| 1411 | |
| 1412 | # we'll use this as a key to make our service easier to find |
| 1413 | # in the next part of the testing |
| 1414 | service_name = "na01" |
| 1415 | |
| 1416 | def notify(self, **kwargs): |
| 1417 | # Pretend everything is okay (so we don't break other tests) |
| 1418 | return True |
| 1419 | |
| 1420 | N_MGR["na01"] = TestDisabled01Notification |
| 1421 | |
| 1422 | class TestDisabled02Notification(NotifyBase): |
| 1423 | """This class is used to test a post-disabled state.""" |
| 1424 | |
| 1425 | # we'll use this as a key to make our service easier to find |
| 1426 | # in the next part of the testing |
| 1427 | service_name = "na02" |
| 1428 | |
| 1429 | def __init__(self, *args, **kwargs): |
| 1430 | super().__init__(**kwargs) |
| 1431 | |
| 1432 | # enable state changes **AFTER** we initialize |
| 1433 | self.enabled = False |
| 1434 | |
| 1435 | def notify(self, **kwargs): |
| 1436 | # Pretend everything is okay (so we don't break other tests) |
| 1437 | return True |
| 1438 | |
| 1439 | N_MGR["na02"] = TestDisabled02Notification |
| 1440 | |
| 1441 | # Create our Apprise instance |
| 1442 | a = Apprise() |
| 1443 | |
| 1444 | result = a.details(lang="ca-en", show_disabled=True) |
| 1445 | assert isinstance(result, dict) |
| 1446 | assert "schemas" in result |
| 1447 | assert len(result["schemas"]) == 2 |
| 1448 | |
| 1449 | # our na01 is disabled right from the get-go |
| 1450 | entry = next( |
| 1451 | (x for x in result["schemas"] if x["service_name"] == "na01"), None |
| 1452 | ) |
| 1453 | assert entry is not None |
| 1454 | assert entry["enabled"] is False |
nothing calls this directly
no test coverage detected
searching dependent graphs…