def test_compile_url(): """ Tests the compile_url function. """ assert compile_url( "K", "API_KEY" ) == "https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=K&apikey=API_KEY"
def test_compile_url(): symbol = "NFLX" parsed_response = compile_url(symbol) assert isinstance(parsed_response, dict) assert "Meta Data" in parsed_response.keys() assert "Time Series (Daily)" in parsed_response.keys() assert parsed_response["Meta Data"]["2. Symbol"] == symbol
def test_compile_url(): """ Tests whether compile_url function successfully takes user-given symbol and API key and makes online request. """ symbol = "MSFT" parsed_response = compile_url(symbol) assert isinstance(parsed_response, dict) assert "Meta Data" in parsed_response.keys() assert "Time Series (Daily)" in parsed_response.keys() assert parsed_response["Meta Data"]["2. Symbol"] == symbol
def test_get_response(): """ Tests the get_response function. """ load_dotenv() API_KEY = os.environ.get("ALPHAVANTAGE_API_KEY") request_url = compile_url("K", API_KEY) response = get_response(request_url) parsed_response = parse_response(response) assert type(parsed_response) is dict assert 'Meta Data' in parsed_response assert 'Time Series (Daily)' in parsed_response
def test_get_response(): #request_url=compile_url(stock_symbol) stock_symbol = "MU" parsed_response = get_response(compile_url(stock_symbol)) assert isinstance( parsed_response, dict) #Checks if its in proper original format: Dictionary assert "Meta Data" in parsed_response.keys( ) #Checks whether correct header assert "Time Series (Daily)" in parsed_response.keys() #'' assert parsed_response["Meta Data"][ "2. Symbol"] == stock_symbol #Checks whether Symbol is in fact Correct!
def test_return_keys(): """ Tests the return_keys function. """ load_dotenv() API_KEY = os.environ.get("ALPHAVANTAGE_API_KEY") request_url = compile_url("K", API_KEY) response = get_response(request_url) parsed_response = parse_response(response) tsd = parsed_response["Time Series (Daily)"] dates = return_keys(tsd) assert '2020-04-14' in dates assert '2020-04-07' in dates
def test_compile_url(): result = compile_url("MSFT") assert result[: 72] == "https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=MSFT"
def test_complile_url_MSFT(): result = compile_url("MSFT").split("&") result.pop() result = "&".join(result) assert result == "https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=MSFT&datatype=json"
def test_compile_url(): ticker = 'AMZN' assert ticker in compile_url(ticker) assert 'https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=' in compile_url( ticker)
def test_compile_url(): assert (compile_url("MSFT")) == 200
def test_url(): result = compile_url('Symbol', 'APIkey') assert "https://www.alphavantage.co/query?function=TIME_SERIES_WEEKLY&outputsize=full&symbol=" in result
def stock_data(): return get_response(compile_url("MSFT"))
def test_compile_url(): expected_result = "https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=AAPL&apikey=KEY123" assert compile_url("DAILY", "AAPL", "KEY123") == expected_result
def test_compile_url(): #Tests whether a sample symbol constructs necessary expected url in proper format stock_symbol = "MU" #sample result = compile_url(stock_symbol) assert result == f"https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=MU&apikey={api_key}"
def test_compile_url(): url = compile_url("AAPL", api_key) assert url == f"https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=AAPL&apikey={api_key}"