Created
October 17, 2016 01:41
-
-
Save jorgemdnt/b90f6168cbf656f66a4a27b03a95935b to your computer and use it in GitHub Desktop.
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
# coding=utf-8 | |
import unittest | |
import requests | |
import mock | |
from star_wars.starwars_gateway_swapi import StarWarsGatewaySWAPI | |
from star_wars.exceptions import PersonagemNaoEncontradoException | |
# [...] StarWarsGatewaySWAPITests | |
def test_lanca_excecao_quando_personagem_nao_existe(self): | |
retorno_json = { | |
'count': 0, | |
'results': [] | |
} | |
mock_response = mock.Mock(status_code=200) | |
mock_response.json.return_value = retorno_json | |
self.client.get.return_value = mock_response | |
with self.assertRaises(PersonagemNaoEncontradoException) as context: | |
self.dados_star_wars_gateway.buscar_personagem(nome='Spock') | |
self.assertEqual('Personagem Spock não encontrado', context.exception.message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment