fix service settings letter branding tests

some tests are now expanded to handle the fact that letter branding
can be null
This commit is contained in:
Leo Hemsted
2019-02-05 16:34:05 +00:00
parent 3be82bafd5
commit 5405c2e1be
5 changed files with 144 additions and 62 deletions

View File

@@ -1,11 +1,38 @@
from app.notify_client.letter_branding_client import LetterBrandingClient
def test_get_letter_branding(mocker):
mock_get = mocker.patch('app.notify_client.letter_branding_client.LetterBrandingClient.get')
LetterBrandingClient().get_letter_branding()
mock_get.assert_called_once_with(
url='/dvla_organisations'
def test_get_letter_branding(mocker, fake_uuid):
mock_get = mocker.patch(
'app.notify_client.letter_branding_client.LetterBrandingClient.get',
return_value={'foo': 'bar'}
)
mock_redis_get = mocker.patch('app.notify_client.RedisClient.get', return_value=None)
mock_redis_set = mocker.patch('app.notify_client.RedisClient.set')
LetterBrandingClient().get_letter_branding(fake_uuid)
mock_get.assert_called_once_with(url='/letter-branding/{}'.format(fake_uuid))
mock_redis_get.assert_called_once_with('letter_branding-{}'.format(fake_uuid))
mock_redis_set.assert_called_once_with(
'letter_branding-{}'.format(fake_uuid),
'{"foo": "bar"}',
ex=604800,
)
def test_get_all_letter_branding(mocker):
mock_get = mocker.patch('app.notify_client.letter_branding_client.LetterBrandingClient.get', return_value=[1, 2, 3])
mock_redis_get = mocker.patch('app.notify_client.RedisClient.get', return_value=None)
mock_redis_set = mocker.patch('app.notify_client.RedisClient.set')
LetterBrandingClient().get_all_letter_branding()
mock_get.assert_called_once_with(url='/letter-branding')
mock_redis_get.assert_called_once_with('letter_branding')
mock_redis_set.assert_called_once_with(
'letter_branding',
'[1, 2, 3]',
ex=604800,
)