This repository has been archived by the owner on Mar 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #362 from alphagov/fix-integer-auto-id-error
Fix integer auto id error
- Loading branch information
Showing
2 changed files
with
21 additions
and
1 deletion.
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,20 @@ | ||
from unittest import TestCase | ||
from hamcrest import assert_that, is_ | ||
from nose.tools import assert_raises | ||
from backdrop.core.records import _generate_auto_id | ||
from backdrop.core.errors import ValidationError | ||
|
||
|
||
class TestRecords(TestCase): | ||
def test__generate_auto_id_generates_auto_ids_correctly_for_standard_case(self): | ||
assert_that(_generate_auto_id({'foo': 'foo'}, ['foo']), is_('Zm9v')) | ||
|
||
def test__generate_auto_id_generates_auto_ids_correctly_for_integers(self): | ||
assert_that(_generate_auto_id({'foo': 1, 'bar': 'foo'}, ['foo', 'bar']), is_('MS5mb28=')) | ||
|
||
def test__generate_auto_id_throws_error_when_key_not_matched(self): | ||
assert_raises( | ||
ValidationError, | ||
_generate_auto_id, | ||
{'foo': 1}, | ||
['bar']) |