コード例 #1
0
def test_create_calls_all_stuff_in_right_order(mocker):
    mock_project = mocker.patch("cli.webapp.Project")

    result = runner.invoke(
        app,
        [
            "create",
            "-d",
            "www.domain.com",
            "-p",
            "python.version",
            "--nuke",
        ],
    )

    assert mock_project.call_args == call("www.domain.com", "python.version")
    assert mock_project.return_value.method_calls == [
        call.sanity_checks(nuke=True),
        call.virtualenv.create(nuke=True),
        call.create_webapp(nuke=True),
        call.add_static_file_mappings(),
        call.webapp.reload(),
    ]
    assert "All done! Your site is now live at https://www.domain.com" in result.stdout
    assert (
        f"https://www.pythonanywhere.com/user/{getpass.getuser().lower()}/webapps/www_domain_com"
        in result.stdout)
コード例 #2
0
def test_autoconfigure_calls_all_stuff_in_right_order(mock_django_project):
    result = runner.invoke(
        app,
        [
            "autoconfigure",
            "repo.url",
            "-d",
            "www.domain.com",
            "-p",
            "python.version",
            "--nuke",
        ],
    )
    mock_django_project.assert_called_once_with("www.domain.com",
                                                "python.version")
    assert mock_django_project.return_value.method_calls == [
        call.sanity_checks(nuke=True),
        call.download_repo("repo.url", nuke=True),
        call.create_virtualenv(nuke=True),
        call.create_webapp(nuke=True),
        call.add_static_file_mappings(),
        call.find_django_files(),
        call.update_wsgi_file(),
        call.update_settings_file(),
        call.run_collectstatic(),
        call.run_migrate(),
        call.webapp.reload(),
        call.start_bash(),
    ]
    assert (f"All done!  Your site is now live at https://www.domain.com"
            in result.stdout)
コード例 #3
0
 def test_calls_all_stuff_in_right_order(self):
     with patch('scripts.pa_autoconfigure_django.DjangoProject'
                ) as mock_DjangoProject:
         main('repo.url',
              'foo',
              'www.domain.com',
              'python.version',
              nuke='nuke option')
     assert mock_DjangoProject.call_args == call('www.domain.com',
                                                 'python.version')
     assert mock_DjangoProject.return_value.method_calls == [
         call.sanity_checks(nuke='nuke option'),
         call.download_repo('repo.url', nuke='nuke option'),
         call.ensure_branch("foo"),
         call.create_virtualenv(nuke='nuke option'),
         call.create_webapp(nuke='nuke option'),
         call.add_static_file_mappings(),
         call.find_django_files(),
         call.update_wsgi_file(),
         call.update_settings_file(),
         call.run_collectstatic(),
         call.run_migrate(),
         call.webapp.reload(),
         call.start_bash(),
     ]
コード例 #4
0
def test_start_calls_all_stuff_in_right_order(mock_django_project):
    result = runner.invoke(
        app,
        [
            "start",
            "-d",
            "www.domain.com",
            "-j",
            "django.version",
            "-p",
            "python.version",
            "--nuke",
        ],
    )

    assert mock_django_project.call_args == call("www.domain.com",
                                                 "python.version")
    assert mock_django_project.return_value.method_calls == [
        call.sanity_checks(nuke=True),
        call.create_virtualenv("django.version", nuke=True),
        call.run_startproject(nuke=True),
        call.find_django_files(),
        call.update_settings_file(),
        call.run_collectstatic(),
        call.create_webapp(nuke=True),
        call.add_static_file_mappings(),
        call.update_wsgi_file(),
        call.webapp.reload(),
    ]
    assert (f"All done!  Your site is now live at https://www.domain.com"
            in result.stdout)
コード例 #5
0
 def test_calls_all_stuff_in_right_order(self):
     with patch(
             'scripts.pa_start_django_webapp_with_virtualenv.DjangoProject'
     ) as mock_DjangoProject:
         main('www.domain.com',
              'django.version',
              'python.version',
              nuke='nuke option')
     assert mock_DjangoProject.call_args == call('www.domain.com',
                                                 'python.version')
     assert mock_DjangoProject.return_value.method_calls == [
         call.sanity_checks(nuke='nuke option'),
         call.create_virtualenv('django.version', nuke='nuke option'),
         call.run_startproject(nuke='nuke option'),
         call.find_django_files(),
         call.update_settings_file(),
         call.run_collectstatic(),
         call.create_webapp(nuke='nuke option'),
         call.add_static_file_mappings(),
         call.update_wsgi_file(),
         call.webapp.reload(),
     ]