From 4b2b9d05e17e43cd554667fb3854f93cbe318e28 Mon Sep 17 00:00:00 2001 From: shunyi Date: Sun, 3 Apr 2016 17:25:23 +0800 Subject: [PATCH] [#84] Remove the stored test data for SpanishDict --- zdict/tests/dictionaries/spanish/__init__.py | 0 zdict/tests/dictionaries/spanish/content.json | 19 ----- .../dictionaries/spanish/test_spanish.py | 60 -------------- .../tests/dictionaries/spanish/testdata.html | 78 ------------------- zdict/tests/dictionaries/test_spanish.py | 50 ++++++++++++ 5 files changed, 50 insertions(+), 157 deletions(-) delete mode 100644 zdict/tests/dictionaries/spanish/__init__.py delete mode 100644 zdict/tests/dictionaries/spanish/content.json delete mode 100644 zdict/tests/dictionaries/spanish/test_spanish.py delete mode 100644 zdict/tests/dictionaries/spanish/testdata.html create mode 100644 zdict/tests/dictionaries/test_spanish.py diff --git a/zdict/tests/dictionaries/spanish/__init__.py b/zdict/tests/dictionaries/spanish/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/zdict/tests/dictionaries/spanish/content.json b/zdict/tests/dictionaries/spanish/content.json deleted file mode 100644 index d5ab55d0..00000000 --- a/zdict/tests/dictionaries/spanish/content.json +++ /dev/null @@ -1,19 +0,0 @@ -{"explains": [["noun", - [["(language)", - [["a. el español (M)", - "The Spanish spoken in the Americas differs somewhat from European Spanish.", - "El español que se habla en América es algo diferente del que se habla en Europa."], - ["b. el castellano (M)", - "My knowledge of Spanish accelerated after moving to Madrid. ", - "Mi conocimiento del castellano aumentó después de mudarme a Madrid. "]]]]], - ["adjective", - [["(of Spanish origin)", - [["a. español", - "Spanish omelette is one of my favorite dishes.", - "La tortilla española es uno de mis platos favoritos."]]]]], - ["plural noun", - [["(inhabitants of Spain)", - [["a. los españoles (M)", - "The Spanish are known for a culture of food that is delicious and diverse. ", - "Los españoles son conocidos por una cultura de comida que es deliciosa y variada. "]]]]]], - "word": "Spanish"} diff --git a/zdict/tests/dictionaries/spanish/test_spanish.py b/zdict/tests/dictionaries/spanish/test_spanish.py deleted file mode 100644 index c2b38e2e..00000000 --- a/zdict/tests/dictionaries/spanish/test_spanish.py +++ /dev/null @@ -1,60 +0,0 @@ -import json -import os - -from pytest import raises -from unittest.mock import Mock, patch - -from zdict.dictionaries.spanish import SpanishDict -from zdict.exceptions import NotFoundError -from zdict.models import Record - - -RAW_HTML_TEST_DATA = os.path.join(os.path.dirname(__file__), 'testdata.html') -CONTENT_TEST_DATA = os.path.join(os.path.dirname(__file__), 'content.json') - - -class TestSpansishDict: - def setup_method(self, method): - self.dict = SpanishDict() - self.word = 'Spanish' - self.timeout = 5 - with open(CONTENT_TEST_DATA, 'r') as f: - self.content = f.read() - with open(RAW_HTML_TEST_DATA, 'r') as f: - self.raw_html = f.read() - - def teardown_method(self, method): - del self.dict - - def test_provider(self): - assert self.dict.provider == 'spanish' - - def test_title(self): - assert self.dict.title == 'SpanishDict' - - def test__get_url(self): - url = 'http://www.spanishdict.com/translate/{}'.format(self.word) - assert url == self.dict._get_url(self.word) - - def test_show(self): - content = self.content - r = Record(word=self.word, content=content, source=self.dict.provider) - - # god bless this method, hope that it do not raise any exception - self.dict.show(r) - - @patch('zdict.dictionaries.spanish.Record') - def test_query_normal(self, Record): - self.dict._get_raw = Mock(return_value=self.raw_html) - self.dict.query(self.word, self.timeout) - Record.assert_called_with( - word=self.word, - content=json.dumps(json.loads(self.content)), - source='spanish', - ) - - def test_query_not_found(self): - self.dict._get_raw = Mock(return_value='
') - with raises(NotFoundError): - self.dict.query(self.word, self.timeout) - self.dict._get_raw.assert_called_with(self.word, self.timeout) diff --git a/zdict/tests/dictionaries/spanish/testdata.html b/zdict/tests/dictionaries/spanish/testdata.html deleted file mode 100644 index cab4894d..00000000 --- a/zdict/tests/dictionaries/spanish/testdata.html +++ /dev/null @@ -1,78 +0,0 @@ -Spanish in Spanish | English to Spanish Translation
Spanish
noun
1. (language) 
a. el español (M) 
The Spanish spoken in the Americas differs somewhat from European Spanish.El español que se habla en América es algo diferente del que se habla en Europa.
b. el castellano (M) 
My knowledge of Spanish accelerated after moving to Madrid. Mi conocimiento del castellano aumentó después de mudarme a Madrid.
adjective
2. (of Spanish origin) 
a. español 
Spanish omelette is one of my favorite dishes.La tortilla española es uno de mis platos favoritos.
plural noun
3. (inhabitants of Spain) 
a. los españoles (M) 
The Spanish are known for a culture of food that is delicious and diverse. Los españoles son conocidos por una cultura de comida que es deliciosa y variada.
Spanish
Noun
1. (people) 
the Spanishlos españoles
2. (language) 
a. el español m, castellano (M) 
Spanish class/teacherclase f/profesor(ora) m, de español
adjective
3. (general) 
a. español(ola) 
the Spanish Armadala Armada Invencible
the Spanish Civil Warla guerra civil española
the Spanish Inquisitionla (Santa) Inquisición
Spanish omelettortilla española or de
Spanish [ˈspænɪʃ]
adjective
español
noun
1
the Spanish (people) los españoles
2 (Ling) español (m); castellano (m); especially (LAm)
modifier
Spanish America (n) Hispanoamérica (f)
the Spanish Armada (n) la Armada invencible
Spanish chestnut (n) castaña (f) dulce
Spanish fly (n) cantárida (f)
Spanish guitar (n) guitarra (f) española
Search history
Did this page answer your question?
diff --git a/zdict/tests/dictionaries/test_spanish.py b/zdict/tests/dictionaries/test_spanish.py new file mode 100644 index 00000000..d663e333 --- /dev/null +++ b/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='
') + with raises(NotFoundError): + self.d.query(self.word, self.timeout) + self.d._get_raw.assert_called_with(self.word, self.timeout)