Example #1
0
 def setUp(self):
   self.iopoll = IOPoll()
   self.iopoll.open()
   self.client = RaleighClient()
   self.client.REPLY_MAX_WAIT = 3
   self.client.connect(self.RALEIGH_HOST, self.RALEIGH_PORT)
   if isinstance(self.client, IOPollEntity):
     self.iopoll.add(self.client)
   self.objects = {}
Example #2
0
class RaleighTestCase(unittest.TestCase):
  RALEIGH_HOST = '127.0.0.1'
  RALEIGH_PORT = 11215
  REMOVE_OBJECTS = True

  def setUp(self):
    self.iopoll = IOPoll()
    self.iopoll.open()
    self.client = RaleighClient()
    self.client.REPLY_MAX_WAIT = 3
    self.client.connect(self.RALEIGH_HOST, self.RALEIGH_PORT)
    if isinstance(self.client, IOPollEntity):
      self.iopoll.add(self.client)
    self.objects = {}

  def tearDown(self):
    try:
      if self.REMOVE_OBJECTS:
        for oid in self.objects:
          self.removeObject(oid)
      if isinstance(self.client, IOPollEntity):
        self.iopoll.remove(self.client)
      self.client.close()
    finally:
      self.iopoll.close()

  def generateName(self):
    return str(uuid1())

  def createObject(self, object_type):
    name = self.generateName()
    data = self.client.semantic_create(name, object_type)
    oid = data['oid']
    self.objects[oid] = name
    return oid

  def removeObject(self, oid):
    name = self.objects[oid]
    self.client.semantic_delete(name)