def test_save_data_when_switching_between_environments(qtbot): # given (a few environments) window = show_window(qtbot) add_environments(qtbot, window, NO_OF_ENVIRONMENTS) # setup data for selected environment selected_env = dict( position=2, data=[(fake.domain_word(), fake.first_name()) for _ in range(5)] ) set_environment_variables(qtbot, window, selected_env) # and (add variables for changed_env) changed_env = dict( position=3, data=[(fake.domain_word(), fake.first_name()) for _ in range(5)] ) set_environment_variables(qtbot, window, changed_env) # when (switch back to previously selected environment) select_environment(window, selected_env.get('position')) # then (the variables should be retained) actual_data = get_variables_for_selected_environment(window) assert actual_data == selected_env.get('data')
def test_load_environment_variables_after_restart(qtbot): # given (a new window and environments) window = show_window(qtbot) add_environments(qtbot, window, NO_OF_ENVIRONMENTS) # and (add variables for environment A) environment_a_data = dict( position=2, data=[(fake.domain_word(), fake.first_name()) for _ in range(5)] ) set_environment_variables(qtbot, window, environment_a_data) # and (switch to environment B and add variables) environment_b_data = dict( position=4, data=[(fake.domain_word(), fake.first_name()) for _ in range(5)] ) set_environment_variables(qtbot, window, environment_b_data) # and (close and save) close_and_save_environments(qtbot, window) # when (quit application) window.toolbar_controller.trigger_quit_application() # and (re-create window and display environments dialog) window = show_window(qtbot, clear_environments=False) # then (select environment A) select_environment(window, position=environment_a_data.get('position')) # and (check that environment variable matches with environment A) environment_a_variables = get_variables_for_selected_environment(window) assert environment_a_variables == environment_a_data.get('data') # and (select environment B) select_environment(window, position=environment_b_data.get('position')) # and (check that environment variable matches with environment B) environment_b_variables = get_variables_for_selected_environment(window) assert environment_b_variables == environment_b_data.get('data') # and (close again) close_and_save_environments(qtbot, window) # and (re-create window and display environments dialog) window = show_window(qtbot, clear_environments=False) # then (select environment A) select_environment(window, position=environment_a_data.get('position')) # and (check that environment variable matches with environment A) environment_a_variables = get_variables_for_selected_environment(window) assert environment_a_variables == environment_a_data.get('data')
def test_app_with_prepopulated_data(qtbot): # given (a new window) window = show_window(qtbot) # add some environments window.environment_view.show_dialog() add_environments(qtbot, window, 5) close_and_save_environments(qtbot, window) # add some environment variables selected_env = dict(position=2, data=[(fake.domain_word(), fake.first_name()) for _ in range(5)]) set_environment_variables(qtbot, window, selected_env) # add some steps for i in range(5): add_step_with_command(window, "HTTP", f" {i} - GET Request") add_step_with_command(window, "SQL", f" {i} - SELECT Request") interact(qtbot)
def test_environment_variable_persistence(qtbot): # given (a new window and environments) window = show_window(qtbot) add_environments(qtbot, window, NO_OF_ENVIRONMENTS) # and (few environment variables) selected_env = dict( position=2, data=[(fake.domain_word(), fake.first_name()) for _ in range(5)] ) selected_environment_name = set_environment_variables(qtbot, window, selected_env) # when (click ok) close_and_save_environments(qtbot, window) # then (should save have the selected environments) actual_saved_environment = window.world.environment_store.get_environment(selected_environment_name) assert actual_saved_environment # and (should save all environment variables) environment_variables = actual_saved_environment.variables assert len(environment_variables) == 5 assert environment_variables == {k: v for (k, v) in selected_env.get('data')}
def random_environment(): return fake.domain_word()