def test_load_fail_wrong_json(self): settings = Settings() path = os.path.join(mocks.constants.MOCKS_PATHS, 'options_wrong.json') with pytest.raises(exceptions.FileReadError): settings.from_file(path) assert settings.settings_loaded is False
def test_load_fail_missing_file(self): wrong_path = './not/a/file.json' settings = Settings() with pytest.raises(exceptions.MissingFile): settings.from_file(wrong_path) assert settings.settings_loaded is False # Custom FileNotFound Exception assert settings.errors == [ "Settings FILE not found at ./not/a/file.json" ]
def test_load_settings_success(self): # Actually test loading mock options settings = Settings() assert settings.from_file(mocks.constants.SETTINGS_PATH) is True assert settings.settings_loaded is True # Validate the some fields are actually loaded validate_start_date(settings) assert settings.tickers == ['AMC', 'GME'] assert settings.errors == [] assert settings.output_type == ticker_writer.output_type