Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
[#84] Remove the stored test data for SpanishDict
Browse files Browse the repository at this point in the history
  • Loading branch information
shunyi authored and shunyi committed Apr 17, 2016
1 parent 48e9b78 commit 4b2b9d0
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 157 deletions.
Empty file.
19 changes: 0 additions & 19 deletions zdict/tests/dictionaries/spanish/content.json

This file was deleted.

60 changes: 0 additions & 60 deletions zdict/tests/dictionaries/spanish/test_spanish.py

This file was deleted.

78 changes: 0 additions & 78 deletions zdict/tests/dictionaries/spanish/testdata.html

This file was deleted.

50 changes: 50 additions & 0 deletions zdict/tests/dictionaries/test_spanish.py
@@ -0,0 +1,50 @@
from pytest import raises
from unittest.mock import Mock, patch

from zdict.dictionaries.spanish import SpanishDict
from zdict.exceptions import NotFoundError


class TestSpansishDict:
@classmethod
def setup_class(cls):
cls.d = SpanishDict()
cls.word = 'Spanish'
cls.timeout = 5
cls.record = cls.d.query(cls.word, cls.timeout)

@classmethod
def teardown_class(cls):
del cls.d
del cls.word
del cls.timeout
del cls.record

def test_provider(self):
assert self.d.provider == 'spanish'

def test_title(self):
assert self.d.title == 'SpanishDict'

def test__get_url(self):
url = 'http://www.spanishdict.com/translate/{}'.format(self.word)
assert url == self.d._get_url(self.word)

def test_show(self):
# god bless this method, hope that it do not raise any exception
self.d.show(self.record)

@patch('zdict.dictionaries.spanish.Record')
def test_query_normal(self, Record):
self.d.query(self.word, self.timeout)
Record.assert_called_with(
word=self.word,
content=self.record.content,
source='spanish',
)

def test_query_not_found(self):
self.d._get_raw = Mock(return_value='<div class="card"><div/>')
with raises(NotFoundError):
self.d.query(self.word, self.timeout)
self.d._get_raw.assert_called_with(self.word, self.timeout)

0 comments on commit 4b2b9d0

Please sign in to comment.