Ejemplo n.º 1
0
def do_stop_bot():
	data = request.get_json(force=True)
	if not data.get('name', False):
		return error_response("Specify a bot name.")
	bot_name = get_bot_name(github.get('user').get('login'), data.get('name'))
	deployer.stop_bot(bot_name)
	return success_response()
Ejemplo n.º 2
0
def do_stop_bot():
    data = request.get_json(force=True)
    if not data.get('name', False):
        return "Specify a bot name."
    username = secure_filename(github.get('user').get('login'))
    bot_root = username + "-" + secure_filename(data.get('name'))
    deployer.stop_bot(bot_root)
    return "done"
Ejemplo n.º 3
0
 def test_stop_bot_success(self, open_mock: ANY):
     bot_name = 'user1-bot_1'
     docker_client = test_docker_client(
         containers=[dict(id='c1', image_id='i1', status='running')],
         images=[dict(id='i1', tags=['zulip-{}:latest'.format(bot_name)])])
     with patch('deployer.docker_client', new=docker_client):
         result = deployer.stop_bot(bot_name)
         self.assertTrue(result)
     stopped_container = docker_client.containers.get('c1')
     self.assertEquals(stopped_container.status, 'exited')
Ejemplo n.º 4
0
 def test_stop_bot_not_found(self):
     docker_client = test_docker_client(containers=[], images=[])
     with patch('deployer.docker_client', new=docker_client):
         result = deployer.stop_bot('non-existing-bot')
         self.assertFalse(result)