warnet-gi / WarnetBot

A bot for Warga Nusantara Teyvat (WARNET) discord server
https://discord.gg/warnet-gi
MIT License
7 stars 4 forks source link

Implement TDD for General CMD #101

Closed rafiramadhana closed 1 year ago

rafiramadhana commented 1 year ago

Relates to https://github.com/warnet-gi/WarnetBot/issues/54

This PR is initiating TDD by:

Some notes:

PS. This PR is very open for discussions

Iqrar99 commented 1 year ago

The test you provided looks promising, It'll be a good starting point to write other tests. I'll try to learn more about utilizing this magic mock

anyway, you can just add the pytest-cov under dev section here along with the requirements.txt I explained above https://github.com/warnet-gi/WarnetBot/blob/01cbd9fdb80b29fd83a495adeafd36bd1869d44a/pyproject.toml#L21-L24

rafiramadhana commented 1 year ago

anyway, you can just add the pytest-cov under dev section here along with the requirements.txt I explained above

got it

rafiramadhana commented 1 year ago

@Iqrar99 btw do you have concerns for the .env.test?

the reason why I don't use .env.example is because the code expects GUILD_ID and DEV_GUILD_ID to be numeric

while they are set as alphabet in the .env.example

GUILD_ID="YOUR_GUILD_ID"
DEV_GUILD_ID="YOUR_DEV_GUILD_ID"

i think, we can also update the .env.example instead of adding .env.test to reduce the number of files within the codebase

---GUILD_ID="YOUR_GUILD_ID"
+++GUILD_ID="123"
---DEV_GUILD_ID="YOUR_DEV_GUILD_ID"
+++DEV_GUILD_ID="123"

wdyt?

PS. in this PR, to avoid breaking in other developer's env (which uses .env.example) i chose to add a new file .env.test instead

Iqrar99 commented 1 year ago

i think, we can also update the .env.example instead of adding .env.test to reduce the number of files within the codebase

Have you tried to change the guild id variables in .env.example to numeric? Does it work with the test? if yes, then it sounds good. Then, we can add a comment suggesting people change the env variables to their own guild id.

rafiramadhana commented 1 year ago

Have you tried to change the guild id variables in .env.example to numeric? Does it work with the test?

yes. ok, i will update the .env.example