1
0
mirror of https://github.com/peeringdb/peeringdb.git synced 2024-05-11 05:55:09 +00:00

black formatted

This commit is contained in:
Matt Griswold
2019-12-05 16:57:52 +00:00
parent a53cadb167
commit cf56acbfc4
106 changed files with 7894 additions and 5626 deletions

View File

@@ -11,21 +11,20 @@ import peeringdb_server.views as views
from util import ClientCase
class TestMaintenanceMode(ClientCase):
class TestMaintenanceMode(ClientCase):
@classmethod
def setUpTestData(cls):
super(TestMaintenanceMode, cls).setUpTestData()
cls.superuser = User.objects.create_user("su","su@localhost","su",is_superuser=True)
cls.org = REFTAG_MAP["org"].objects.create(name="Test Org",
status="ok")
cls.superuser = User.objects.create_user(
"su", "su@localhost", "su", is_superuser=True
)
cls.org = REFTAG_MAP["org"].objects.create(name="Test Org", status="ok")
@pytest.fixture(autouse=True)
def init_lockfile(self, tmpdir):
settings.MAINTENANCE_MODE_LOCKFILE = str(tmpdir.join("maintenance.lock"))
def test_signup(self):
"""
user signup should be blocked during maintenance
@@ -40,7 +39,6 @@ class TestMaintenanceMode(ClientCase):
maintenance.off()
def test_api(self):
"""
test that maintenance mode on blocks all write ops to the rest api
@@ -61,27 +59,22 @@ class TestMaintenanceMode(ClientCase):
assert r.status_code == 200
# POST should be blocked
r = self.client.post("/api/net", {
"org_id": 1,
"name": "Test net",
"asn": 9000000
}, format="json")
r = self.client.post(
"/api/net", {"org_id": 1, "name": "Test net", "asn": 9000000}, format="json"
)
content = json.loads(r.content)
assert r.status_code == 503
assert content["meta"]["error"].find(err_str) > -1
net = {"id": 1}
# PUT should be blocked
r = self.client.put("/api/net/{}".format(net["id"]), net,
format="json")
r = self.client.put("/api/net/{}".format(net["id"]), net, format="json")
content = json.loads(r.content)
assert r.status_code == 503
assert content["meta"]["error"].find(err_str) > -1
# DELETE should be blocked
r = self.client.delete("/api/net/{}".format(net["id"]), {},
format="json")
r = self.client.delete("/api/net/{}".format(net["id"]), {}, format="json")
content = json.loads(r.content)
assert r.status_code == 503
assert content["meta"]["error"].find(err_str) > -1