codefortulsa / courtbot-python

This is an experimental reimplementation of courtbot using python.
http://court.bot/
ISC License
18 stars 17 forks source link

updated website view tests #78

Open jeremiahbrem opened 4 years ago

jeremiahbrem commented 4 years ago

I updated the website views test cases with the changed post endpoint name, different phone numbers, and updated success message.

jeremiahbrem commented 4 years ago

Run tests with 'python manage.py test'

jeremiahbrem commented 4 years ago

I can, or I can implement some mocking so we don't have to rely on actual case data, which changes.

jeremiahbrem commented 4 years ago

Actually, I'm not sure how to mock a request made within another request. I can just change the case number for now.

jdungan commented 4 years ago

Actually, I'm not sure how to mock a request made within another request. I can just change the case number for now.

The trick to mocking calls from inside another request is to mock it with the full context from where it is being called:

e.g.


some_module.py
from some_library import some_function

def another_function():
    return some_function()

test.py
import some_module

@mock.patch('some_library.some_function')
def test_one(self):
    result = some_library.another_function()

hope this helps.

jeremiahbrem commented 4 years ago

Awesome, thanks jdungan. I'll get to work on that and commit again