[asterisk-dev] [Code Review] 2770: TestSuite: ARI Bridge Tests

David Lee reviewboard at asterisk.org
Thu Sep 12 16:03:23 CDT 2013



> On Sept. 12, 2013, 2 p.m., opticron wrote:
> > /asterisk/trunk/tests/rest_api/bridges/hangup/bridge_hangup.py, lines 16-17
> > <https://reviewboard.asterisk.org/r/2770/diff/3/?file=45856#file45856line16>
> >
> >     Is there any reason not to just define these two members in global scope since the majority of the class is now gone? Idem for happy and move tests.

Because scoping in Python [is weird][1]. Assigning to a global
variable requires using the global keyword, which is easy to forget,
made things hard to debug, and just felt clunky overall.

The next attempt was to put all the test methods on an object, but
that required annoying wrapper methods at global scope, so they can be
called dynamically by the test module.

I finally settled on having a global object with mutable state as the
least awful alternative.

 [1]: http://docs.python.org/2/faq/programming.html#what-are-the-rules-for-local-and-global-variables-in-python


- David


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/2770/#review9684
-----------------------------------------------------------


On Sept. 12, 2013, 11:56 a.m., David Lee wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/2770/
> -----------------------------------------------------------
> 
> (Updated Sept. 12, 2013, 11:56 a.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Bugs: ASTERISK-22036
>     https://issues.asterisk.org/jira/browse/ASTERISK-22036
> 
> 
> Repository: testsuite
> 
> 
> Description
> -------
> 
> TestSuite tests that test the expected behavior for adding/removing
> channel to/from bridges using ARI.
> 
> 
> Diffs
> -----
> 
>   /asterisk/trunk/lib/python/asterisk/TestCase.py 4167 
>   /asterisk/trunk/lib/python/asterisk/TestConfig.py 4167 
>   /asterisk/trunk/lib/python/asterisk/ari.py 4167 
>   /asterisk/trunk/tests/rest_api/bridges/hangup/bridge_hangup.py PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/bridges/hangup/configs/ast1/extensions.conf PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/bridges/hangup/test-config.yaml PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/bridges/happy/bridge_happy.py PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/bridges/happy/configs/ast1/extensions.conf PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/bridges/happy/test-config.yaml PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/bridges/move/bridge_move.py PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/bridges/move/configs/ast1/extensions.conf PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/bridges/move/test-config.yaml PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/bridges/tests.yaml PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/bridges/unhappy/bridge_unhappy.py PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/bridges/unhappy/configs/ast1/extensions.conf PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/bridges/unhappy/test-config.yaml PRE-CREATION 
>   /asterisk/trunk/tests/rest_api/continue/test-config.yaml 4167 
>   /asterisk/trunk/tests/rest_api/tests.yaml 4167 
> 
> Diff: https://reviewboard.asterisk.org/r/2770/diff/
> 
> 
> Testing
> -------
> 
> Tests pass.
> 
> https://reviewboard.asterisk.org/r/2769/
> 
> 
> Thanks,
> 
> David Lee
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20130912/ac19ed31/attachment.htm>


More information about the asterisk-dev mailing list