def test_cli_setup_with_hub_during_first_time(runner): clean_config_files() cli_setup_with_hub(runner) iniFile = HostPlatform.get_setting_ini_path() jsonFile = HostPlatform.get_config_file_path() assert os.path.exists(iniFile) assert os.path.exists(jsonFile)
def clean_config_files(): iniFile = HostPlatform.get_setting_ini_path() jsonFile = HostPlatform.get_config_file_path() update_setting_ini_as_firsttime() if os.path.exists(iniFile): os.remove(iniFile) if os.path.exists(jsonFile): os.remove(jsonFile)
def test_cli_setup_during_first_time(runner): iniFile = HostPlatform.get_setting_ini_path() jsonFile = HostPlatform.get_config_file_path() update_setting_ini_as_firsttime() if os.path.exists(iniFile): os.remove(iniFile) if os.path.exists(jsonFile): os.remove(jsonFile) cli_setup(runner) assert os.path.exists(iniFile) assert os.path.exists(jsonFile)
def test_corrupt_edge_hub_config(runner): json_file = HostPlatform.get_config_file_path() base_dir = os.path.dirname(json_file) if not os.path.exists(base_dir): os.makedirs(base_dir) if os.path.exists(json_file): os.remove(json_file) # Create an empty edgehub.json file open(json_file, 'a').close() instruction = ('ERROR: Invalid config file. Please run `iotedgehubdev setup -c "<edge-device-connection-string>"` again.' if platform.system().lower() == 'windows' else 'ERROR: Invalid config file. ' 'Please run `sudo iotedgehubdev setup -c "<edge-device-connection-string>"` again.') result = runner.invoke(cli.start, ['-i', 'input1']) assert result.exception assert result.exit_code != 0 assert instruction in result.output.strip() result = runner.invoke(cli.start, ['-d', 'dummy_deployment.json']) assert result.exception assert result.exit_code != 0 assert instruction in result.output.strip() result = runner.invoke(cli.modulecred) assert result.exception assert result.exit_code != 0 assert instruction in result.output.strip()
def test_pre_setup(runner): json_file = HostPlatform.get_config_file_path() if os.path.exists(json_file): os.remove(json_file) instruction = ( 'ERROR: Cannot find config file. Please run `iotedgehubdev setup -c "<edge-device-connection-string>"` first.' if platform.system().lower() == 'windows' else 'ERROR: Cannot find config file. ' 'Please run `sudo iotedgehubdev setup -c "<edge-device-connection-string>"` first.' ) result = runner.invoke(cli.start, ['-i', 'input1']) assert result.exception assert result.exit_code != 0 assert instruction in result.output.strip() result = runner.invoke(cli.start, ['-d', 'dummy_deployment.json']) assert result.exception assert result.exit_code != 0 assert instruction in result.output.strip() result = runner.invoke(cli.modulecred) assert result.exception assert result.exit_code != 0 assert instruction in result.output.strip()
def cleanup(cls): iniFile = HostPlatform.get_setting_ini_path() if os.path.exists(iniFile): os.remove(iniFile)