[Twisted-web] Passing events to (Athena) event handlers.

kgi iacovou at gmail.com
Mon Aug 6 13:48:56 EDT 2007


On Wednesday 18 July 2007 22:08:33 glyph at divmod.com wrote:
> You may have noticed JavaScript unit tests lying around in our various
> codebases.  A good example of some pretty thorough unit testing is in
> Mantissa.Test.TestRegionModel.  You'd need to add coverage for your
> event handler stuff that used these tests and ran under trial.
>
> Some other test examples, that will be even closer to the feature you
> are trying to implement, are in
> Nevow.Test.TestWidget.WidgetTests.test_connectDOMEvent*.

Hi Glyph et al.

I'm having a little trouble running (or indeed, understanding) the unit 
testing infrastructure. This is in relation to the patch I mentioned 
previously that allows the event to be passed along with the node to event 
handlers.

I've read through

  http://divmod.org/trac/wiki/DivmodNevow/AthenaTesting

and also

  http://blackjml.livejournal.com/21602.html

You mentioned "trial", but the pages above refer to "nit". From what I've 
worked, trial is the general purpose testing infrastructure and nit is a 
Nevow-specific thing that actually requires a browser (rather than using a 
standalone JS interpreter, say). Does trial use nit, nit use trial, or are 
they completely separate?

(And I've got no idea how "nose" fits into all this).

I can see that Nevow/nevow/js/Nevow/Test/TestWidget.js contains exactly the 
sort of tests that I want to extend, just like you said. I intend to leave 
the existing tests alone (to prove that passing and event to methods that 
aren't expecting events still work) and a new test that receives and examines 
the event (to prove that the event getting passed is indeed the type, etc, I 
expect)[1].

I've managed to run the nevow tests by running "nit nevow" and pointing 
Firefox to http://localhost:8080.

However, when I run open Firebug and go to the "Script" tab I would expect to 
see "Nevow.Test" as an option in the dropdown list of modules. However, it 
looks like this isn't included at all, which means that Firefox hasn't loaded 
it because the test "page" doesn't include it.

It occurred to me that it's possible that it's "pushed" to the browser 
dynamically, but it's not available even after the tests have run. At that 
point I'd definitely expect all relevant JS to have been loaded.

(The list of JS files is: Divmod, Divmod.Base|Defer|Inspect|Runtime|
Runtime.Tests, Nevow, Nevow.Athena, Nevow.Athena.Test, Nevow.Athena.Tests, 
Nevow.Athena.Tests.Resources.

Is the JS code you pointed me to not run by the "nit nevow" tests? If not, how 
can I run that test code?

Thanks,

Ricky

[1] Plus any other tests that fail as a result of the changes; for example, 
Nevow/nevow/test/test_athena.py:test_handlerMacro() checks a serialized 
athena handler against a hardcoded string; if _handlerFormat is changed, this 
will fail and need updating.



More information about the Twisted-web mailing list