Opened 11 years ago

Closed 9 years ago

#146 closed enhancement (fixed)

Make messaging system testable

Reported by: Christopher Allan Webber Owned by:
Priority: minor Milestone:
Component: programming Keywords: bitesized
Cc: Parent Tickets:

Description (last modified by Christopher Allan Webber)

We should make it possible to test the messaging system.

If you look at mediagoblin/utils.py you can see what happens when
we \_activate\_testing() for some other things... ie, we insert
template context info like so:

::

        if TESTS_ENABLED:
            TEMPLATE_TEST_CONTEXT[template_path] = context

Maybe we should do something similar with messaging? Either we
should store in a dictionary like TEMPLATE\_TEST\_CONTEXT, maybe
TEST\_MESSAGES (which gets wiped by clear\_test\_buckets()) or we
should store in the session like request.session['test\_messages']
(should also get wiped by clear\_test\_buckets())

I'm assigning this to Caleb Davis who I think is a good fit for
it.



Subtickets

Change History (24)

comment:1 Changed 11 years ago by Christopher Allan Webber

Owner: changed from Caleb Davis to Chris Moylan
Assigning to cmoylan!



comment:2 Changed 11 years ago by Caleb Davis

go cmoylan, go! :)



comment:3 Changed 11 years ago by Will Kahn-Greene

Milestone: 0.0.40.0.5
We release 0.0.4, so I'm bumping this to 0.0.5.



comment:4 Changed 11 years ago by Chris Moylan

Seems like the best way to do this is to move the messaging
functions into util.py.



comment:5 Changed 11 years ago by Christopher Allan Webber

Indeed, though I think Aaron is facing some of this stuff in
`http://bugs.foocorp.net/issues/444 <http://bugs.foocorp.net/issues/444>`_,
so adding him to this bug.



comment:6 Changed 11 years ago by Christopher Allan Webber

Ping :)



comment:7 Changed 11 years ago by Chris Moylan

I thought about moving messaging into util.py, but you're right -
it's a junk drawer of functionality. So instead I imported util.py
into messages.py to get access to the globals TESTS\_ENABLED and
TEMPLATE\_TEST\_CONTEXT. However, messages.py is already being
imported in util.py, so I'm not sure if there will be any circular
reference problems. I think the best solution would be to move the
test globals into their own file which can be imported wherever.



comment:8 Changed 11 years ago by Christopher Allan Webber

Milestone: 0.0.50.1.0

comment:8 Changed 11 years ago by Christopher Allan Webber

Re: util.py, probably
`http://bugs.foocorp.net/issues/444 <http://bugs.foocorp.net/issues/444>`_
is related :)



comment:9 Changed 11 years ago by Chris Moylan

So should this wait until 444 is resolved? I don't want to move
messaging into util.py if that's just going to create a headache
when it comes time to refactor it.



comment:10 Changed 11 years ago by Christopher Allan Webber

Milestone: 0.1.00.2.0

comment:11 Changed 11 years ago by Elrond

Milestone: 0.2.00.2.1

comment:10 Changed 11 years ago by Shawn Khan

Hi Chris, `#444 </issues/444>`_ is now done, are you still
interested in this ticket?



comment:11 Changed 11 years ago by Christopher Allan Webber

Yes it should be possible to move forward with this now. Chris
Moylan, if you're still interested, feel free to ping me on IRC!



comment:12 Changed 11 years ago by Will Kahn-Greene

The original url for this bug was http://bugs.foocorp.net/issues/436 .
Relations:
#154: related

comment:13 Changed 11 years ago by Christopher Allan Webber

No response recently from Chris Moylan on this. I'll send him an email. But if someone wants to just pick this up in the meanwhile they're welcome to. Should be reasonably simple.

comment:14 Changed 11 years ago by Elrond

Milestone: 0.2.1
Type: defectenhancement

comment:15 Changed 10 years ago by Christopher Allan Webber

Description: modified (diff)
Keywords: bitesized added

comment:16 Changed 9 years ago by Christopher Allan Webber

Owner: Chris Moylan deleted
Status: acceptedassigned

Removing assignment. Again, another good bug for someone wanting something small, esp for OPW/GSoC prep.

comment:17 Changed 9 years ago by Christopher Allan Webber

Resolution: fixed
Status: assignedclosed

Wait, we have tests on messages! I'm removing this :)

comment:18 Changed 9 years ago by Christopher Allan Webber

Resolution: fixed
Status: closedreopened

Wait, no, I'm misreading.

We have tests on test_messages, but this isn't what this bug is about. The suggestion here is that in unit testing mode the tests should be appended to some debug information that we can query. Reopening!

comment:19 Changed 9 years ago by Gabriela Thumé

I believe I implemented this ticket in branch 146_debug_message at my fork: https://gitorious.org/~gabithume/mediagoblin/gabithume-mediagoblin/commits/146_debug_message

In summary, I changed mediagoblin/tests/test_messages.py and mediagoblin/messages.py to test messages.add_message() function. This is done appending messages in messages.ADD_MESSAGE_TEST and verifying its presence after adding a new message.

I already tested (running runtests.sh) and verified the modified files with PEP-8.

Please, let me know if there is anything I have to change.

Thanks a lot!

comment:20 Changed 9 years ago by Elrond

Status: reopenedreview

comment:21 Changed 9 years ago by Christopher Allan Webber

Resolution: fixed
Status: reviewclosed

Merged. Great work!

Note: See TracTickets for help on using tickets.