Example #1
0
 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
Example #2
0
 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;'
Example #3
0
 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
Example #4
0
from src.Quote import Quote
from src.Histogram import Histogram
from src.Translate import Translate

quote_obj = Quote()
histogram_obj = Histogram()
translate_obj = Translate()
quote = quote_obj.get_quote()
print(quote)
print(translate_obj.translate(quote))
histogram_obj.print_dict(histogram_obj.ret_sorted(quote))