Created
September 14, 2012 01:52
-
-
Save tarsisazevedo/3719345 to your computer and use it in GitHub Desktop.
Mock fail
This file contains hidden or 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
| def test_widget_obter_contexto_semantico(self): | |
| with mock.patch("semantica.repositories.SparqlRepository") as MockClass: | |
| instance = MockClass.return_value | |
| instance.select.return_value = [{'label': 'Rio de Janeiro', 'slug': 'rio-de-janeiro', 'sigla': 'rj'}] | |
| widget = WidgetHeaderPaginaCidade(None, None) | |
| # mock do container | |
| widget.conteudo_container = { | |
| 'contexto': { | |
| 'individuo': { | |
| 'label': { | |
| 'valor': 'Rio de Janeiro', | |
| }, | |
| 'slug_topico': { | |
| 'valor': 'rio-de-janeiro' | |
| } | |
| }, | |
| 'uri_individuo': 'http://semantica.globo.com/base/Cidade_Rio_de_Janeiro_RJ', | |
| } | |
| } | |
| expected = { | |
| 'header': { | |
| 'logo': { | |
| 'image': '/static/header_pagina_cidades/cda/img/marca.png', | |
| 'link': 'http://%s:8000' % settings.SERVER_NAME, | |
| 'title': 'G1' | |
| }, | |
| 'titulo': { | |
| 'link': '/rj/rio-de-janeiro/cidade/rio-de-janeiro.html', | |
| 'title': 'Rio de Janeiro' | |
| }, | |
| 'breadcrumbs': [ | |
| { | |
| 'link': '/rj/rio-de-janeiro/', | |
| 'title': 'Rio de Janeiro' | |
| } | |
| ] | |
| } | |
| } | |
| self.assertEqual( | |
| expected, | |
| widget.obter_contexto_semantico() | |
| ) | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ERROR: test_widget_obter_contexto_semantico (g1.componentes.semantica.widget_header_pagina_cidades.tests.unit.test_widget_header_pagina_cidade.WidgetHeaderPaginaCidadeTestCase)
Traceback (most recent call last):
File "/Users/tarsis/.virtualenvs/core-43/lib/python2.7/site-packages/mocker.py", line 149, in test_method_wrapper
result = test_method()
File "/Users/tarsis/Sites/Projetos/Globo.com/g1/g1/../g1/componentes/semantica/widget_header_pagina_cidades/tests/unit/test_widget_header_pagina_cidade.py", line 220, in test_widget_obter_contexto_semantico
widget.obter_contexto_semantico()
File "/Users/tarsis/Sites/Projetos/Globo.com/g1/g1/componentes/semantica/widget_header_pagina_cidades/widgets.py", line 138, in obter_contexto_semantico
regiao
File "/Users/tarsis/Sites/Projetos/Globo.com/g1/g1/componentes/semantica/widget_header_pagina_cidades/widgets.py", line 70, in obtem_breadcrumb_da_regiao
contexto['uri_individuo']
File "/Users/tarsis/Sites/Projetos/Globo.com/g1/g1/topico_novo/templatetags/afiliadas.py", line 21, in regiao_cidade
repository = SparqlRepository()
File "/Users/tarsis/.virtualenvs/core-43/lib/python2.7/site-packages/semantica/repositories.py", line 187, in init
super(SparqlRepository, self).init()
TypeError: must be type, not MagicMock