def set_up(self): """Ensure virtualenv present, then run all services.""" python_package = hitchpython.PythonPackage( python_version=self.preconditions['python_version'] ) python_package.build() python_package.verify() call([ python_package.pip, "install", "-r", path.join(PROJECT_DIRECTORY, "requirements/local.txt") ]) postgres_package = hitchpostgres.PostgresPackage( version=self.settings["postgres_version"], ) postgres_package.build() postgres_package.verify() redis_package = hitchredis.RedisPackage(version="2.8.4") redis_package.build() redis_package.verify() self.services = hitchserve.ServiceBundle( project_directory=PROJECT_DIRECTORY, startup_timeout=float(self.settings["startup_timeout"]), shutdown_timeout=5.0, ) postgres_user = hitchpostgres.PostgresUser("{{cookiecutter.repo_name}}", "password") self.services['Postgres'] = hitchpostgres.PostgresService( postgres_package=postgres_package, users=[postgres_user, ], databases=[hitchpostgres.PostgresDatabase("{{cookiecutter.repo_name}}", postgres_user), ] ) self.services['HitchSMTP'] = hitchsmtp.HitchSMTPService(port=1025) self.services['Django'] = hitchpython.DjangoService( python=python_package.python, port=8000, version=str(self.settings.get("django_version")), settings="config.settings.local", needs=[self.services['Postgres'], ], env_vars=self.settings['environment_variables'], ) self.services['Redis'] = hitchredis.RedisService( redis_package=redis_package, port=16379, )
def set_up(self): """Ensure virtualenv present, then run all services.""" python_package = hitchpython.PythonPackage( python_version=self.settings['python_version'] ) python_package.build() call([ python_package.pip, 'install', '-r', path.join(PROJECT_DIRECTORY, 'requirements/local.txt') ]) postgres_package = hitchpostgres.PostgresPackage() postgres_package.build() redis_package = hitchredis.RedisPackage() redis_package.build() self.services = hitchserve.ServiceBundle( project_directory=PROJECT_DIRECTORY, startup_timeout=float(self.settings['startup_timeout']), shutdown_timeout=float(self.settings['shutdown_timeout']), ) postgres_user = hitchpostgres.PostgresUser('{{cookiecutter.repo_name}}', 'password') self.services['Postgres'] = hitchpostgres.PostgresService( postgres_package=postgres_package, users=[postgres_user, ], databases=[hitchpostgres.PostgresDatabase('{{cookiecutter.repo_name}}', postgres_user), ] ) self.services['HitchSMTP'] = hitchsmtp.HitchSMTPService(port=1025) self.services['Django'] = hitchpython.DjangoService( python=python_package.python, port=8000, settings='config.settings.local', needs=[self.services['Postgres'], ], env_vars=self.settings['environment_variables'], ) self.services['Redis'] = hitchredis.RedisService( redis_package=redis_package, port=16379, )
def set_up(self): """Ensure virtualenv present, then run all services.""" python_package = hitchpython.PythonPackage( python_version=self.settings['python_version']) python_package.build() call([ python_package.pip, "install", "-r", path.join(PROJECT_DIRECTORY, "requirements/local.txt") ]) postgres_package = hitchpostgres.PostgresPackage() postgres_package.build() redis_package = hitchredis.RedisPackage() redis_package.build() self.services = hitchserve.ServiceBundle( project_directory=PROJECT_DIRECTORY, startup_timeout=float(self.settings["startup_timeout"]), shutdown_timeout=float(self.settings["shutdown_timeout"]), ) postgres_user = hitchpostgres.PostgresUser("django_bootstrap", "password") self.services['Postgres'] = hitchpostgres.PostgresService( postgres_package=postgres_package, users=[ postgres_user, ], databases=[ hitchpostgres.PostgresDatabase("django_bootstrap", postgres_user), ]) self.services['HitchSMTP'] = hitchsmtp.HitchSMTPService(port=1025) self.services['Django'] = hitchpython.DjangoService( python=python_package.python, port=8000, settings="config.settings.local", needs=[ self.services['Postgres'], ], env_vars=self.settings['environment_variables'], ) self.services['Redis'] = hitchredis.RedisService( redis_package=redis_package, port=16379, ) self.services['Firefox'] = hitchselenium.SeleniumService( xvfb=self.settings.get("xvfb", False), no_libfaketime=True, ) # import hitchcron # self.services['Cron'] = hitchcron.CronService( # run=self.services['Django'].manage("trigger").command, # every=1, # needs=[ self.services['Django'], ], # ) self.services.startup(interactive=False) # Docs : https://hitchtest.readthedocs.org/en/latest/plugins/hitchselenium.html self.driver = self.services['Firefox'].driver self.webapp = hitchselenium.SeleniumStepLibrary( selenium_webdriver=self.driver, wait_for_timeout=5, ) # Add selenium steps self.click = self.webapp.click self.wait_to_appear = self.webapp.wait_to_appear self.wait_to_contain = self.webapp.wait_to_contain self.wait_for_any_to_contain = self.webapp.wait_for_any_to_contain self.click_and_dont_wait_for_page_load = self.webapp.click_and_dont_wait_for_page_load # Configure selenium driver self.driver.set_window_size(self.settings['window_size']['height'], self.settings['window_size']['width']) self.driver.set_window_position(0, 0) self.driver.implicitly_wait(2.0) self.driver.accept_next_alert = True
def set_up(self): """Ensure virtualenv present, then run all services.""" python_package = hitchpython.PythonPackage( python_version=self.preconditions['python_version'] ) python_package.build() python_package.verify() call([ python_package.pip, "install", "-r", path.join(PROJECT_DIRECTORY, "requirements/local.txt") ]) postgres_package = hitchpostgres.PostgresPackage( version=self.settings["postgres_version"], ) postgres_package.build() postgres_package.verify() redis_package = hitchredis.RedisPackage(version="2.8.4") redis_package.build() redis_package.verify() self.services = hitchserve.ServiceBundle( project_directory=PROJECT_DIRECTORY, startup_timeout=float(self.settings["startup_timeout"]), shutdown_timeout=5.0, ) postgres_user = hitchpostgres.PostgresUser("studentloan5", "password") self.services['Postgres'] = hitchpostgres.PostgresService( postgres_package=postgres_package, users=[postgres_user, ], databases=[hitchpostgres.PostgresDatabase("studentloan5", postgres_user), ] ) self.services['HitchSMTP'] = hitchsmtp.HitchSMTPService(port=1025) self.services['Django'] = hitchpython.DjangoService( python=python_package.python, port=8000, version=str(self.settings.get("django_version")), settings="config.settings.local", needs=[self.services['Postgres'], ], env_vars=self.settings['environment_variables'], ) self.services['Redis'] = hitchredis.RedisService( redis_package=redis_package, port=16379, ) self.services['Firefox'] = hitchselenium.SeleniumService( xvfb=self.settings.get("quiet", False), no_libfaketime=True, ) # import hitchcron # self.services['Cron'] = hitchcron.CronService( # run=self.services['Django'].manage("trigger").command, # every=1, # needs=[ self.services['Django'], ], # ) self.services.startup(interactive=False) # Configure selenium driver self.driver = self.services['Firefox'].driver self.driver.set_window_size(self.settings['window_size']['height'], self.settings['window_size']['width']) self.driver.set_window_position(0, 0) self.driver.implicitly_wait(2.0) self.driver.accept_next_alert = True
def set_up(self): """Set up your applications and the test environment.""" self.python_package = hitchpython.PythonPackage( python_version=self.settings['python_version']) self.python_package.build() self.python_package.verify() check_call([ self.python_package.pip, "install", "-r", path.join(PROJECT_DIRECTORY, "requirements.txt") ]) #postgres_package = hitchpostgres.PostgresPackage( #version=self.settings["postgres_version"], #) #postgres_package.build() turkeydb_filename = path.join(hitchtest.utils.get_hitch_directory(), "turkey.db") if path.exists(turkeydb_filename): remove(turkeydb_filename) with open(path.join(PROJECT_DIRECTORY, "turkey.conf"), "w") as turkey_conf: turkey_conf.write( json.dumps({ "SECRET_KEY": "xxx", "DEBUG": False, "SQLALCHEMY_TRACK_MODIFICATIONS": False, "SQLALCHEMY_DATABASE_URI": "sqlite:///{}".format(turkeydb_filename) })) chdir(PROJECT_DIRECTORY) check_call([self.python_package.python, "manage.py", "db", "upgrade"]) self.services = ServiceBundle( project_directory=PROJECT_DIRECTORY, startup_timeout=float(self.settings["startup_timeout"]), shutdown_timeout=float(self.settings["shutdown_timeout"]), ) # Docs : https://hitchtest.readthedocs.org/en/latest/plugins/hitchpostgres.html # Postgres user and database postgres_user = hitchpostgres.PostgresUser("example", "password") #self.services['Postgres'] = hitchpostgres.PostgresService( #postgres_package=postgres_package, #users=[postgres_user, ], #port=15432, #databases=[hitchpostgres.PostgresDatabase("example", postgres_user), ] #) # Docs : https://hitchtest.readthedocs.org/en/latest/plugins/hitchsmtp.html self.services['HitchSMTP'] = hitchsmtp.HitchSMTPService(port=10025) # Docs : https://hitchtest.readthedocs.org/en/latest/plugins/hitchpython.html self.services['Flask'] = hitchserve.Service( command=[ self.python_package.python, "manage.py", "runserver", ], directory=PROJECT_DIRECTORY, needs=[], #[self.services['Postgres'], ], log_line_ready_checker=lambda line: "Running on" in line, ) # Docs : https://hitchtest.readthedocs.org/en/latest/plugins/hitchselenium.html self.services['Firefox'] = hitchselenium.SeleniumService( xvfb=self.settings.get("xvfb", False) or self.settings.get("quiet", False), no_libfaketime=True, ) self.services.startup(interactive=False) # Docs : https://hitchtest.readthedocs.org/en/latest/plugins/hitchselenium.html self.driver = self.services['Firefox'].driver self.webapp = hitchselenium.SeleniumStepLibrary( selenium_webdriver=self.driver, wait_for_timeout=5, ) self.click = self.webapp.click self.wait_to_appear = self.webapp.wait_to_appear self.wait_to_contain = self.webapp.wait_to_contain self.wait_for_any_to_contain = self.webapp.wait_for_any_to_contain self.click_and_dont_wait_for_page_load = self.webapp.click_and_dont_wait_for_page_load # Configure selenium driver screen_res = self.settings.get("screen_resolution", { "width": 1024, "height": 768, }) self.driver.set_window_size(int(screen_res['width']), int(screen_res['height'])) self.driver.set_window_position(0, 0) self.driver.implicitly_wait(2.0) self.driver.accept_next_alert = True chdir(PROJECT_DIRECTORY)