def testChromeAFDOSuccess(self): """Test the command is called correctly with Chrome afdo.""" request = self._GetRequest(build_target=self.board, artifact_type=toolchain_pb2.CHROME_AFDO) toolchain.UploadVettedAFDOArtifacts(request, self.response, self.api_config) self.command.assert_called_once_with('chrome_afdo', self.board)
def testOrderfileSuccess(self): """Test the command is called correctly with orderfile.""" request = self._GetRequest(build_target=self.board, artifact_type=toolchain_pb2.ORDERFILE) toolchain.UploadVettedAFDOArtifacts(request, self.response, self.api_config) self.command.assert_called_once_with('orderfile', self.board)
def testValidateOnly(self): """Sanity check that a validate only call does not execute any logic.""" request = self._GetRequest(build_target=self.board, artifact_type=toolchain_pb2.ORDERFILE) toolchain.UploadVettedAFDOArtifacts(request, self.response, self.validate_only_config) self.command.assert_not_called()
def testMockCall(self): """Test that a mock call does not execute logic, returns mock value.""" request = self._GetRequest(build_target=self.board, artifact_type=toolchain_pb2.ORDERFILE) toolchain.UploadVettedAFDOArtifacts(request, self.response, self.mock_call_config) self.command.assert_not_called() self.assertEqual(self.response.status, True)
def testWrongArtifactType(self): """Test passing wrong artifact type.""" request = self._GetRequest(build_target=self.board, artifact_type=self.invalid_artifact_type) with self.assertRaises(cros_build_lib.DieSystemExit) as context: toolchain.UploadVettedAFDOArtifacts(request, self.response, self.api_config) self.assertIn( 'artifact_type (%d) must be in' % self.invalid_artifact_type, str(context.exception))