def test_honors_max_regions(self):
        """Test that when force_num_regions is False, MAX_NUM_REGIONS is used to set region size.
        """

        r_size = summarize_coverage.get_region_size(50000, 10000, 0, 100,
                                                    False)

        ugly_expected_r_size = 50000.0 / \
            (summarize_coverage.Constants.MAX_NUM_REGIONS / 10000)
        pretty_expected_r_size = summarize_coverage.get_pretty_value(
            ugly_expected_r_size)
        self.assertEqual(r_size, pretty_expected_r_size)
    def test_honors_max_regions(self):
        """Test that when force_num_regions is False, MAX_NUM_REGIONS is used to set region size.
        """

        r_size = summarize_coverage.get_region_size(
            50000, 10000, 0, 100, False)

        ugly_expected_r_size = 50000.0 / \
            (summarize_coverage.Constants.MAX_NUM_REGIONS / 10000)
        pretty_expected_r_size = summarize_coverage.get_pretty_value(
            ugly_expected_r_size)
        self.assertEqual(r_size, pretty_expected_r_size)
    def test_pretty_is_nearby(self):
        """Test the pretty value is near the ugly value."""

        list_of_primes = self.primes(1000000)

        for prime in list_of_primes:
            pretty_prime = summarize_coverage.get_pretty_value(prime)

            diff_pct = min(abs(pretty_prime / float(prime) - 1),
                           abs(prime / float(pretty_prime) - 1))

            # This is not a very tight bound, but it's what we've got
            self.assertTrue(diff_pct < 0.55 or abs(prime - pretty_prime) < 10)
    def test_pretty_is_nearby(self):
        """Test the pretty value is near the ugly value."""

        list_of_primes = self.primes(1000000)

        for prime in list_of_primes:
            pretty_prime = summarize_coverage.get_pretty_value(prime)

            diff_pct = min(
                abs(pretty_prime / float(prime) - 1),
                abs(prime / float(pretty_prime) - 1))

            # This is not a very tight bound, but it's what we've got
            self.assertTrue(diff_pct < 0.55 or abs(prime - pretty_prime) < 10)