def handle(self, *args, **options): random.seed(12345) if options.get('list_scenarios'): self.stdout.write('Scenarios:\n') for num, (_, name) in enumerate(LearnersStates()): self.stdout.write(" {:03}_{}\n".format(num, name)) return if not os.environ.get('WEBPACK_DEV_SERVER_HOST'): # This should only happen if the user is running in an environment without Docker, which isn't allowed # for this command. raise Exception( 'Missing environment variable WEBPACK_DEV_SERVER_HOST.') if os.environ.get('RUNNING_SELENIUM') != 'true': raise Exception( "This management command must be run with ./scripts/test/run_snapshot_dashboard_states.sh" ) # We need to use pytest here instead of invoking the tests directly so that the test database # is used. Using override_settings(DATABASE...) causes a warning message and is not reliable. global RUNNING_DASHBOARD_STATES # pylint: disable=global-statement,global-variable-undefined RUNNING_DASHBOARD_STATES = True # pylint: disable=global-variable-undefined global DASHBOARD_STATES_OPTIONS # pylint: disable=global-statement,global-variable-undefined DASHBOARD_STATES_OPTIONS = options # pylint: disable=global-variable-undefined with override_settings( ELASTICSEARCH_INDEX='testindex', ELASTICSEARCH_DEFAULT_PAGE_SIZE=15, ): pytest_args = ["{}::test_learners_states".format(__file__), "-s"] if options.get('create_db'): pytest_args.append('--create-db') sys.exit(pytest.main(args=pytest_args))
def handle(self, *args, **options): random.seed(12345) if options.get('list_scenarios'): self.stdout.write('Scenarios:\n') for num, (_, name) in enumerate(DashboardStates()): self.stdout.write(" {:03}_{}\n".format(num, name)) return if not os.environ.get('WEBPACK_DEV_SERVER_HOST'): # This should only happen if the user is running in an environment without Docker, which isn't allowed # for this command. raise Exception('Missing environment variable WEBPACK_DEV_SERVER_HOST.') if os.environ.get('RUNNING_SELENIUM') != 'true': raise Exception( "This management command must be run with ./scripts/test/run_snapshot_dashboard_states.sh" ) # We need to use pytest here instead of invoking the tests directly so that the test database # is used. Using override_settings(DATABASE...) causes a warning message and is not reliable. global RUNNING_DASHBOARD_STATES # pylint: disable=global-statement RUNNING_DASHBOARD_STATES = True global DASHBOARD_STATES_OPTIONS # pylint: disable=global-statement DASHBOARD_STATES_OPTIONS = options with override_settings( ELASTICSEARCH_INDEX='testindex', ): pytest_args = ["{}::test_dashboard_states".format(__file__), "-s"] if options.get('create_db'): pytest_args.append('--create-db') sys.exit(pytest.main(args=pytest_args))
from datetime import datetime from django.utils import timezone import factory from .. import models from faker.generator import random random.seed(0xDEADBEEF) class BundleFactory(factory.django.DjangoModelFactory): class Meta: model = models.Bundle easydita_id = factory.Faker('first_name') easydita_resource_id = factory.Faker('last_name') time_queued = factory.LazyFunction(timezone.now)