File size: 3,686 Bytes
2c17839 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | # coding: utf8
import pytest
import sys
from atlassian import ServiceDesk
SERVICEDESK = None
try:
from .mockup import mockup_server
SERVICEDESK = ServiceDesk(
"{}/servicedesk".format(mockup_server()), username="username", password="password", cloud=True
)
except ImportError:
pass
@pytest.mark.skipif(sys.version_info < (3, 4), reason="requires python3.4")
class TestBasic:
def test_create_customer(self):
result = SERVICEDESK.create_customer("{displayName}", "{emailAddress}")["emailAddress"]
assert result == "{emailAddress}", "Result of [create_customer()]"
def test_get_organisations(self):
result = [x["name"] for x in SERVICEDESK.get_organisations()["values"]]
assert result == ["Charlie Cakes Franchises"], "Result of [get_organisations()]"
def test_get_organisations_servicedesk_id(self):
result = [x["name"] for x in SERVICEDESK.get_organisations(service_desk_id="{serviceDeskId}")["values"]]
assert result == [
"Charlie Cakes Franchises",
"Atlas Coffee Co",
"The Adjustment Bureau",
], "Result of [get_organisations(service_desk_id)]"
def test_get_organization(self):
result = SERVICEDESK.get_organization("{organizationId}")
assert result["name"] == "Charlie Cakes Franchises", "Result of [test_get_organization(...)]"
def test_get_users_in_organization(self):
result = [x["emailAddress"] for x in SERVICEDESK.get_users_in_organization("{organizationId}")["values"]]
assert result == ["fred@example.com", "bob@example.com"], "Result of [get_users_in_organization(...)]"
def test_create_organization(self):
result = SERVICEDESK.create_organization("Charlie Chocolate Franchises")
assert result["id"] == "2", "Result of [create_organization(...)]"
def test_add_organization(self):
result = SERVICEDESK.add_organization("{serviceDeskId}", "{organizationId}")
assert result is None, "Result of [add_organization(...)]"
def test_remove_organization(self):
result = SERVICEDESK.remove_organization("{serviceDeskId}", "{organizationId}")
assert result is None, "Result of [remove_organization(...)]"
def test_delete_organization(self):
result = SERVICEDESK.delete_organization("{organizationId}")
assert result is None, "Result of [delete_organization(...)]"
def test_add_users_to_organization(self):
result = SERVICEDESK.add_users_to_organization(
"{organizationId}", account_list=["{accountId1}", "{accountId2}"]
)
assert result is None, "Result of [add_users_to_organization(...)]"
def test_remove_users_from_organization(self):
result = SERVICEDESK.remove_users_from_organization(
"{organizationId}", account_list=["{accountId1}", "{accountId2}"]
)
assert result is None, "Result of [remove_users_from_organization(...)]"
def test_get_customers(self):
result = [x["emailAddress"] for x in SERVICEDESK.get_customers("{serviceDeskId}", query=None)["values"]]
assert result == ["fred@example.com"], "Result of [remove_users_from_organization(...)]"
def test_add_customers(self):
result = SERVICEDESK.add_customers("{serviceDeskId}", list_of_accountids=["{accountId1}", "{accountId2}"])
assert result is None, "Result of [remove_users_from_organization(...)]"
def test_remove_customers(self):
result = SERVICEDESK.remove_customers("{serviceDeskId}", list_of_accountids=["{accountId1}", "{accountId2}"])
assert result is None, "Result of [remove_users_from_organization(...)]"
|