blob: ffb2ef80b42e4fb4b3b03fd70ed737a467150fcd [file] [log] [blame]
Michael Mortensen3e86c1e2019-11-21 15:51:54 -07001# -*- coding: utf-8 -*-
2# Copyright 2019 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6"""Unittests for build_api.py"""
7
8from __future__ import print_function
Chris McDonalde0a44a22020-04-15 06:55:20 -06009from __future__ import division
Michael Mortensen3e86c1e2019-11-21 15:51:54 -070010
Mike Frysinger898265b2020-02-10 23:49:12 -050011import sys
Michael Mortensen3e86c1e2019-11-21 15:51:54 -070012
13from chromite.api import router as router_lib
Michael Mortensen3e86c1e2019-11-21 15:51:54 -070014from chromite.lib import osutils
15from chromite.scripts import build_api
16
Mike Frysinger898265b2020-02-10 23:49:12 -050017assert sys.version_info >= (3, 6), 'This module requires Python 3.6+'
18
19
Chris McDonalde0a44a22020-04-15 06:55:20 -060020def testSmoke(tmp_path, monkeypatch):
21 """Basic sanity check"""
Michael Mortensen3e86c1e2019-11-21 15:51:54 -070022
Chris McDonalde0a44a22020-04-15 06:55:20 -060023 def dummy(*_args, **_kwargs):
24 return True
Alex Kleind815ca62020-01-10 12:21:30 -070025
Chris McDonalde0a44a22020-04-15 06:55:20 -060026 monkeypatch.setattr(router_lib.Router, 'Route', dummy)
Alex Kleind815ca62020-01-10 12:21:30 -070027
Chris McDonalde0a44a22020-04-15 06:55:20 -060028 input_json = tmp_path / 'input.json'
29 output_json = tmp_path / 'output.json'
Alex Kleind815ca62020-01-10 12:21:30 -070030
Chris McDonalde0a44a22020-04-15 06:55:20 -060031 osutils.WriteFile(input_json, '{}')
Michael Mortensen3e86c1e2019-11-21 15:51:54 -070032
Chris McDonalde0a44a22020-04-15 06:55:20 -060033 build_api.main([
34 '--input-json',
35 str(input_json),
36 '--output-json',
37 str(output_json),
38 'chromite.api.VersionService/Get',
39 ])