def test_create_amp(self): beforeAmps = Amp.list(self.connection) amp = Amp("test-amp", "http://example.com", "/MarkLogic/test-amp.xqy", \ connection=self.connection) amp.create() afterAmps = Amp.list(self.connection) assert len(afterAmps) > len(beforeAmps) newAmp = Amp.lookup(self.connection, amp.local_name(), \ amp.namespace(), amp.document_uri()) assert isinstance(newAmp, Amp) for key in amp._config: assert newAmp._config[key] == amp._config[key] amp.set_role_names(["manage-admin"]) amp.update(connection=self.connection) newAmp.set_document_uri("/MarkLogic/no-can-do") try: newAmp.update(connection=self.connection) except UnexpectedManagementAPIResponse: pass except: raise amp.delete() afterAmps = Amp.list(self.connection) assert len(afterAmps) == len(beforeAmps) newAmp = Amp.lookup(self.connection, amp.local_name(), \ amp.namespace(), amp.document_uri()) assert newAmp is None
def modify(self, args, config, connection): if args['json'] is not None: amp = self._read(args['json']) else: amp = Amp() self._handle_args(amp, args) self._handle_properties(amp, args) amp.update(connection=connection)