Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Michael Howitz
committed
Apr 12, 2018
1 parent
2bfe0df
commit 5b43358
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import unittest | ||
|
||
|
||
class DummySection(object): | ||
blocks = ['dummy'] | ||
|
||
|
||
class TestIn(unittest.TestCase): | ||
"""Testing ..DT_in.InClass.""" | ||
|
||
def _getTargetClass(self): | ||
from DocumentTemplate.DT_In import InClass | ||
return InClass | ||
|
||
def _makeOne(self, *args): | ||
blocks = [('in', ' '.join(args), DummySection())] | ||
return self._getTargetClass()(blocks) | ||
|
||
def test_sort_sequence(self): | ||
"""It does not break on duplicate sort keys at a list of dicts.""" | ||
stmt = self._makeOne('seq', 'mapping', 'sort=key') | ||
seq = [ | ||
{'key': 'c', 'data': '3'}, | ||
{'key': 'a', 'data': '1'}, | ||
{'key': 'b', 'data': '2'}, | ||
{'key': 'a', 'data': '2'}, | ||
] | ||
result = stmt.sort_sequence(seq, 'key') | ||
self.assertEqual([ | ||
{'key': 'a', 'data': '1'}, | ||
{'key': 'a', 'data': '2'}, | ||
{'key': 'b', 'data': '2'}, | ||
{'key': 'c', 'data': '3'}, | ||
], result) |