Skip to content

Commit

Permalink
Pad Groups and Org names from factories with zeros
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
k-nut authored and amercader committed Aug 26, 2016
1 parent 8b4c0b9 commit 9bb37f4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ckan/tests/factories.py
Expand Up @@ -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.'

Expand Down Expand Up @@ -286,7 +286,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):
Expand Down

0 comments on commit 9bb37f4

Please sign in to comment.