Пример #1
0
def test_get_response():
    stock_symbol = "AMZN"
    parsed_response = get_response(stock_symbol)
    # adapated from https://github.com/s2t2/robo-advisor-screencast/pull/1/files
    assert isinstance(parsed_response, dict)
    assert parsed_response["Meta Data"]["1. Information"] == "Daily Prices (open, high, low, close) and Volumes"
    assert parsed_response["Meta Data"]["2. Symbol"] == stock_symbol
def test_get_response():
    symbol = "NFLX"

    parsed_response = get_response(symbol)

    assert isinstance(parsed_response, dict)
    assert "Meta Data" in parsed_response.keys()
    assert "Weekly Time Series" in parsed_response.keys()
    assert parsed_response["Meta Data"]["2. Symbol"] == symbol
Пример #3
0
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
Пример #4
0
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!
Пример #5
0
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
Пример #6
0
def test_get_response():
    symbol = "NFLX"

    parsed_response = get_response(symbol)

    assert isinstance(
        parsed_response,
        dict)  #Tests that the parsed_response is of the class "dict"
    assert "Meta Data" in parsed_response.keys(
    )  #Tests that one of the "keys" in the parsed_response dictionary is "Meta Data"
    assert "Time Series (Daily)" in parsed_response.keys(
    )  #Tests that one of the "keys" in the parsed_response dictionary is "Time Series (Daily)"
    assert parsed_response["Meta Data"][
        "2. Symbol"] == symbol  #Tests that "symbol" variable in the parsed response data has the same value as the one given as a parameter
Пример #7
0
def test_get_response():
    parsed_response = get_response("AAPL")
    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"] == "AAPL"