Opened 13 years ago

Closed 12 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.



Change History (24)

comment:1 by Christopher Allan Webber, 13 years ago

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



comment:2 by Caleb Davis, 13 years ago

go cmoylan, go! :)



comment:3 by Will Kahn-Greene, 13 years ago

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



comment:4 by Chris Moylan, 13 years ago

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



comment:5 by Christopher Allan Webber, 13 years ago

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 by Christopher Allan Webber, 13 years ago

Ping :)



comment:7 by Chris Moylan, 13 years ago

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 by Christopher Allan Webber, 13 years ago

Milestone: 0.0.50.1.0

comment:8 by Christopher Allan Webber, 13 years ago

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



comment:9 by Chris Moylan, 13 years ago

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 by Christopher Allan Webber, 13 years ago

Milestone: 0.1.00.2.0

comment:11 by Elrond, 13 years ago

Milestone: 0.2.00.2.1

comment:10 by Shawn Khan, 13 years ago

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



comment:11 by Christopher Allan Webber, 13 years ago

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 by Will Kahn-Greene, 13 years ago

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

comment:13 by Christopher Allan Webber, 13 years ago

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 by Elrond, 13 years ago

Milestone: 0.2.1
Type: defectenhancement

comment:15 by Christopher Allan Webber, 12 years ago

Description: modified (diff)
Keywords: bitesized added

comment:16 by Christopher Allan Webber, 12 years ago

Owner: Chris Moylan removed
Status: acceptedassigned

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

comment:17 by Christopher Allan Webber, 12 years ago

Resolution: fixed
Status: assignedclosed

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

comment:18 by Christopher Allan Webber, 12 years ago

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 by Gabriela Thumé, 12 years ago

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 by Elrond, 12 years ago

Status: reopenedreview

comment:21 by Christopher Allan Webber, 12 years ago

Resolution: fixed
Status: reviewclosed

Merged. Great work!

Note: See TracTickets for help on using tickets.