change == to is
parent
4f86d7c0fb
commit
fb451e90a9
|
@ -7,7 +7,6 @@ from tests.common import (
|
|||
)
|
||||
|
||||
|
||||
|
||||
class ProcessMock:
|
||||
"""Mock subprocess.Popen"""
|
||||
|
||||
|
@ -26,6 +25,7 @@ def mock_subprocess_popen(mocker):
|
|||
mock = mocker.patch("subprocess.Popen", autospec=True, return_value=ProcessMock)
|
||||
return mock
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def some_users(mocker, datadir):
|
||||
mocker.patch("selfprivacy_api.utils.USERDATA_FILE", new=datadir / "some_users.json")
|
||||
|
@ -41,7 +41,6 @@ def some_users(mocker, datadir):
|
|||
return datadir
|
||||
|
||||
|
||||
|
||||
# TESTS ########################################################
|
||||
|
||||
|
||||
|
@ -76,6 +75,7 @@ def test_graphql_add_ssh_unauthorized(client, some_users, mock_subprocess_popen)
|
|||
assert response.status_code == 200
|
||||
assert response.json.get("data") is None
|
||||
|
||||
|
||||
def test_graphql_add_ssh(authorized_client, some_users, mock_subprocess_popen):
|
||||
response = authorized_client.post(
|
||||
"/graphql",
|
||||
|
@ -99,9 +99,10 @@ def test_graphql_add_ssh(authorized_client, some_users, mock_subprocess_popen):
|
|||
assert response.json["data"]["createSsh"]["user"]["username"] == "user1"
|
||||
assert response.json["data"]["createSsh"]["user"]["sshKeys"] == [
|
||||
"ssh-rsa KEY tester@pc",
|
||||
"ssh-rsa KEY test_key@pc"
|
||||
"ssh-rsa KEY test_key@pc",
|
||||
]
|
||||
|
||||
|
||||
def test_graphql_add_root_ssh(authorized_client, some_users, mock_subprocess_popen):
|
||||
response = authorized_client.post(
|
||||
"/graphql",
|
||||
|
@ -125,9 +126,10 @@ def test_graphql_add_root_ssh(authorized_client, some_users, mock_subprocess_pop
|
|||
assert response.json["data"]["createSsh"]["user"]["username"] == "root"
|
||||
assert response.json["data"]["createSsh"]["user"]["sshKeys"] == [
|
||||
"ssh-ed25519 KEY test@pc",
|
||||
"ssh-rsa KEY test_key@pc"
|
||||
"ssh-rsa KEY test_key@pc",
|
||||
]
|
||||
|
||||
|
||||
def test_graphql_add_main_ssh(authorized_client, some_users, mock_subprocess_popen):
|
||||
response = authorized_client.post(
|
||||
"/graphql",
|
||||
|
@ -151,7 +153,7 @@ def test_graphql_add_main_ssh(authorized_client, some_users, mock_subprocess_pop
|
|||
assert response.json["data"]["createSsh"]["user"]["username"] == "tester"
|
||||
assert response.json["data"]["createSsh"]["user"]["sshKeys"] == [
|
||||
"ssh-rsa KEY tester@pc",
|
||||
"ssh-rsa KEY test_key@pc"
|
||||
"ssh-rsa KEY test_key@pc",
|
||||
]
|
||||
|
||||
|
||||
|
@ -211,6 +213,7 @@ mutation deleteSsh($input: SshMutationsInput!) {
|
|||
}
|
||||
"""
|
||||
|
||||
|
||||
def test_graphql_dell_ssh_unauthorized(client, some_users, mock_subprocess_popen):
|
||||
response = client.post(
|
||||
"/graphql",
|
||||
|
@ -227,6 +230,7 @@ def test_graphql_dell_ssh_unauthorized(client, some_users, mock_subprocess_popen
|
|||
assert response.status_code == 200
|
||||
assert response.json.get("data") is None
|
||||
|
||||
|
||||
def test_graphql_dell_ssh(authorized_client, some_users, mock_subprocess_popen):
|
||||
response = authorized_client.post(
|
||||
"/graphql",
|
||||
|
@ -252,6 +256,7 @@ def test_graphql_dell_ssh(authorized_client, some_users, mock_subprocess_popen):
|
|||
"ssh-rsa KEY user1@pc"
|
||||
]
|
||||
|
||||
|
||||
def test_graphql_dell_root_ssh(authorized_client, some_users, mock_subprocess_popen):
|
||||
response = authorized_client.post(
|
||||
"/graphql",
|
||||
|
@ -299,6 +304,7 @@ def test_graphql_dell_main_ssh(authorized_client, some_users, mock_subprocess_po
|
|||
assert response.json["data"]["deleteSsh"]["user"]["username"] == "tester"
|
||||
assert response.json["data"]["deleteSsh"]["user"]["sshKeys"] == []
|
||||
|
||||
|
||||
def test_graphql_dell_404ssh(authorized_client, some_users, mock_subprocess_popen):
|
||||
response = authorized_client.post(
|
||||
"/graphql",
|
||||
|
@ -339,4 +345,3 @@ def test_graphql_dell_ssh_404user(authorized_client, some_users, mock_subprocess
|
|||
assert response.json["data"]["deleteSsh"]["code"] == 404
|
||||
assert response.json["data"]["deleteSsh"]["message"] is not None
|
||||
assert response.json["data"]["deleteSsh"]["success"] is False
|
||||
|
||||
|
|
|
@ -289,7 +289,7 @@ def test_graphql_get_404user(authorized_client, one_user, mock_subprocess_popen)
|
|||
assert response.status_code == 200
|
||||
assert response.json.get("data") is not None
|
||||
|
||||
assert response.json["data"]["users"]["getUser"] == None
|
||||
assert response.json["data"]["users"]["getUser"] is None
|
||||
|
||||
|
||||
API_CHANGE_USERS_MUTATION = """
|
||||
|
@ -396,7 +396,7 @@ def test_graphql_add_without_password(
|
|||
assert response.json["data"]["createUser"]["code"] == 400
|
||||
assert response.json["data"]["createUser"]["success"] is False
|
||||
|
||||
assert response.json["data"]["createUser"]["user"] == None
|
||||
assert response.json["data"]["createUser"]["user"] is None
|
||||
|
||||
|
||||
def test_graphql_add_without_both(authorized_client, one_user, mock_subprocess_popen):
|
||||
|
@ -419,7 +419,7 @@ def test_graphql_add_without_both(authorized_client, one_user, mock_subprocess_p
|
|||
assert response.json["data"]["createUser"]["code"] == 400
|
||||
assert response.json["data"]["createUser"]["success"] is False
|
||||
|
||||
assert response.json["data"]["createUser"]["user"] == None
|
||||
assert response.json["data"]["createUser"]["user"] is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize("username", invalid_usernames)
|
||||
|
@ -445,7 +445,7 @@ def test_graphql_add_system_username(
|
|||
assert response.json["data"]["createUser"]["code"] == 409
|
||||
assert response.json["data"]["createUser"]["success"] is False
|
||||
|
||||
assert response.json["data"]["createUser"]["user"] == None
|
||||
assert response.json["data"]["createUser"]["user"] is None
|
||||
|
||||
|
||||
def test_graphql_add_existing_user(authorized_client, one_user, mock_subprocess_popen):
|
||||
|
@ -468,7 +468,7 @@ def test_graphql_add_existing_user(authorized_client, one_user, mock_subprocess_
|
|||
assert response.json["data"]["createUser"]["code"] == 409
|
||||
assert response.json["data"]["createUser"]["success"] is False
|
||||
|
||||
assert response.json["data"]["createUser"]["user"] == None
|
||||
assert response.json["data"]["createUser"]["user"] is None
|
||||
|
||||
|
||||
def test_graphql_add_main_user(authorized_client, one_user, mock_subprocess_popen):
|
||||
|
@ -491,7 +491,7 @@ def test_graphql_add_main_user(authorized_client, one_user, mock_subprocess_pope
|
|||
assert response.json["data"]["createUser"]["code"] == 409
|
||||
assert response.json["data"]["createUser"]["success"] is False
|
||||
|
||||
assert response.json["data"]["createUser"]["user"] == None
|
||||
assert response.json["data"]["createUser"]["user"] is None
|
||||
|
||||
|
||||
def test_graphql_add_long_username(authorized_client, one_user, mock_subprocess_popen):
|
||||
|
@ -514,7 +514,7 @@ def test_graphql_add_long_username(authorized_client, one_user, mock_subprocess_
|
|||
assert response.json["data"]["createUser"]["code"] == 400
|
||||
assert response.json["data"]["createUser"]["success"] is False
|
||||
|
||||
assert response.json["data"]["createUser"]["user"] == None
|
||||
assert response.json["data"]["createUser"]["user"] is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize("username", ["", "1", "фыр", "user1@", "^-^"])
|
||||
|
@ -540,7 +540,7 @@ def test_graphql_add_invalid_username(
|
|||
assert response.json["data"]["createUser"]["code"] == 400
|
||||
assert response.json["data"]["createUser"]["success"] is False
|
||||
|
||||
assert response.json["data"]["createUser"]["user"] == None
|
||||
assert response.json["data"]["createUser"]["user"] is None
|
||||
|
||||
|
||||
API_DELETE_USERS_MUTATION = """
|
||||
|
@ -718,5 +718,5 @@ def test_graphql_update_404user(authorized_client, some_users, mock_subprocess_p
|
|||
assert response.json["data"]["updateUser"]["message"] is not None
|
||||
assert response.json["data"]["updateUser"]["success"] is False
|
||||
|
||||
assert response.json["data"]["updateUser"]["user"] == None
|
||||
assert response.json["data"]["updateUser"]["user"] is None
|
||||
assert mock_subprocess_popen.call_count == 1
|
||||
|
|
Loading…
Reference in New Issue