-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[book-store] Add additional tests (#2174)
* [book-store] Add additional tests Adds tests that requires use of booth groups of 4 and 5 volumes. Closes #2141, which had gone stale. * [book-store] Update from latest template. * Crank the handle on Travis
- Loading branch information
Showing
4 changed files
with
52 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"cases": [ | ||
{ | ||
"property": "total", | ||
"description": "Two groups of four and a group of five", | ||
"comments": ["Suggested grouping, [[1,2,3,4],[1,2,3,5],[1,2,3,4,5]]. Solutions can pass all the other tests if they just try to group without using any groups of 5. This test case breaks that since it requires both 4-groups and 5-groups."], | ||
"input": { | ||
"basket": [1,1,1,2,2,2,3,3,3,4,4,5,5] | ||
}, | ||
"expected": 8120 | ||
}, | ||
{ | ||
"property": "total", | ||
"description": "Shuffled book order", | ||
"comments": ["Suggested grouping, [[1,2,3,4],[1,2,3,5],[1,2,3,4,5]]. All the other tests give the books in sorted order. Robust solutions should be able to handle any order"], | ||
"input": { | ||
"basket": [1,2,3,4,5,1,2,3,4,5,1,2,3] | ||
}, | ||
"expected": 8120 | ||
} | ||
] | ||
} |
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 |
---|---|---|
@@ -1,13 +1,26 @@ | ||
{%- import "generator_macros.j2" as macros with context -%} | ||
{{ macros.header() }} | ||
|
||
class {{ exercise | camel_case }}Test(unittest.TestCase): | ||
{% for casegroup in cases %}{% for case in casegroup["cases"] -%} | ||
{% macro test_case(case) -%} | ||
{%- set input = case["input"] -%} | ||
def test_{{ case["description"] | to_snake }}(self): | ||
basket = {{ input["basket"] }} | ||
self.assertEqual({{ case["property"] }}(basket), {{ case["expected"] }}) | ||
{%- endmacro %} | ||
{{ macros.header() }} | ||
|
||
class {{ exercise | camel_case }}Test(unittest.TestCase): | ||
{% for casegroup in cases %} | ||
{% for case in casegroup["cases"] -%} | ||
{{ test_case(case) }} | ||
{% endfor %} | ||
{% endfor %} | ||
|
||
{% if additional_cases | length -%} | ||
|
||
# Additional tests for this track | ||
|
||
{% endfor %}{% endfor %} | ||
{% for case in additional_cases -%} | ||
{{ test_case(case) }} | ||
{% endfor %} | ||
{%- endif %} | ||
|
||
{{ macros.footer() }} | ||
{{ macros.footer() }} |
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