Skip to content

Commit

Permalink
Add tests for system check
Browse files Browse the repository at this point in the history
  • Loading branch information
enkore committed Sep 18, 2016
1 parent 30febb2 commit 9d846ee
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/crypto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

from django.core.checks import Error

import pytest

from index_service.crypto import check_server_private_key


@pytest.mark.parametrize('private_key', (
'123', b'1234', bytes(31), bytes(31).hex()
))
def test_check_server_private_key_invalid(settings, private_key):
settings.SERVER_PRIVATE_KEY = private_key
errors = check_server_private_key(None)
assert errors
assert isinstance(errors[0], Error)


@pytest.mark.parametrize('private_key', (
None, bytes(32), bytes(32).hex()
))
def test_check_server_private_key(settings, private_key):
settings.SERVER_PRIVATE_KEY = private_key
errors = check_server_private_key(None)
assert not errors

0 comments on commit 9d846ee

Please sign in to comment.