def test_ProtocolInterfaceType(): cp = ContextProtocols(IProtocols("localhost", "icmp")) cc = ContextConfig(IConfig("example.yaml")) cc.GetWorkingConfigClass(True) cp.configuration = cc.configuration if cp.protocols.Type == "ICMP": assert True pass
def test_ProtocolMSGoogle(): cc = ContextConfig(IConfig("example.yaml")) cc.GetWorkingConfigClass(True) cc.ReadConfig() cp = ContextProtocols(IProtocols("google.com", 'ICMP')) cp.GetWorkingClass(True) cp.Start() if cp.MS >= 1: assert True
def test_PassConfigToContext(): cc = ContextConfig(IConfig("example.yaml")) cc.GetWorkingConfigClass(True) cc.ReadConfig() cp = ContextProtocols(IProtocols("localhost", 'ICMP')) cp.GetWorkingClass(True) cp.configuration = cc.configuration cp.Start() if cp.protocols.configuration.nodes.__len__() >= 1: assert True
def test_ProtocolBadURL(): cp = ContextProtocols(IProtocols("www.google.com", "Http:Get")) #cc = ContextConfig(IConfig("example.yaml")) #cp.configuration = cc.configuration cp.GetWorkingClass(True) cp.Start() if cp.Status == "Online": assert True pass
def test_ProtocolMS(): #i = IProtocols("https://www.youtube.com", "HTTP:Get") #cp = ContextProtocols(i) #IConfig("example.yaml") cp = ContextProtocols(IProtocols("https://www.youtube.com", "Http:Get")) cp.GetWorkingClass(True) cp.Start() if cp.MS >= 0: assert True pass
def test_ProtocolMSLocalHost(): cc = ContextConfig(IConfig("example.yaml")) cc.GetWorkingConfigClass(True) cc.ReadConfig() cp = ContextProtocols(IProtocols("localhost",'ICMP')) cp.GetWorkingClass(True) cp.Start() if cp.MS >= 0: assert True pass
def test_ProtocolHttpsURL(): #sleep(5) #i = IProtocols("https://www.espn.com", "HTTP:GET") #IConfig("example.yaml") cp = ContextProtocols(IProtocols("https://www.espn.com", "Http:Get")) #cp = ContextProtocols(i) cp.GetWorkingClass(True) cp.Start() if cp.Status == "Online": assert True pass
def test_ProtocolStatus(): #i = IProtocols("localhost", "ICMP") #cp = ContextProtocols(i) cc = ContextConfig(IConfig("example.yaml")) cc.GetWorkingConfigClass(True) cc.ReadConfig() cp = ContextProtocols(IProtocols("localhost", "icmp")) cp.GetWorkingClass(True) cp.Start() if cp.Status == "Online": assert True pass
def test_ProtocolHttpURL(): """ This will test to confirm tht we can accept a normal URI. """ #sleep(5) #i = IProtocols("https://www.gmail.com", "HTTP:GET") #IConfig("example.yaml") cp = ContextProtocols(IProtocols("https://www.gmail.com", "Http:Get")) cp.GetWorkingClass(True) cp.Start() if cp.Status == "Online": assert True pass
def test_ProtocolInterfaceAddress(): #IConfig("example.yaml") cp = ContextProtocols(IProtocols("localhost", "Http:Get")) if cp.protocols.URI == "localhost": assert True pass
def test_ProtocolInterfaceType(): #cc = ContextConfig(IConfig("example.yaml")) cp = ContextProtocols(IProtocols("localhost", "HTTP:Get")) if cp.protocols.Type == "HTTP:GET": assert True pass
def test_ProtocolInterfaceAddress(): cp = ContextProtocols(IProtocols("localhost", "icmp")) cc = ContextConfig(IConfig("example.yaml")) cc.GetWorkingConfigClass(True) if cp.protocols.URI == "localhost": assert True pass
def __Worker(self) -> None: self.__ReadConfig__() report = self.__configuration__.nodes requirement: bool = True for node in report: if requirement == True: np = node.protocol.lower() if np == "icmp": cp = ContextProtocols(IProtocols(node.address, 'ICMP')) cp.GetWorkingClass(True) cp.configuration = self.__configuration__ cp.Start() elif np == "http:get": cp = ContextProtocols(IProtocols(node.address, "HTTP:GET")) cp.GetWorkingClass(True) cp.Start() elif np == "http:post": cp = ContextProtocols(IProtocols(node.address, "Http:Post")) cp.GetWorkingClass(True) cp.Start() else: raise InvalidProtocol( f"{node.protocol} is invalid. Use ICMP, HTTP:Get, HTTP:POST." ) node.ms = cp.MS node.status = cp.Status if node.required == True and node.status == "Offline": requirement = False else: node.status = "Offline" # Work has been finished #Copy our local version to the global scope self.LastRefresh = datetime.datetime.now() self.report = report