def test_tagging(self): o = SimpleRoutablePDU(self.connector, self.PDU, self.user, datetime.now()) self.assertRaises(InvalidTagError, o.addTag, 'anything') self.assertRaises(InvalidTagError, o.hasTag, 'anything') self.assertRaises(InvalidTagError, o.removeTag, 'anything') o.addTag(23) self.assertTrue(o.hasTag(23)) self.assertFalse(o.hasTag(30)) self.assertRaises(TagNotFoundError, o.removeTag, 30) self.assertEqual([23], o.getTags()) o.flushTags() self.assertEqual([], o.getTags())
def test_standard(self): o = SimpleRoutablePDU(self.connector, self.PDU, self.user, datetime.now()) self.assertEqual(o.pdu, self.PDU) self.assertEqual(o.connector.cid, self.connector.cid) self.assertEqual(o.user.uid, self.user.uid) self.assertEqual(o.user.group.gid, self.user.group.gid) self.assertNotEqual(o.datetime, None)
def test_tagging(self): o = SimpleRoutablePDU(self.connector, self.PDU, self.user, datetime.now()) self.assertRaises(InvalidTagError, o.addTag, "anything") self.assertRaises(InvalidTagError, o.hasTag, "anything") self.assertRaises(InvalidTagError, o.removeTag, "anything") o.addTag(23) self.assertTrue(o.hasTag(23)) self.assertFalse(o.hasTag(30)) self.assertRaises(TagNotFoundError, o.removeTag, 30) self.assertEqual([23], o.getTags()) o.flushTags() self.assertEqual([], o.getTags())
def setUp(self): FilterTestCase.setUp(self) # Redefine routable with a fixed datetime routableDatetime = datetime.datetime(year = 2012, month = 1, day = 1, hour = 6, minute = 0, second = 0) self.routable = SimpleRoutablePDU(self.connector, self.PDU, self.user, routableDatetime) threeHoursEarlier = datetime.time(hour=3, minute=0) threeHoursLater = datetime.time(hour=9, minute=0) self.f = self._filter([threeHoursEarlier, threeHoursLater])
def setUp(self): self.connector = Connector('abc') self.PDU = SubmitSM( source_addr='20203060', destination_addr='20203060', short_message='hello world', ) self.group = Group(100) self.user = User(1, self.group, 'username', 'password') self.routable = SimpleRoutablePDU(self.connector, self.PDU, self.user)
def test_message_payload(self): """Related to #380 Consider 'message_payload' when there is no 'short_message' parameter """ PDU_message_payload = SubmitSM( source_addr='20203060', destination_addr='20203060', message_payload='hello world', ) del PDU_message_payload.params['short_message'] _routable = SimpleRoutablePDU(self.connector, PDU_message_payload, self.user) self.assertTrue(self.f.match(_routable))
def setUp(self, authentication=False): # Initiating config objects without any filename # will lead to setting defaults and that's what we # need to run the tests self.InterceptorPBConfigInstance = InterceptorPBConfig() self.InterceptorPBConfigInstance.authentication = authentication # Launch the interceptor pb server pbRoot = InterceptorPB() pbRoot.setConfig(self.InterceptorPBConfigInstance) p = portal.Portal(JasminPBRealm(pbRoot)) if not authentication: p.registerChecker(AllowAnonymousAccess()) else: c = InMemoryUsernamePasswordDatabaseDontUse() c.addUser('test_user', md5('test_password').digest()) p.registerChecker(c) jPBPortalRoot = JasminPBPortalRoot(p) self.IPBServer = reactor.listenTCP(0, pb.PBServerFactory(jPBPortalRoot)) self.ipbPort = self.IPBServer.getHost().port # Test fixtures self.SubmitSMPDU = SubmitSM( source_addr='20203060', destination_addr='20203060', short_message='MT hello world', ) self.DeliverSMPDU = DeliverSM( source_addr='20203060', destination_addr='20203060', short_message='MO hello world', ) self.connector = Connector('abc') self.user = User(1, Group(100), 'username', 'password') # Routables fixtures self.routable_simple = SimpleRoutablePDU(self.connector, self.SubmitSMPDU, self.user, datetime.now()) # Scripts fixtures self.script_generic = InterceptorScript( 'somevar = "something in MOIS"') self.script_3_second = InterceptorScript('import time;time.sleep(3)') self.script_syntax_error = InterceptorScript('somevar = sssss') self.script_http_status = InterceptorScript('http_status = 404') self.script_smpp_status = InterceptorScript('smpp_status = 64')
def test_tagging(self): o = SimpleRoutablePDU(self.connector, self.PDU, self.user, datetime.now()) _any_object = object() self.assertRaises(InvalidTagError, o.addTag, _any_object) self.assertRaises(InvalidTagError, o.hasTag, _any_object) self.assertRaises(InvalidTagError, o.removeTag, _any_object) # Integer tags o.addTag(23) self.assertTrue(o.hasTag(23)) self.assertFalse(o.hasTag(30)) self.assertRaises(TagNotFoundError, o.removeTag, 30) self.assertEqual(['23'], o.getTags()) o.flushTags() self.assertEqual([], o.getTags()) # String tags o.addTag('23') self.assertTrue(o.hasTag('23')) self.assertFalse(o.hasTag('30')) self.assertRaises(TagNotFoundError, o.removeTag, '30') self.assertEqual(['23'], o.getTags()) o.flushTags() self.assertEqual([], o.getTags()) # Mixed tags o.addTag('23') o.addTag(24) self.assertEqual(['23', '24'], o.getTags()) o.flushTags()
def test_without_datetime(self): o = SimpleRoutablePDU(self.connector, self.PDU, self.user) self.assertNotEqual(o.datetime, None)
def test_tagging(self): o = SimpleRoutablePDU(self.connector, self.PDU, self.user, datetime.now()) _any_object = object() self.assertRaises(InvalidTagError, o.addTag, _any_object) self.assertRaises(InvalidTagError, o.hasTag, _any_object) self.assertRaises(InvalidTagError, o.removeTag, _any_object) # Integer tags o.addTag(23) self.assertTrue(o.hasTag(23)) self.assertFalse(o.hasTag(30)) self.assertRaises(TagNotFoundError, o.removeTag, 30) self.assertEqual(['23'], o.getTags()) o.flushTags() self.assertEqual([], o.getTags()) # String tags o.addTag('23') self.assertTrue(o.hasTag('23')) self.assertFalse(o.hasTag('30')) self.assertRaises(TagNotFoundError, o.removeTag, '30') self.assertEqual(['23'], o.getTags()) o.flushTags() self.assertEqual([], o.getTags()) # Mixed tags o.addTag('23') o.addTag(24) self.assertEqual(['23', '24'], o.getTags()) o.flushTags()