def test_runs(self):
        problem_id = colab_logging.get_uuid()
        colab_logging.log_problem(self.inputs,
                                  self.output,
                                  self.constants,
                                  self.description,
                                  self.settings,
                                  include_in_dataset=True,
                                  problem_id=problem_id)

        results = colab_interface.run_value_search_from_colab(
            self.inputs, self.output, self.constants, self.description,
            self.settings)

        colab_logging.log_result(results,
                                 include_in_dataset=True,
                                 problem_id=problem_id)

        colab_logging._IPYTHON_MOCK.display.HTML.assert_called_once()
        colab_logging._IPYTHON_MOCK.display.Javascript.assert_called()
        js_strings = [
            call_args[0] for call_args in (
                colab_logging._IPYTHON_MOCK.display.Javascript.call_args_list)
        ]
        self.assertTrue(all(js_strings))  # None of them are empty or None.
    def test_too_large_logging_dict(self):
        # Pretend that there are very few dimensions, so that the serialized logging
        # dict is too large to send to GA.
        old_num_dimensions = colab_logging.NUM_DIMENSIONS
        colab_logging.NUM_DIMENSIONS = 5

        problem_id = colab_logging.get_uuid()
        colab_logging.log_problem(self.inputs,
                                  self.output,
                                  self.constants,
                                  self.description,
                                  self.settings,
                                  include_in_dataset=True,
                                  problem_id=problem_id)

        results = colab_interface.run_value_search_from_colab(
            self.inputs, self.output, self.constants, self.description,
            self.settings)

        colab_logging.log_result(results,
                                 include_in_dataset=True,
                                 problem_id=problem_id)

        colab_logging._IPYTHON_MOCK.display.HTML.assert_called_once()
        colab_logging._IPYTHON_MOCK.display.Javascript.assert_not_called()

        colab_logging.NUM_DIMENSIONS = old_num_dimensions
 def test_get_uuid_returns_different_results(self):
     # This test will fail with probability 2^-64.
     self.assertNotEqual(colab_logging.get_uuid(), colab_logging.get_uuid())