From f8ead5d8fbaba38364702332a50a87471175b65e Mon Sep 17 00:00:00 2001 From: schneefux Date: Wed, 8 Oct 2014 16:41:20 +0200 Subject: Add test for keyword phrase extraction --- client/test.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'client/test.py') diff --git a/client/test.py b/client/test.py index f661b89..0269d18 100644 --- a/client/test.py +++ b/client/test.py @@ -40,6 +40,19 @@ class TestVocabCompiler(unittest.TestCase): extracted_phrases = vocabcompiler.get_all_phrases() self.assertEqual(expected_phrases, extracted_phrases) + def testKeywordPhraseExtraction(self): + expected_phrases = ['MOCK'] + + with tempfile.TemporaryFile() as f: + # We can't use mock_open here, because it doesn't seem to work + # with the 'for line in f' syntax + f.write("MOCK\n") + f.seek(0) + with patch('%s.open' % vocabcompiler.__name__, + return_value=f, create=True): + extracted_phrases = vocabcompiler.get_keyword_phrases() + self.assertEqual(expected_phrases, extracted_phrases) + class TestVocabulary(unittest.TestCase): VOCABULARY = vocabcompiler.DummyVocabulary -- cgit v1.3.1