def test_fail_safe_set1(self):
     test_return = fail_safe(temperature=100,
                             neutrons_produced_per_second=18,
                             threshold=5000)
     self.assertEqual(test_return,
                      'LOW',
                      msg=f"Expected LOW but returned {test_return}")
 def test_fail_safe_set5(self):
     test_return = fail_safe(temperature=100,
                             neutrons_produced_per_second=45,
                             threshold=5000)
     self.assertEqual(test_return,
                      'NORMAL',
                      msg=f"Expected NORMAL but returned {test_return}")
 def test_fail_safe_set9(self):
     test_return = fail_safe(temperature=1000,
                             neutrons_produced_per_second=25,
                             threshold=5000)
     self.assertEqual(test_return,
                      'DANGER',
                      msg=f"Expected DANGER but returned {test_return}")
Example #4
0
    def test_fail_safe(self):
        temp = 10
        threshold = 10000
        test_data = ((399, 'LOW'), (300, 'LOW'), (1, 'LOW'), (0, 'LOW'),
                     (901, 'NORMAL'), (1000, 'NORMAL'), (1099, 'NORMAL'),
                     (899, 'LOW'), (700, 'LOW'), (400, 'LOW'),
                     (1101, 'DANGER'), (1200, 'DANGER'))

        for variant, (neutrons_per_second, expected) in enumerate(test_data,
                                                                  start=1):
            with self.subTest(f'variation #{variant}',
                              temp=temp,
                              neutrons_per_second=neutrons_per_second,
                              threshold=threshold,
                              expected=expected):

                # pylint: disable=assignment-from-no-return
                actual_result = fail_safe(temp, neutrons_per_second, threshold)
                failure_message = (
                    f'Expected {expected} but returned {actual_result} with T={temp}, '
                    f'neutrons={neutrons_per_second}, threshold={threshold}')
                self.assertEqual(actual_result, expected, failure_message)
Example #5
0
    def test_fail_safe(self):
        temperature = 10
        threshold = 10000
        test_data = ((399, 'LOW'), (300, 'LOW'), (1, 'LOW'), (0, 'LOW'),
                     (901, 'NORMAL'), (1000, 'NORMAL'), (1099, 'NORMAL'),
                     (899, 'DANGER'), (700, 'DANGER'), (400, 'DANGER'),
                     (1101, 'DANGER'), (1200, 'DANGER'))

        for variant, data in enumerate(test_data, start=1):
            neutrons_produced_per_second, expected = data

            with self.subTest(
                    f"variation #{variant}",
                    temperature=temperature,
                    neutrons_produced_per_second=neutrons_produced_per_second,
                    threshold=threshold,
                    expected=expected):

                got = fail_safe(temperature, neutrons_produced_per_second,
                                threshold)
                msg = f"Expected {expected} but returned {got} with T={temperature}, " \
                      f"neutrons={neutrons_produced_per_second}, threshold={threshold}"
                self.assertEqual(got, expected, msg)