示例#1
0
def test_copy_env_file_calls_put(secrets):
    with mock.patch("deploy.deployment.Connection",
                    spec=Connection) as m_connection:
        with mock.patch("deploy.deployment.get_secrets") as m_get_secrets:
            m_get_secrets.return_value = (secrets, None)
            d = Deployment()
            d.copy_env_file("env_file")
            m_connection.put.assert_called_once()
示例#2
0
def test_write_env_file_content(mock_get_secrets, secrets):
    get_secrets_string = secrets
    mock_get_secrets.return_value = (get_secrets_string, None)
    deployment = Deployment()
    m = mock.mock_open()
    with mock.patch("deploy.deployment.open", m, create=True):
        deployment.write_env_file("foo")
    m.assert_called_once_with("foo", "w")
示例#3
0
def test_env_file_values_for_DotEnvKeys(mock_get_secrets, secrets):
    get_secrets_string = secrets
    expected_env_result = {
        "DEBUG": "false",
        "SECRET_KEY": "some_super_secret_key",
        "DATABASE_URL": "database_string",
        "INTERNAL_IPS": "127.0.0.1",
        "ALLOWED_HOSTS": "localhost,127.0.0.1,foo.bar.com",
        "STATIC_ROOT": "/foo/bar/static/tdd/",
        "MEDIA_ROOT": "/foo/bar/media/tdd/",
    }
    mock_get_secrets.return_value = (get_secrets_string, None)
    deployment = Deployment()
    actual_env_result = deployment.env_file_filter_values()
    assert expected_env_result == actual_env_result
示例#4
0
def main(argz):
    env_file = os.path.join(ROOT_DIR, '.env')
    deployment = Deployment(django_src=os.path.join(ROOT_DIR, 'src'))

    # relative to the django_src path
    deployment.copy_app_contents()
    deployment.write_env_file(env_file)
    deployment.copy_env_file(env_file)
    deployment.refresh_venv()
    deployment.gather_static_files()
    deployment.django_migrations()
    deployment.restart_apache()
示例#5
0
def test_env_file_content(mock_get_secrets, secrets_value, content):
    get_secrets_string = secrets_value
    mock_get_secrets.return_value = (get_secrets_string, None)
    deployment = Deployment()
    actual_env_content = deployment.env_file_content()
    assert content == actual_env_content
示例#6
0
def test_excluded_directories(name, excluded):
    assert Deployment.excluded(name, EXCLUDED_DIRECTORY_PATTERNS) == excluded
示例#7
0
def test_excluded_files(name, excluded):
    assert Deployment.excluded(name, EXCLUDED_FILE_PATTERNS) == excluded