@task
def setup_test_deploy_env(c):
    c.run('rm -rf ./{}'.format(TEST_DEPLOY_DIRECTORY))
    c.run('mkdir {}'.format(TEST_DEPLOY_DIRECTORY))
    resp = requests.get('https://api.github.com/orgs/rajk-apps/repos')
    repos = ['git+https://github.com/{}'.format(d['full_name']) for d in json.loads(resp.content)]
    app_names = [r.split('/')[(- 1)].replace('-', '_') for r in repos]
    c.run('python3 -m venv {}/django_venv'.format(TEST_DEPLOY_DIRECTORY))
    for r in (['wheel', 'django', 'toml'] + repos):
        c.run('{}/django_venv/bin/pip install {}'.format(TEST_DEPLOY_DIRECTORY, r))
    c.run('cd {};django_venv/bin/django-admin startproject rajkproject'.format(TEST_DEPLOY_DIRECTORY))
    with open('{}/rajkproject/rajkproject/settings.py'.format(TEST_DEPLOY_DIRECTORY), 'a') as fp:
        fp.write('\nINSTALLED_APPS += [{}]'.format(', '.join(["'{}'".format(a) for a in app_names])))
    with open('{}/rajkproject/rajkproject/urls.py'.format(TEST_DEPLOY_DIRECTORY), 'a') as fp:
        fp.write("\nfrom django.urls import include\nurlpatterns.append(path('accounts/', include('django.contrib.auth.urls')))\nurlpatterns += [{}]".format(', '.join(["path('{}', include('{}.urls'))".format(((a + '/') if (a != 'rajk_appman') else ''), a) for a in app_names])))
    dump_fname = '{}/dump.json'.format(TEST_DEPLOY_DIRECTORY)
    resp = requests.get('https://rajk.uni-corvinus.hu/djangodump.json')
    with open(dump_fname, 'wb') as fp:
        fp.write(resp.content)
    for django_command in ['makemigrations', 'makemigrations {}'.format(' '.join(app_names)), 'migrate', 'loaddata {}'.format(dump_fname)]:
        c.run('{}/django_venv/bin/python {}/rajkproject/manage.py {}'.format(TEST_DEPLOY_DIRECTORY, TEST_DEPLOY_DIRECTORY, django_command))
@task
def setup_test_deploy_env(c):
    c.run('rm -rf ./{}'.format(TEST_DEPLOY_DIRECTORY))
    c.run('mkdir {}'.format(TEST_DEPLOY_DIRECTORY))
    resp = requests.get('https://api.github.com/orgs/rajk-apps/repos')
    repos = ['git+https://github.com/{}'.format(d['full_name']) for d in json.loads(resp.content)]
    app_names = [r.split('/')[(- 1)].replace('-', '_') for r in repos]
    c.run('python3 -m venv {}/django_venv'.format(TEST_DEPLOY_DIRECTORY))
    for r in (['wheel', 'django', 'toml'] + repos):
        c.run('{}/django_venv/bin/pip install {}'.format(TEST_DEPLOY_DIRECTORY, r))
    c.run('cd {};django_venv/bin/django-admin startproject rajkproject'.format(TEST_DEPLOY_DIRECTORY))
    with open('{}/rajkproject/rajkproject/settings.py'.format(TEST_DEPLOY_DIRECTORY), 'a') as fp:
        fp.write('\nINSTALLED_APPS += [{}]'.format(', '.join(["'{}'".format(a) for a in app_names])))
    with open('{}/rajkproject/rajkproject/urls.py'.format(TEST_DEPLOY_DIRECTORY), 'a') as fp:
        fp.write("\nfrom django.urls import include\nurlpatterns.append(path('accounts/', include('django.contrib.auth.urls')))\nurlpatterns += [{}]".format(', '.join(["path('{}', include('{}.urls'))".format(((a + '/') if (a != 'rajk_appman') else ), a) for a in app_names])))
    dump_fname = '{}/dump.json'.format(TEST_DEPLOY_DIRECTORY)
    resp = requests.get('https://rajk.uni-corvinus.hu/djangodump.json')
    with open(dump_fname, 'wb') as fp:
        fp.write(resp.content)
    for django_command in ['makemigrations', 'makemigrations {}'.format(' '.join(app_names)), 'migrate', 'loaddata {}'.format(dump_fname)]:
        c.run('{}/django_venv/bin/python {}/rajkproject/manage.py {}'.format(TEST_DEPLOY_DIRECTORY, TEST_DEPLOY_DIRECTORY, django_command))