32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
from office365_admin.batch import parse_identifier_content, parse_table_content
|
|
|
|
|
|
def test_parse_table_content_from_csv():
|
|
content = "userPrincipalName,displayName,department\nalice, Alice Zhang,Sales\n"
|
|
rows = parse_table_content(content)
|
|
assert rows == [
|
|
{
|
|
"userPrincipalName": "alice",
|
|
"displayName": "Alice Zhang",
|
|
"department": "Sales",
|
|
}
|
|
]
|
|
|
|
|
|
def test_parse_table_content_from_json():
|
|
rows = parse_table_content('[{"userPrincipalName":"bob@example.com","department":"IT"}]')
|
|
assert rows[0]["userPrincipalName"] == "bob@example.com"
|
|
assert rows[0]["department"] == "IT"
|
|
|
|
|
|
def test_parse_identifier_content_from_lines():
|
|
values = parse_identifier_content("alice\nbob@example.com\n")
|
|
assert values == ["alice", "bob@example.com"]
|
|
|
|
|
|
def test_parse_identifier_content_from_csv():
|
|
content = "userPrincipalName,displayName\nalice@example.com,Alice\n"
|
|
values = parse_identifier_content(content)
|
|
assert values == ["alice@example.com"]
|
|
|