Exemplo n.º 1
0
    def __init__(self, data):
        self.accounts     = data['accounts']
        self.transactions = data['transactions']
        self.budgets      = data['budgets']
        self.reminders    = data['reminders']
        self.c            = None
        self.l            = 800

        cc = CurrencyCalculator()
        self.dolar = None
        try:
            self.dolar = cc.get_dolar()['real']
        except:
            self.dolar = settings.DOLAR

        self.pdf_chart_colors = [
            HexColor("#0000e5"),
            HexColor("#1f1feb"),
            HexColor("#5757f0"),
            HexColor("#8f8ff5"),
            HexColor("#c7c7fa"),
            HexColor("#f5c2c2"),
            HexColor("#eb8585"),
            HexColor("#e04747"),
            HexColor("#d60a0a"),
            HexColor("#cc0000"),
            HexColor("#ff0000"),
        ]
Exemplo n.º 2
0
class TestCurrencyCalculator(unittest.TestCase):

    __exchange_rate = 4.2

    def setUp(self):
        self.calculator = CurrencyCalculator()

    def test_calculator_has_exchange_rates(self):
        assert self.calculator.euro_exchange_rate is not None, "euro_exchange_rate is None"
        assert self.calculator.pound_exchange_rate is not None, "pound_exchange_rate is None"
        assert self.calculator.dollar_exchange_rate is not None, "dollar_exchange_rate is None"

    def test_calculator_set_exchange_rates(self):
        self.calculator.set_euro_exchange_rate(self.__exchange_rate)
        self.calculator.set_pound_exchange_rate(self.__exchange_rate)
        self.calculator.set_dollar_exchange_rate(self.__exchange_rate)

        assert self.calculator.euro_exchange_rate == self.__exchange_rate, "euro_exchange_rate did not set"
        assert self.calculator.pound_exchange_rate == self.__exchange_rate, "pound_exchange_rate did not set"
        assert self.calculator.dollar_exchange_rate == self.__exchange_rate, "dollar_exchange_rate did not set"

    def test_calculator_converts_to_pln(self):
        self.calculator.set_euro_exchange_rate(self.__exchange_rate)
        self.calculator.set_pound_exchange_rate(self.__exchange_rate)
        self.calculator.set_dollar_exchange_rate(self.__exchange_rate)

        assert self.calculator.convert_euro_to_pln(1) == self.__exchange_rate, "conversion euro to pln failed"
        assert self.calculator.convert_pound_to_pln(1) == self.__exchange_rate, "conversion pound to pln failed"
        assert self.calculator.convert_dollar_to_pln(1) == self.__exchange_rate, "conversion dollar to pln failed"

        assert self.calculator.convert_euro_to_pln(3) == 3*self.__exchange_rate, "conversion euro to pln failed"
        assert self.calculator.convert_pound_to_pln(3) == 3*self.__exchange_rate, "conversion pound to pln failed"
        assert self.calculator.convert_dollar_to_pln(3) == 3*self.__exchange_rate, "conversion dollar to pln failed"

        assert self.calculator.convert_euro_to_pln(3.4) == 3.4*self.__exchange_rate, "conversion euro to pln failed"
        assert self.calculator.convert_pound_to_pln(3.4) == 3.4*self.__exchange_rate, "conversion pound to pln failed"
        assert self.calculator.convert_dollar_to_pln(3.4) == 3.4*self.__exchange_rate, "conversion dollar to pln failed"
Exemplo n.º 3
0
class TestCurrencyCalculator(unittest.TestCase):

    __exchange_rate = 4.2

    def setUp(self):
        self.calculator = CurrencyCalculator()

    def test_calculator_has_exchange_rates(self):
        assert self.calculator.euro_exchange_rate is not None, "euro_exchange_rate is None"
        assert self.calculator.pound_exchange_rate is not None, "pound_exchange_rate is None"
        assert self.calculator.dollar_exchange_rate is not None, "dollar_exchange_rate is None"

    def test_calculator_set_exchange_rates(self):
        self.calculator.set_euro_exchange_rate(self.__exchange_rate)
        self.calculator.set_pound_exchange_rate(self.__exchange_rate)
        self.calculator.set_dollar_exchange_rate(self.__exchange_rate)

        assert self.calculator.euro_exchange_rate == self.__exchange_rate, "euro_exchange_rate did not set"
        assert self.calculator.pound_exchange_rate == self.__exchange_rate, "pound_exchange_rate did not set"
        assert self.calculator.dollar_exchange_rate == self.__exchange_rate, "dollar_exchange_rate did not set"

    def test_calculator_converts_to_pln(self):
        self.calculator.set_euro_exchange_rate(self.__exchange_rate)
        self.calculator.set_pound_exchange_rate(self.__exchange_rate)
        self.calculator.set_dollar_exchange_rate(self.__exchange_rate)

        assert self.calculator.convert_euro_to_pln(
            1) == self.__exchange_rate, "conversion euro to pln failed"
        assert self.calculator.convert_pound_to_pln(
            1) == self.__exchange_rate, "conversion pound to pln failed"
        assert self.calculator.convert_dollar_to_pln(
            1) == self.__exchange_rate, "conversion dollar to pln failed"

        assert self.calculator.convert_euro_to_pln(
            3) == 3 * self.__exchange_rate, "conversion euro to pln failed"
        assert self.calculator.convert_pound_to_pln(
            3) == 3 * self.__exchange_rate, "conversion pound to pln failed"
        assert self.calculator.convert_dollar_to_pln(
            3) == 3 * self.__exchange_rate, "conversion dollar to pln failed"

        assert self.calculator.convert_euro_to_pln(
            3.4) == 3.4 * self.__exchange_rate, "conversion euro to pln failed"
        assert self.calculator.convert_pound_to_pln(
            3.4
        ) == 3.4 * self.__exchange_rate, "conversion pound to pln failed"
        assert self.calculator.convert_dollar_to_pln(
            3.4
        ) == 3.4 * self.__exchange_rate, "conversion dollar to pln failed"
Exemplo n.º 4
0
 def setUp(self):
     self.calculator = CurrencyCalculator()
Exemplo n.º 5
0
 def setUp(self):
     self.calculator = CurrencyCalculator()