from fedal_cli.apis.spanglish import verb from fedal_cli.services.logger import get_logger from fedal_cli.services.requester import make_request from click.testing import CliRunner from unittest import TestCase import random logger = get_logger(loggername='spanglish') class TestSpanglishVerb(TestCase): def test_verb_dict(self): """ test if the verb module has a funcs dict with 5 objects """ verb_funcs = getattr(verb, 'funcs') logger.debug("verb funcs are: {}".format(verb_funcs)) self.assertEqual(type(verb_funcs), dict) self.assertTrue(len(verb_funcs), 5) def test_get_verbs(self): """ making a call to the get_verbs will exit successfully with code 0 """ get_verbs = getattr(verb, 'get_verbs') runner = CliRunner() result = runner.invoke(get_verbs, []) logger.debug("result get_verbs output: {}".format(result.output)) self.assertTrue(result.exit_code == 0)
from fedal_cli.configs import settings as conf from fedal_cli.services.requester import make_request from fedal_cli.services.tokens import get_token, get_token_cached_times_diff import click from click.testing import CliRunner from nose.tools import assert_true, assert_equal from fedal_cli.services.logger import get_logger import redis from datetime import datetime, timedelta logger = get_logger(loggername='test') class TestCLI: def xtest_make_get_with_args_request(self): """ test the make request method with a get action and a tuple of args """ assert_true(True)
from fedal_cli.apis import currency from fedal_cli.services.logger import get_logger from click.testing import CliRunner from unittest import TestCase logger = get_logger(loggername='currency') class TestCurrency(TestCase): def test_get_code_ok(self): """ provide param currency and gets back the symbol of the currency """ gc = getattr(currency, 'get_code') runner = CliRunner() result = runner.invoke(gc, ['--currency', 'EUR']) logger.debug("result.output: {}".format(result.output)) self.assertTrue(result.exit_code == 0) self.assertEqual('currency code is €\n', result.output) def test_convert_currency(self): """ pass three paramters and expects a string returned with the value as a result """ cc = getattr(currency, 'convert_currency') runner = CliRunner() result = runner.invoke(cc, ['--base', 'EUR', '--currency', 'USD', '--amount', '1000']) logger.debug("result.output: {}".format(result.output)) self.assertTrue(result.exit_code == 0)