-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
259 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
"""Test the teams functions.""" | ||
import random | ||
import string | ||
|
||
import pytest | ||
|
||
from datawrapper import Datawrapper | ||
|
||
|
||
def test_get_teams(): | ||
# Connect | ||
dw = Datawrapper() | ||
|
||
# Get all teams | ||
teams = dw.get_teams() | ||
|
||
# Verify format of data | ||
assert isinstance(teams['list'], list) | ||
|
||
|
||
def test_edit_teams(): | ||
# Connect | ||
dw = Datawrapper() | ||
|
||
# Get a randoms string suffix to use in our names | ||
suffix = "".join(random.choices(string.ascii_lowercase + string.digits, k=5)) | ||
|
||
# Create a team | ||
team = dw.create_team(f"Test Team {suffix}") | ||
assert isinstance(team, dict) | ||
|
||
# Get the team | ||
team = dw.get_team(team["id"]) | ||
|
||
# Update the team | ||
team = dw.update_team(team["id"], f"Test Team 2 {suffix}") | ||
|
||
# Get the team again | ||
team = dw.get_team(team["id"]) | ||
|
||
# Verify that the name changed | ||
assert team["name"] == f"Test Team 2 {suffix}" | ||
|
||
# Delete the team | ||
dw.delete_team(team["id"]) | ||
|
||
# Verify that if you try to get this team it will now raise an exception | ||
with pytest.raises(Exception): | ||
dw.get_team(team["id"]) |