def _NewSession(self, reason): if not self.session: self._CancelSessionRetries() self.event_queue.appendleft((reason, None)) self.session = cwmp_session.CwmpSession( acs_url=self.cpe_management_server.URL, ioloop=self.ioloop) self.Run()
def testActive(self): cs = cwmp_session.CwmpSession('') cs.state_update(sent_inform=True) self.assertFalse(cs.inform_required()) self.assertTrue(cs.request_allowed()) self.assertTrue(cs.response_allowed()) # should be no change cs.state_update(sent_inform=True) self.assertFalse(cs.inform_required()) self.assertTrue(cs.request_allowed()) self.assertTrue(cs.response_allowed()) cs.state_update(acs_to_cpe_empty=True) self.assertFalse(cs.inform_required()) self.assertTrue(cs.request_allowed()) self.assertTrue(cs.response_allowed()) # transition to ONHOLD cs.state_update(on_hold=True) self.assertFalse(cs.inform_required()) self.assertFalse(cs.request_allowed()) self.assertTrue(cs.response_allowed()) # transition back to ACTIVE cs.state_update(on_hold=False) self.assertFalse(cs.inform_required()) self.assertTrue(cs.request_allowed()) self.assertTrue(cs.response_allowed()) # transition to NOMORE cs.state_update(cpe_to_acs_empty=True) self.assertFalse(cs.inform_required()) self.assertFalse(cs.request_allowed()) self.assertTrue(cs.response_allowed())
def testOnHold(self): cs = cwmp_session.CwmpSession('') cs.state_update(sent_inform=True) cs.state_update(on_hold=True) self.assertFalse(cs.inform_required()) self.assertFalse(cs.request_allowed()) self.assertTrue(cs.response_allowed()) # No change cs.state_update(on_hold=True) self.assertFalse(cs.inform_required()) self.assertFalse(cs.request_allowed()) self.assertTrue(cs.response_allowed()) cs.state_update(sent_inform=True) self.assertFalse(cs.inform_required()) self.assertFalse(cs.request_allowed()) self.assertTrue(cs.response_allowed()) cs.state_update(cpe_to_acs_empty=True) self.assertFalse(cs.inform_required()) self.assertFalse(cs.request_allowed()) self.assertTrue(cs.response_allowed()) cs.state_update(acs_to_cpe_empty=True) self.assertFalse(cs.inform_required()) self.assertFalse(cs.request_allowed()) self.assertTrue(cs.response_allowed()) # back to ACTIVE cs.state_update(on_hold=False) self.assertFalse(cs.inform_required()) self.assertTrue(cs.request_allowed()) self.assertTrue(cs.response_allowed())
def testDone(self): cs = cwmp_session.CwmpSession('') cs.state_update(sent_inform=True) cs.state_update(cpe_to_acs_empty=True) cs.state_update(acs_to_cpe_empty=True) self.assertFalse(cs.inform_required()) self.assertFalse(cs.request_allowed()) self.assertFalse(cs.response_allowed()) cs.state_update(sent_inform=True) self.assertFalse(cs.inform_required()) self.assertFalse(cs.request_allowed()) self.assertFalse(cs.response_allowed()) cs.state_update(cpe_to_acs_empty=True) self.assertFalse(cs.inform_required()) self.assertFalse(cs.request_allowed()) self.assertFalse(cs.response_allowed()) cs.state_update(acs_to_cpe_empty=True) self.assertFalse(cs.inform_required()) self.assertFalse(cs.request_allowed()) self.assertFalse(cs.response_allowed()) cs.state_update(sent_inform=True) self.assertFalse(cs.inform_required()) self.assertFalse(cs.request_allowed()) self.assertFalse(cs.response_allowed())
def _SessionWaitTimer(self): """Handler for the CWMP Retry timer, to start a new session.""" self.start_session_timeout = None self.session = cwmp_session.CwmpSession( acs_url=self.cpe_management_server.URL, ioloop=self.ioloop) self.Run()