def test4(self, func_quote): quote_obj = Quote() quote_obj.get_quote_as_dict = func_quote with open("/home/semaphore/QuoteTDD/tests/mockqoute1.json") as f: quote_obj.get_quote_as_dict.return_value = json.load(f) quote = quote_obj.get_quote() histogram_obj = Histogram() histogram_dict = histogram_obj.word_counter(quote) assert histogram_dict['buy'] == 2
def test5(self, func_quote): quote_obj = Quote() quote_obj.get_quote_as_dict = func_quote with open("/home/semaphore/QuoteTDD/tests/mockqoute1.json") as f: quote_obj.get_quote_as_dict.return_value = json.load(f) quote = quote_obj.get_quote() histogram_obj = Histogram() histogram_dict = histogram_obj.word_counter(quote) items = histogram_dict.items() min_dict = min(items, key=operator.itemgetter(1))[0] assert min_dict == 'gamble;'
def test5(self, func_quote, translate_func): quote_obj = Quote() quote_obj.get_quote_as_dict = func_quote with open("/home/semaphore/QuoteTDD/tests/mockqoute1.json") as f: quote_obj.get_quote_as_dict.return_value = json.load(f) quote = quote_obj.get_quote() translate_obj = Translate() translate_obj.translate = translate_func path = "/home/semaphore/QuoteTDD/tests/mocktranslate.txt" with open(path, encoding="utf8") as f2: translate_obj.translate.return_value = f2.read() result = translate_obj.translate(quote) strs = result.replace('[', '').split('],') assert strs[1].find('מלאי טוב') != -1