def test_find_modules_goes_bang(): """ Ensure if there's a problem getting metadata an error message is displayed and the utility exists with an error code of 1. """ with mock.patch("circup.get_device_versions", side_effect=Exception("BANG!")), mock.patch( "circup.click") as mock_click, mock.patch( "circup.sys.exit") as mock_exit: circup.find_modules() assert mock_click.echo.call_count == 1 mock_exit.assert_called_once_with(1)
def test_find_modules(): """ Ensure that the expected list of Module instances is returned given the metadata dictionary fixtures for device and bundle modules. """ with open("tests/device.json") as f: device_modules = json.load(f) with open("tests/bundle.json") as f: bundle_modules = json.load(f) with mock.patch( "circup.get_device_versions", return_value=device_modules ), mock.patch( "circup.get_bundle_versions", return_value=bundle_modules ), mock.patch( "circup.os.path.isfile", return_value=True ): bundle = circup.Bundle(TEST_BUNDLE_NAME) bundles_list = [bundle] for module in bundle_modules: bundle_modules[module]["bundle"] = bundle result = circup.find_modules("", bundles_list) assert len(result) == 1 assert result[0].name == "adafruit_74hc595" assert ( result[0].repo == "https://github.com/adafruit/Adafruit_CircuitPython_74HC595.git" )
def test_find_modules(): """ Ensure that the expected list of Module instances is returned given the metadata dictionary fixtures for device and bundle modules. """ with open("tests/device.json") as f: device_modules = json.load(f) with open("tests/bundle.json") as f: bundle_modules = json.load(f) with mock.patch("circup.get_device_versions", return_value=device_modules), mock.patch( "circup.get_bundle_versions", return_value=bundle_modules), mock.patch( "circup.os.path.isfile", return_value=True): result = circup.find_modules() assert len(result) == 1 assert result[0].name == "adafruit_74hc595"