Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make tests more generic #16

Closed
leandrotoledo opened this issue Jul 20, 2015 · 8 comments
Closed

Make tests more generic #16

leandrotoledo opened this issue Jul 20, 2015 · 8 comments
Assignees

Comments

@leandrotoledo
Copy link
Member

The way it is right now it will fail if not ToledosPalaceBot, if more generic Travis could run all the tests when pull requesting, etc.

@Jzarecta
Copy link

Jzarecta commented Oct 7, 2015

I want to learn how the module handles the declared commands assigned by botfather and be able to route them to the desired action.

@leandrotoledo
Copy link
Member Author

Hi @Jzarecta, it doesn't. Bot API doesn't provide methods to get declared commands, you have to create your own handlers parsing text messages when polling updates from their servers. Have a look at examples folder from this repository, hopefully it will be a good start.

Feel free to reach out me for any further questions.

@Jzarecta
Copy link

Actually the example folder didn't gave me much insight. Perhaps I didnt read it right, but I was able to declare updates on the api, but that was it, the rest was a lonely def that supposely was the command to use, but it didnt work as expected. I had the following code:

def p(value):
    #Buscamos el API
    bitapeso=urllib2.urlopen("http://bitapeso.com/json/").read()
    jobject = json.loads(mxn, 'utf-8')
    val=jobject['mxn']
    if val == None:
        peso = float(val)
    else:
        peso = float(val) * value
    return peso.strip()

Maybe I miss something, or a lot.

@franciscod
Copy link
Contributor

We could get the token from an env-var

@franciscod
Copy link
Contributor

are these tests https://travis-ci.org/leandrotoledo/python-telegram-bot/jobs/87105084 from #87 failing due to a testing token issue?

@franciscod
Copy link
Contributor

there are a lot of hardcoded things, right? message/file ids, message contents

@leandrotoledo
Copy link
Member Author

The way it's writen atm I'm the only one who can see the bot interation (as it sends messages to chat_id corresponding my telegram user). @jh0ker has suggested a public channel so anyone planning to submit a feature can see the results for their thats. In order to accomplish that we would need to change some tests and avoid hardcoding as @franciscod mentioned. I'll spend some time on it this week.

@leandrotoledo
Copy link
Member Author

Seems like the amount of efforts to have the same result does justify this rework right now.
The token and the chat_id are now shared on tests/base.py so anyone can run tests. Until we have a better (and easier way) to emulate client requests or generic tests I'd say to keep the way we have.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants