0

I have seen a couple of questions on this problem, but the answers for them do not work for me. I am having the check50 problem on pset7 with check50 not finding 112.00. One answer was to use usd in the form which I have, another was to redirect to /index when the buy is submitted, which is the way my code was written. Decided to test staff's website side by side with mine to see if there were differences in their behavior and mine. I bought BA stock, all the behavior looked the same except the staff website showed a price of 327.84, and mine was 327.88. I checked yahoo online, it showed 327.88, also checked Alpha Vantage, also had 327.88 and checked a couple others such as Bloomberg, all had 327.88. But I am quessing somehow the check50 is using a fixed file to get prices otherwise it could not be always 112.00 for four shares. However, whatever caused the disagreement real time could cause the same during the test. Does anyone have another idea? Below is what check50 shows:

    :( buy handles valid purchase
    expected to find "112.00" in page, but it wasn't found 

    Log 
    sending POST request to /login 
    sending POST request to /buy 
    checking that "112.00" is in page 

2 Answers 2

3

One way to test is to add a hard-coded value to lookup (in helpers.py) that has the condition you need.

Near the top, put this:

    if symbol == "ABC":
        return {"name": "ABC test","price": 14.00,"symbol": "ABC"}

And then buy 8 shares of it.

Does your index.html page now show that you have 8 shares worth $112.00?

2
  • Thank you for the suggestion I was trying think of some test I could do in lookup. I did the test and my index.html does show $112.00. So I think I know the problem only I don't know how any of the tests worked if I am correct. I thought was no check50 for this pset7 and I put a lot of necessary functions in helpers and now I realize the check50 probably does not use my helpers. So I will move those functions to applications and see that works.
    – Nancy Holt
    Commented Mar 31, 2018 at 19:42
  • Moving the functions from helpers to application worked for this problem but now I have :(buy handles fractional, negative, and non-numeric shares expected status code 400, but got 200 It was sending 400 before so I have for something I missed when moving the functions.
    – Nancy Holt
    Commented Mar 31, 2018 at 20:21
1

replacing

return render_template("index.html")

with

return redirect("/")

worked for me.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .