Пример #1
0
 def create_definition(self, definition_id, definition_type, executable,
                       name=None, description=None):
     validate_definition_id(definition_id)
     definition = ProcessDefinitionRecord.new(definition_id,
         definition_type, executable, name=name, description=description)
     log.debug("creating definition %s" % definition)
     self.store.add_definition(definition)
Пример #2
0
    def test_not_unicode(self):
        d1 = ProcessDefinitionRecord.new("d1", "t1", "notepad.exe", "proc1")
        self.store.add_definition(d1)
        got_d1 = self.store.get_definition("d1")

        # ensure strings don't come back as unicode
        self.assertIsInstance(got_d1.definition_id, str)
        self.assertIsInstance(got_d1.name, str)
Пример #3
0
    def test_add_update_remove_definition(self):

        d1 = ProcessDefinitionRecord.new("d1", "t1", "notepad.exe", "proc1")
        d2 = ProcessDefinitionRecord.new("d2", "t2", "cat", "proc2")
        d3 = ProcessDefinitionRecord.new("d3", "t3", "cat" * 2000000, "proc3")

        self.store.add_definition(d1)
        self.store.add_definition(d2)
        if self.__class__ == ProcessDispatcherZooKeeperStoreTests:
            with self.assertRaises(ValueError):
                self.store.add_definition(d3)

        # adding again should get a WriteConflict
        self.assertRaises(WriteConflictError, self.store.add_definition, d1)

        all_ids = self.store.list_definition_ids()
        self.assertEqual(set(all_ids), set(["d1", "d2"]))

        got_d1 = self.store.get_definition("d1")
        self.assertProcessDefinitionsEqual(d1, got_d1)

        got_d2 = self.store.get_definition("d2")
        self.assertProcessDefinitionsEqual(d2, got_d2)

        self.assertIsNone(self.store.get_definition("d3"))

        d1.executable = "ps"
        self.store.update_definition(d1)
        got_d1 = self.store.get_definition("d1")
        self.assertProcessDefinitionsEqual(d1, got_d1)

        self.store.remove_definition("d1")
        self.store.remove_definition("d2")

        self.assertRaises(NotFoundError, self.store.update_definition, d2)

        self.assertFalse(self.store.list_definition_ids())

        self.assertIsNone(self.store.get_definition("d1"))
        self.assertIsNone(self.store.get_definition("neverexisted"))
Пример #4
0
 def update_definition(self, definition_id, definition_type, executable,
                       name=None, description=None):
     validate_definition_id(definition_id)
     definition = ProcessDefinitionRecord.new(definition_id,
         definition_type, executable, name=name, description=description)
     self.store.update_definition(definition)