zzadxz / RATTM

https://rattm.vercel.app
MIT License
0 stars 0 forks source link

Dashboard test #79

Open Chong-source opened 5 days ago

Chong-source commented 5 days ago

Wrote tests for the functions in calculations.py in the dashboard folder. I still couldn't figure out how to run the tests, I have tried manage.py test dashboard.tests, the terminal runs the test, but returns this weird error message:

image

Resolves #75

vercel[bot] commented 5 days ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rattm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 24, 2024 7:00pm
Chong-source commented 5 days ago

After discussing with Callum, we found that we didn't need these lines:

# # Add the project root directory to sys.path
# sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

It turns out, since we're already in the Django env, we don't need to add the project root directory to sys.path.

I still can't figure out why I couldn't run the tests individually by clicking the green buttons on the left side, but Yoyo and Jennifer figured out that if I cd backend and run heroku local:run python3 manage.py test, the tests will run, currently I am trying to fix the tests, one of the test actually worked and we caught an error in the calculations. (calculate_company_esg_scores was trying to iterate through a dictionary, but we end up iterating through the keys, not the actual values of the dictionary.)

jnnchi commented 3 days ago

Great work! But calculate_company_esg_scores doesn't have an error; since we index the Users dictionary by the user ID, calculate_company_esg_scores should be iterating through a list of dictionaries, which represent the rows in the transactions table. Therefore, all of the functions take in the parameter: transactions: list[dict], which should be reflected in the tests.

jnnchi commented 12 hours ago

The tests look great! I updated app.json so that that the Heroku pipeline would be configured properly. Thank you for the hard work!