749
746
raise NotImplementedError()
752
class Enable(Property):
749
class Enable(PropertySetter):
753
750
propname = "Enabled"
754
751
value_to_set = dbus.Boolean(True)
757
class Disable(Property):
754
class Disable(PropertySetter):
758
755
propname = "Enabled"
759
756
value_to_set = dbus.Boolean(False)
762
class BumpTimeout(Property):
759
class BumpTimeout(PropertySetter):
763
760
propname = "LastCheckedOK"
764
761
value_to_set = ""
767
class StartChecker(Property):
768
propname = "CheckerRunning"
769
value_to_set = dbus.Boolean(True)
772
class StopChecker(Property):
773
propname = "CheckerRunning"
774
value_to_set = dbus.Boolean(False)
777
class ApproveByDefault(Property):
778
propname = "ApprovedByDefault"
779
value_to_set = dbus.Boolean(True)
782
class DenyByDefault(Property):
783
propname = "ApprovedByDefault"
784
value_to_set = dbus.Boolean(False)
787
class PropertyValue(Property):
788
"Abstract class for Property recieving a value as argument"
764
class StartChecker(PropertySetter):
765
propname = "CheckerRunning"
766
value_to_set = dbus.Boolean(True)
769
class StopChecker(PropertySetter):
770
propname = "CheckerRunning"
771
value_to_set = dbus.Boolean(False)
774
class ApproveByDefault(PropertySetter):
775
propname = "ApprovedByDefault"
776
value_to_set = dbus.Boolean(True)
779
class DenyByDefault(PropertySetter):
780
propname = "ApprovedByDefault"
781
value_to_set = dbus.Boolean(False)
784
class PropertySetterValue(PropertySetter):
785
"""Abstract class for PropertySetter recieving a value as
786
constructor argument instead of a class attribute."""
789
787
def __init__(self, value):
790
788
self.value_to_set = value
793
class SetChecker(PropertyValue):
791
class SetChecker(PropertySetterValue):
794
792
propname = "Checker"
797
class SetHost(PropertyValue):
795
class SetHost(PropertySetterValue):
798
796
propname = "Host"
801
class SetSecret(PropertyValue):
799
class SetSecret(PropertySetterValue):
802
800
propname = "Secret"
826
825
self._vts = int(round(value.total_seconds() * 1000))
829
class SetTimeout(MillisecondsPropertyValueArgument):
828
class SetTimeout(PropertySetterValueMilliseconds):
830
829
propname = "Timeout"
833
class SetExtendedTimeout(MillisecondsPropertyValueArgument):
832
class SetExtendedTimeout(PropertySetterValueMilliseconds):
834
833
propname = "ExtendedTimeout"
837
class SetInterval(MillisecondsPropertyValueArgument):
836
class SetInterval(PropertySetterValueMilliseconds):
838
837
propname = "Interval"
841
class SetApprovalDelay(MillisecondsPropertyValueArgument):
840
class SetApprovalDelay(PropertySetterValueMilliseconds):
842
841
propname = "ApprovalDelay"
845
class SetApprovalDuration(MillisecondsPropertyValueArgument):
844
class SetApprovalDuration(PropertySetterValueMilliseconds):
846
845
propname = "ApprovalDuration"
1727
1726
self.command().run(clients, self.bus)
1730
class TestEnableCmd(TestPropertyCmd):
1729
class TestEnableCmd(TestPropertySetterCmd):
1731
1730
command = command.Enable
1732
1731
propname = "Enabled"
1733
1732
values_to_set = [dbus.Boolean(True)]
1736
class TestDisableCmd(TestPropertyCmd):
1735
class TestDisableCmd(TestPropertySetterCmd):
1737
1736
command = command.Disable
1738
1737
propname = "Enabled"
1739
1738
values_to_set = [dbus.Boolean(False)]
1742
class TestBumpTimeoutCmd(TestPropertyCmd):
1741
class TestBumpTimeoutCmd(TestPropertySetterCmd):
1743
1742
command = command.BumpTimeout
1744
1743
propname = "LastCheckedOK"
1745
1744
values_to_set = [""]
1748
class TestStartCheckerCmd(TestPropertyCmd):
1747
class TestStartCheckerCmd(TestPropertySetterCmd):
1749
1748
command = command.StartChecker
1750
1749
propname = "CheckerRunning"
1751
1750
values_to_set = [dbus.Boolean(True)]
1754
class TestStopCheckerCmd(TestPropertyCmd):
1753
class TestStopCheckerCmd(TestPropertySetterCmd):
1755
1754
command = command.StopChecker
1756
1755
propname = "CheckerRunning"
1757
1756
values_to_set = [dbus.Boolean(False)]
1760
class TestApproveByDefaultCmd(TestPropertyCmd):
1759
class TestApproveByDefaultCmd(TestPropertySetterCmd):
1761
1760
command = command.ApproveByDefault
1762
1761
propname = "ApprovedByDefault"
1763
1762
values_to_set = [dbus.Boolean(True)]
1766
class TestDenyByDefaultCmd(TestPropertyCmd):
1765
class TestDenyByDefaultCmd(TestPropertySetterCmd):
1767
1766
command = command.DenyByDefault
1768
1767
propname = "ApprovedByDefault"
1769
1768
values_to_set = [dbus.Boolean(False)]
1772
class TestPropertyValueCmd(TestPropertyCmd):
1773
"""Abstract class for tests of PropertyValueCmd classes"""
1771
class TestPropertySetterValueCmd(TestPropertySetterCmd):
1772
"""Abstract class for tests of PropertySetterValueCmd classes"""
1775
1774
def runTest(self):
1776
if type(self) is TestPropertyValueCmd:
1775
if type(self) is TestPropertySetterValueCmd:
1778
return super(TestPropertyValueCmd, self).runTest()
1777
return super(TestPropertySetterValueCmd, self).runTest()
1780
1779
def run_command(self, value, clients):
1781
1780
self.command(value).run(clients, self.bus)
1784
class TestSetCheckerCmd(TestPropertyValueCmd):
1783
class TestSetCheckerCmd(TestPropertySetterValueCmd):
1785
1784
command = command.SetChecker
1786
1785
propname = "Checker"
1787
1786
values_to_set = ["", ":", "fping -q -- %s"]
1790
class TestSetHostCmd(TestPropertyValueCmd):
1789
class TestSetHostCmd(TestPropertySetterValueCmd):
1791
1790
command = command.SetHost
1792
1791
propname = "Host"
1793
1792
values_to_set = ["192.0.2.3", "client.example.org"]
1796
class TestSetSecretCmd(TestPropertyValueCmd):
1795
class TestSetSecretCmd(TestPropertySetterValueCmd):
1797
1796
command = command.SetSecret
1798
1797
propname = "Secret"
1799
1798
values_to_set = [io.BytesIO(b""),