コード例 #1
0
    def test_pause_at_update(self, bp: BasePage, pp: PopulationPage):
        """
        Tests that 'Pause at Update' setting will allow user to automatically
        pause the experiment at the given update.

        :return: None.
        """

        # Setup pause settings.
        pp.enable_pause_at_update()
        pp.edit_pause_update(9)

        # Set up the rest of the experiment.
        bp.add_ancestor_to_dish()

        # Run the experiment.
        bp.run_from_menu()

        # Wait long enough for experiment to have reached update 9.
        bp.util.sleep(10, "Waiting for experiment to pause automatically.")

        # Check that pause worked properly.
        assert pp.get_pop_current_update() == 9

        # Wait to make sure it is paused.
        bp.util.sleep(1, "Ensuring that experiment is paused.")
        assert pp.get_pop_current_update() == 9
コード例 #2
0
    def test_pop_stats_sanity_ancestor(self, bp: BasePage, pp: PopulationPage):
        """
        Tests that running an experiment with @ancestor for a brief period of
        time does not lead to any unexpected values in the population statistics
        window.

        :return: None.
        """

        # Add @ancestor to dish.
        bp.add_ancestor_to_dish()

        # Run the experiment for a while, then pause it.
        bp.run_from_menu()
        bp.util.sleep(15, "Waiting for updates to occur.")
        bp.pause_from_menu()
        bp.util.sleep(1, "Waiting for pause to take affect.")

        # Test that population stats are valid.
        assert pp.get_pop_current_update() > 0
        assert pp.get_pop_num_orgs() > 1
        assert pp.get_pop_avg_fit() >= 0.0
        assert pp.get_pop_avg_energy_rate() > 0
        assert pp.get_pop_avg_offspring_cost() > 0
        assert pp.get_pop_avg_age() >= 0
コード例 #3
0
    def test_exp_run_controls(self, bp: BasePage, pp: PopulationPage):
        """
        Tests that a simple experiment can be run and that running, pausing, and
        doing one update work as expected.

        :return: None.
        """

        # Add @ancestor to dish.
        bp.add_ancestor_to_dish()

        # Run the experiment.
        bp.run_from_menu()
        bp.util.sleep(3, "Waiting for updates to occur.")

        # Assert that updates have occurred.
        assert pp.get_pop_current_update() > 0
        assert pp.gr_get_pop_current_update() > 0

        # Pause the experiment.
        bp.pause_from_menu()
        bp.util.sleep(1, "Making sure pause goes into effect.")

        # Get current update, wait a few seconds, assert it has not changed.
        current_update = pp.get_pop_current_update()
        bp.util.sleep(3, "Ensuring no updates occur after pause.")
        assert pp.get_pop_current_update() == current_update

        # Do one update
        bp.forward_from_menu()
        bp.util.sleep(1, "Making sure update has time to occur.")
        assert (pp.get_pop_current_update() - current_update) == 1
コード例 #4
0
    def test_check_calcs(self, bp: BasePage, pp: PopulationPage):
        """
        Tests calculation of avg fitness, offspring cost, and energy acq. rate (as well as # of viable orgs).

        :return: None.
        """
        bp.add_ancestor_to_dish()
        pp.run_from_pop()
        bp.util.sleep(10, "Waiting for experiment to run for a while.")
        pp.pause_from_pop()
        bp.util.sleep(10, "Waiting for pause.")
        calculated_values = pp.calculate_pop_averages()

        assert calculated_values[0] == pp.get_pop_current_viable()
        assert abs(calculated_values[1] - pp.get_pop_avg_fit()) < 0.2
        assert abs(calculated_values[2] -
                   pp.get_pop_avg_offspring_cost()) < 0.2
        assert abs(calculated_values[3] - pp.get_pop_avg_energy_rate()) < 0.2
コード例 #5
0
    def test_input_dishsize_str(self, bp: BasePage, pp: PopulationPage):
        """
        Tests that crashes and unexpected behaviors do not occur if a
        non-numeric string is given to the dish size boxes.

        :return: None.
        """

        # Edit dish size with string values.
        pp.show_env_settings()
        pp.edit_dish_cols("sample text")
        pp.hide_env_settings()
        assert pp.check_size_cells_error()

        # Add an organism to the experiment and try to run it.
        bp.add_ancestor_to_dish()
        pp.run_from_pop()

        # Wait for a short period so that response to run attempt occurs.
        bp.util.sleep(3)
コード例 #6
0
    def test_input_dishsize_zero(
        self,
        bp: BasePage,
        pp: PopulationPage,
    ):
        """
        Tests that crashes and unexpected behaviors do not occur if a dish size
        dimension is set to 0.

        :return: None.
        """

        # Edit dish size with value zero.
        pp.show_env_settings()
        pp.edit_dish_cols("0")
        pp.hide_env_settings()
        assert pp.check_size_cells_error()

        # Add an organism to the experiment and try to run it.
        bp.add_ancestor_to_dish()
        pp.run_from_pop()

        # Wait for a short period so that response to run attempt occurs.
        bp.util.sleep(3)