Пример #1
0
    def test004_createsCaloricBalanceBadInput(self):
        from main import createCaloricBalance

        gender = 'f'
        age = '23'
        height = '65'
        weight = '130'

        self.input_response_list = [
            "   ", "  \t\n", gender, "0", "-17", "zero", age, "   ", "  \t\n",
            "0", "-17", "zero", height, "   ", "  \t\n", "0", "-17", "zero",
            weight
        ]

        cb = createCaloricBalance()

        expected = -1417.9
        actual = cb.getBalance()
        self.assertAlmostEqual(
            actual, expected, 2,
            'Your result (%s) is not close enough to (%s)' %
            (actual, expected))

        expected = 1417.9
        actual = cb.getBMR(gender, float(age), float(height), float(weight))
        self.assertAlmostEqual(
            actual, expected, 2,
            'Your result (%s) is not close enough to (%s)' %
            (actual, expected))
Пример #2
0
    def test006_createsCaloricBalanceBadGenderOption(self):
        from main import createCaloricBalance

        gender = 'x'
        age = '26'
        height = '70.5'
        weight = '185'

        self.input_response_list = [
            "   ", "  \t\n", gender, "0", "-17", "zero", age, "   ", "  \t\n",
            "0", "-17", "zero", height, "   ", "  \t\n", "0", "-17", "zero",
            weight
        ]

        cb = createCaloricBalance()

        expected = 0.0
        actual = cb.getBalance()
        self.assertEqual(
            actual, expected,
            'Your result (%s) is not equal to (%s)' % (actual, expected))

        expected = 0.0
        actual = cb.getBMR(gender, float(age), float(height), float(weight))
        self.assertEqual(
            actual, expected,
            'Your result (%s) is not equal to (%s)' % (actual, expected))
Пример #3
0
    def test003_createsCaloricBalanceCheckInstance(self):
        from main import createCaloricBalance

        gender = 'f'
        age = '23'
        height = '65'
        weight = '130'

        self.input_response_list = [
            gender + "\n", age + "\n", height + "\n", weight + "\n"
        ]
        cb = createCaloricBalance()

        expected = -1417.9
        actual = cb.getBalance()
        self.assertAlmostEqual(
            actual, expected, 2,
            'Your result (%s) is not close enough to (%s)' %
            (actual, expected))

        expected = 1417.9
        actual = cb.getBMR('f', 23.0, 65.0, 130.0)
        self.assertAlmostEqual(
            actual, expected, 2,
            'Your result (%s) is not close enough to (%s)' %
            (actual, expected))
Пример #4
0
    def test002_createsCaloricBalanceInstance(self):
        from main import createCaloricBalance
        from caloric_balance import CaloricBalance

        gender = 'f'
        age = '23'
        height = '65'
        weight = '130'

        self.input_response_list = [gender + "\n", age + "\n", height + "\n", weight + "\n"]
        cb = createCaloricBalance()
        self.assertTrue(isinstance(cb, CaloricBalance), 'The returned value is not an instance of CaloricBalance')