Esempio n. 1
0
    def test_report_with_deploy_goal(self):
        if os.path.exists('/tmp/env_status'):
            os.remove('/tmp/env_status')

        build = {}
        build['id'] = '123'
        build['url'] = 'https://test'
        client = mock.Mock()
        deploy_goal = {}
        deploy_goal['deployId'] = '123'
        deploy_goal['envName'] = '456'
        deploy_goal['envId'] = '789'
        deploy_goal['stageName'] = 'beta'
        deploy_goal['deployStage'] = DeployStage.PRE_DOWNLOAD
        deploy_goal['scriptVariables'] = build
        ping_response = {'deployGoal': deploy_goal, 'opCode': OpCode.DEPLOY}

        responses = [
            PingResponse(jsonValue=ping_response),
            PingResponse(jsonValue=self.ping_noop_response)
        ]
        client.send_reports = mock.Mock(side_effect=responses)
        agent = DeployAgent(client=client, estatus=self.estatus, conf=self.config,
                            executor=self.executor, helper=self.helper)
        agent.process_deploy = mock.Mock(return_value=(DeployReport(AgentStatus.SUCCEEDED)))
        agent.serve_build()
        self.assertEqual(agent._curr_report.report.envId, '789')
        self.assertEqual(agent._curr_report.report.deployStage, DeployStage.PRE_DOWNLOAD)
        self.assertEqual(len(agent._envs), 1)