From ae52164e009df1863f1451a343041a94c3d0fc0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20H=C3=BChne?= Date: Fri, 27 May 2016 12:14:15 +0200 Subject: [PATCH] Pad Groups and Org names from factories with zeros The test in ckan/tests/controllers/test_group.py would sometimes fail when run in an unfortunate order. The `test_page_thru_list_of_orgs_preserves_sort_order` and `test_page_thru_list_of_groups_preserves_sort_order` would fail because some organizations had already been created by oyher tests and the numbering would start a 5 instead of 1. And because the sorting was done via strings (so `Group 5` came after `Group 31` the test would fail. By always padding them with zeros this should not happend anymore and make the tests more stable (So it is `Group 05` now). --- ckan/tests/factories.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ckan/tests/factories.py b/ckan/tests/factories.py index 3f364c19a84..fd6d68d4cb8 100644 --- a/ckan/tests/factories.py +++ b/ckan/tests/factories.py @@ -245,7 +245,7 @@ class Group(factory.Factory): FACTORY_FOR = ckan.model.Group - name = factory.Sequence(lambda n: 'test_group_{n}'.format(n=n)) + name = factory.Sequence(lambda n: 'test_group_{0:02d}'.format(n)) title = factory.LazyAttribute(_generate_group_title) description = 'A test description for this test group.' @@ -285,7 +285,7 @@ class Organization(factory.Factory): image_url = 'http://placekitten.com/g/200/100' # Generate a different group name param for each user that gets created. - name = factory.Sequence(lambda n: 'test_org_{n}'.format(n=n)) + name = factory.Sequence(lambda n: 'test_org_{0:02d}'.format(n)) @classmethod def _build(cls, target_class, *args, **kwargs):