* Move imports in owntracks component * Fix nacl import * Fix nacl import 2 * Fix nacl import 3 * Add helper.supports_encryption tests * Fix tests helper 1 * Fix tests 2 * Add not_supports_encryption + get_cipher_error tests * Code cov * Fix nacl_not_imported test
29 lines
808 B
Python
29 lines
808 B
Python
"""Test the owntracks_http platform."""
|
|
from unittest.mock import patch
|
|
import pytest
|
|
|
|
from homeassistant.components.owntracks import helper
|
|
|
|
|
|
@pytest.fixture(name="nacl_imported")
|
|
def mock_nacl_imported():
|
|
"""Mock a successful import."""
|
|
with patch("homeassistant.components.owntracks.helper.nacl"):
|
|
yield
|
|
|
|
|
|
@pytest.fixture(name="nacl_not_imported")
|
|
def mock_nacl_not_imported():
|
|
"""Mock non successful import."""
|
|
with patch("homeassistant.components.owntracks.helper.nacl", new=None):
|
|
yield
|
|
|
|
|
|
def test_supports_encryption(nacl_imported):
|
|
"""Test if env supports encryption."""
|
|
assert helper.supports_encryption()
|
|
|
|
|
|
def test_supports_encryption_failed(nacl_not_imported):
|
|
"""Test if env does not support encryption."""
|
|
assert not helper.supports_encryption()
|