Opened 12 years ago
Closed 11 years ago
#10283 closed defect (worksforme)
Tests fail on Trac 1.0-beta1
Reported by: | ejucovy | Owned by: | osimons |
---|---|---|---|
Priority: | normal | Component: | CustomFieldAdminPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 1.0 |
Description
Running customfieldadmin's setup.py test
against Trac 1.0-beta1 results in several test failures. They seem to be caused by a change in the return value of Trac's TicketSystem.get_custom_fields()
API. The dicts returned by that method now include a key "custom": True
for custom fields, which is not expected by the tests in CustomFieldApiTestCase
.
The attached patch causes the tests to pass by adding "custom": True
to the expected return value in those tests.
Attachments (0)
Change History (4)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Huh.
Why we have changed TicketSystem(self.env).get_custom_fields()
to include the truly useless 'custom': True
information I don't know. It makes no sense and just adds overhead IMHO - the API call already requests the custom fields, and I cannot see the point of adding some sort of additional marker saying the field is a custom field??
Ideally I'd like to see this fixed in Trac, but if not I can also strip it at the receiving end so that the new working patch would look something like this:
-
0.11/customfieldadmin/api.py
a b class CustomFields(Component): 73 73 """ Returns the custom fields from TicketSystem component. 74 74 Use a cfdict with 'name' key set to find a specific custom field only. 75 75 """ 76 def _get_custom_fields(): 77 for item in TicketSystem(self.env).get_custom_fields(): 78 # Remove the superfluous `'custom': True` item from field dict 79 item.pop('custom', None) 80 yield item 76 81 if not cfield: # return full list 77 return TicketSystem(self.env).get_custom_fields()82 return list(_get_custom_fields()) 78 83 else: # only return specific item with cfname 79 for item in TicketSystem(self.env).get_custom_fields():84 for item in _get_custom_fields(): 80 85 if item['name'] == cfield['name']: 81 86 return item 82 87 return None # item not found
comment:3 Changed 12 years ago by
It looks like the change was made in [t 11330], moving the dictionary key from the fields
method to the custom_fields
method.
comment:4 Changed 11 years ago by
Resolution: | → worksforme |
---|---|
Status: | new → closed |
This is the test result running Trac 1.0.1 backed by SQLite (PostgreSQL8.4 and PostgreSQL9.1 successfully tested as well):
(trac-1.0_pg)hasienda@debian6.0:th_devel/customfieldadminplugin_build$ python ./setup.py test running test running egg_info creating TracCustomFieldAdmin.egg-info writing requirements to TracCustomFieldAdmin.egg-info/requires.txt writing TracCustomFieldAdmin.egg-info/PKG-INFO writing top-level names to TracCustomFieldAdmin.egg-info/top_level.txt writing dependency_links to TracCustomFieldAdmin.egg-info/dependency_links.txt writing entry points to TracCustomFieldAdmin.egg-info/entry_points.txt writing manifest file 'TracCustomFieldAdmin.egg-info/SOURCES.txt' reading manifest file 'TracCustomFieldAdmin.egg-info/SOURCES.txt' writing manifest file 'TracCustomFieldAdmin.egg-info/SOURCES.txt' running build_ext test_create (customfieldadmin.tests.api.CustomFieldApiTestCase) ... ok test_delete (customfieldadmin.tests.api.CustomFieldApiTestCase) ... ok test_delete_unknown_options (customfieldadmin.tests.api.CustomFieldApiTestCase) ... ok test_not_delete_unknown_options_for_modify (customfieldadmin.tests.api.CustomFieldApiTestCase) ... ok test_systeminfo (customfieldadmin.tests.api.CustomFieldApiTestCase) ... ok test_update (customfieldadmin.tests.api.CustomFieldApiTestCase) ... ok test_update_non_existing (customfieldadmin.tests.api.CustomFieldApiTestCase) ... ok test_update_non_existing_no_name (customfieldadmin.tests.api.CustomFieldApiTestCase) ... ok test_update_textarea (customfieldadmin.tests.api.CustomFieldApiTestCase) ... ok test_translation_function (customfieldadmin.tests.api.CustomFieldL10NTestCase) ... ok test_translation_function_tag (customfieldadmin.tests.api.CustomFieldL10NTestCase) ... ok test_add_optional_select (customfieldadmin.tests.admin.CustomFieldAdminPageTestCase) ... ok test_apply_optional_select (customfieldadmin.tests.admin.CustomFieldAdminPageTestCase) ... ok test_create (customfieldadmin.tests.admin.CustomFieldAdminPageTestCase) ... ok ---------------------------------------------------------------------- Ran 14 tests in 0.301s
Hmm, attaching a patch doesn't seem to work -- here's the contents of the patch, produced by
svn diff
:customfieldadmin/tests/api.py