1
0
mirror of https://github.com/peeringdb/peeringdb.git synced 2024-05-11 05:55:09 +00:00
Files
peeringdb-peeringdb/tests/test_misc.py
Matt Griswold 04f1928b3c Updates 2.23 (#843)
* pipenv lock and pyupgrade

* pyupgrade, black format, add docs

* update for py3.7
2020-09-29 20:13:38 -05:00

67 lines
1.7 KiB
Python

import pytest
import requests
import peeringdb_server.models as models
import peeringdb_server.views as views
import peeringdb_server.settings as settings
from django.test import TestCase, Client
def test_requests_ssl():
r = requests.get("https://www.google.com")
assert r.status_code == 200
@pytest.mark.django_db
@pytest.mark.parametrize(
"env,result",
[
("beta", True),
("dev", False),
("prod", False),
],
)
def test_beta_banner(env, result):
_release_env = views.BASE_ENV["RELEASE_ENV"]
settings.RELEASE_ENV = views.BASE_ENV["RELEASE_ENV"] = env
client = Client()
response = client.get("/")
if result:
assert "This is a beta/testing instance" in response.content.decode()
else:
assert "This is a beta/testing instance" not in response.content.decode()
settings.RELEASE_ENV = views.BASE_ENV["RELEASE_ENV"] = _release_env
@pytest.mark.django_db
@pytest.mark.parametrize(
"env,result",
[
("beta", True),
("dev", False),
("prod", False),
],
)
def test_beta_banner_show_prod_sync_warning(env, result):
_release_env = views.BASE_ENV["RELEASE_ENV"]
settings.RELEASE_ENV = views.BASE_ENV["RELEASE_ENV"] = env
views.BASE_ENV["SHOW_AUTO_PROD_SYNC_WARNING"] = True
client = Client()
response = client.get("/")
if result:
assert (
"all data will be refreshed from production at" in response.content.decode()
)
else:
assert (
"all data will be refreshed from production at"
not in response.content.decode()
)
settings.RELEASE_ENV = views.BASE_ENV["RELEASE_ENV"] = _release_env
views.BASE_ENV["SHOW_AUTO_PROD_SYNC_WARNING"] = False