Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Store upgrade_10_11 warning logs as notes, closes #67
- Loading branch information
1 parent
e69fc52
commit b95847e
Showing
3 changed files
with
60 additions
and
4 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
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,37 @@ | ||
import json | ||
from collections import OrderedDict | ||
from unittest.mock import patch | ||
|
||
from django.test import SimpleTestCase | ||
from ocdskit.upgrade import upgrade_10_11 | ||
|
||
from process.models import CollectionNote | ||
from process.util import create_logger_note | ||
|
||
|
||
class UtilTests(SimpleTestCase): | ||
@patch("process.util.create_note") | ||
def test_create_logger_note(self, create_note): | ||
with create_logger_note("collection", "ocdskit"): | ||
upgrade_10_11( | ||
json.loads( | ||
'{"tender":{"tenderers":[{"name":"Acme Inc.","identifier":{"id":1}}]},"awards":[{"suppliers":' | ||
'[{"name":"Acme Inc.","identifier":{"id":1},"additionalIdentifiers":[{"id":"a"}]}]}]}', | ||
object_pairs_hook=OrderedDict, | ||
) | ||
) | ||
|
||
create_note.assert_called_once_with( | ||
"collection", | ||
CollectionNote.Level.WARNING, | ||
'party in "supplier" role differs from party in ["tenderer"] roles:\n{"name": "Acme Inc.", "identifier": ' | ||
'{"id": 1}, "additionalIdentifiers": [{"id": "a"}], "id": "3c9756cf8983b14066a034079aa7aae4"}\n{"id": ' | ||
'"3c9756cf8983b14066a034079aa7aae4", "name": "Acme Inc.", "identifier": {"id": 1}}\n', | ||
) | ||
|
||
@patch("process.util.create_note") | ||
def test_create_logger_note_not_called(self, create_note): | ||
with create_logger_note("collection", "ocdskit"): | ||
upgrade_10_11({}) | ||
|
||
create_note.assert_not_called() |