On 1/16/16 1:46 AM, Pranav Sharma wrote:
> I am trying to figure out this test. I am not able to understand this one.
> 
> Please explain the following..
> 
>    1. What are the parameters "addr-1.ord", and so on.

These are regular form parameters, the "." doesn't do anything particular.  The
form that submits to this location just sets up the input fields with names like
that.

>    2. I checked that td is a decorator import. But not able to figure out
>    the use of the line
> 
>            with td.audits('Email address deleted: [email protected]',
>    user=True):
> 

That is a context manager used to assert that audit log entries are created.  It
runs the checks at the *end* of the indented block.

>    3. In the decorator, have the messages been stored in database
>    beforehand to match the test outputs? on which assertions are added?

The audit log messages should be created and stored in the database, by the code
that runs from within that "with" block.

>    4. If a primary email is deleted, and uer now has 2 emails both of them
>    confirmed, which one is made primary?

I'm not sure, it might be arbitrary (random).

For this test, it looks like the purpose is to test what happens when you add 2
emails to an account, change the primary and then delete the primary.  Since the
default data now includes a confirmed email for one user, there is now are 3
email addresses.  I'm not sure why that would cause the removal of
[email protected] to not happen or not get logged, though.  I would suggest
looking at the test.log file and see if there's anything useful in there.  It
might be big, so check the end where the more relevant logging would be.

It might also help to change the test a bit so it only adds 1 new email address
instead of 2, since there is now one pre-existing email address on the account.
 I'm not sure if that's necessary or useful, but it could be worth trying.

> 
> Allura/allura/tests/functional/test_site_admin.py
> 
>         # remove [email protected]
>         with td.audits('Email address deleted: [email protected]',
> user=True):
>             r = self.app.post('/nf/admin/user/update_emails', params={
>                 'username': 'test-user',
>                 'addr-1.ord': '1',
>                 'addr-2.ord': '2',
>                 'addr-2.delete': 'on',
>                 'new_addr.addr': '',
>                 'primary_addr': '[email protected]'},
>                 extra_environ=dict(username='test-admin'))
>         r = self.app.get('/nf/admin/user/test-user')
>         user = M.User.query.get(username='test-user')
>         # [email protected] set as primary since [email protected] is deleted
>         assert_equal(user.get_pref('email_address'), '[email protected]')
> 
> This test's failing log -
> 
> FAIL: allura.tests.functional.test_site_admin:TestUserDetails.test_emails
>   vi +683 allura/tests/functional/test_site_admin.py  # test_emails
>     extra_environ=dict(username='test-admin'))
>   vi +24  /usr/lib/python2.7/contextlib.py  # __exit__
>     self.gen.next()
>   vi +175 allura/tests/decorators.py  # audits
>     message=re.compile(preamble + message))).count(), 'Could not find "%s"'
> % message
> AssertionError: Could not find "Email address deleted: [email protected]"
> -------------------- >> begin captured stdout << ---------------------
> Running setup_app() from allura.websetup
> 
> --------------------- >> end captured stdout << ----------------------
> -------------------- >> begin captured logging << --------------------
> pylons.configuration: DEBUG: Initializing configuration, package: 'allura'
> allura.lib.app_globals: WARNING: Solr config not set; using in-memory
> MockSOLR
> routes.middleware: DEBUG: Initialized with method overriding = True, and
> path info altering = True
> ew.resource: INFO: Loading ep ew_resources =
> allura.config.resources:register_ew_resources
> ew.resource: INFO: Loading ep ew_resources =
> forgeactivity.config.resources:register_ew_resources
> ew.resource: INFO: Loading ep ew_resources =
> forgetracker.config.resources:register_ew_resources
> ew.render: DEBUG: Loading template engine jinja
> ew.render: DEBUG: Loading template engine kajiki-text
> ew.render: DEBUG: Error loading engine kajiki-text
> ew.render: DEBUG: Loading template engine kajiki
> ew.render: DEBUG: Error loading engine kajiki
> ew.render: DEBUG: Loading template engine kajiki-html5
> ew.render: DEBUG: Error loading engine kajiki-html5
> ew.render: DEBUG: Loading template engine kajiki-html4
> ew.render: DEBUG: Error loading engine kajiki-html4
> ew.render: DEBUG: Loading template engine json
> ew.render: DEBUG: Loading template engine jinja2
> ew.render: DEBUG: Loading template engine kajiki-xml
> ew.render: DEBUG: Error loading engine kajiki-xml
> ew.render: DEBUG: Loading template engine genshi
> ew.render: DEBUG: Loading template engine core-ew
> --------------------- >> end captured logging << ---------------------
> 



-- 
Dave Brondsema : [email protected]
http://www.brondsema.net : personal
http://www.splike.com : programming
              <><

Reply via email to