Make sure status dictionary is assinged each time

The status dictionary was being assigned once, and then subsequent
uses of it were by reference. This meant that each template type was
pointing at the same dictionary, and updating one meant updating all.

This commit adds a dictionary comprehension, which gets evaluated once
for each template type, so each template type has its own `dict` of
statuses.

Before
--
```
Email     SMS       Letter
  |        |           |
{'sending':, 'failed', …}
```

After
--
```
Email                SMS                   Letter
   |                  |                      |
{'sending':,      {'sending':,            {'sending':,
'failed',          'failed',               'failed',
…}                 …}                      …}
```
This commit is contained in:
Chris Hill-Scott
2017-02-07 13:06:32 +00:00
parent 4805ccdeed
commit 0dfa4a93d5
2 changed files with 6 additions and 6 deletions

View File

@@ -545,8 +545,8 @@ def test_fetch_monthly_historical_stats_separates_weeks(notify_db, notify_db_ses
('2017-03', 'created', 2),
):
assert result[date]['sms'][status] == count
assert result[date]['email'][status] == count
assert result[date]['letter'][status] == count
assert result[date]['email'][status] == 0
assert result[date]['letter'][status] == 0
assert result.keys() == {
'2016-04', '2016-05', '2016-06',