From 21b1b2c30ad7a8e58d2feade76cd306f06e0888f Mon Sep 17 00:00:00 2001 From: izzy lyseggen Date: Mon, 18 Jan 2021 15:25:50 +0000 Subject: [PATCH] test(commits): scaffold tests --- tests/test_commit.py | 44 +++++++++++++++++++++++++++++++++++++++++++ tests/test_objects.py | 1 + 2 files changed, 45 insertions(+) create mode 100644 tests/test_commit.py create mode 100644 tests/test_objects.py diff --git a/tests/test_commit.py b/tests/test_commit.py new file mode 100644 index 0000000..2201aa2 --- /dev/null +++ b/tests/test_commit.py @@ -0,0 +1,44 @@ +from tests.test_stream import stream +from speckle.api.models import Commit +import pytest + + +@pytest.fixture(scope="module") +def commit(): + return Commit(message="a fun little test commit") + + +@pytest.fixture(scope="module") +def updated_commit(): + return Commit(message="a fun little updated commit") + + +@pytest.fixture(scope="module") +def stream_id(client): + return client.stream.create("testing commits") + + +def test_create(client, stream_id, commit): + commit_id = client.commit.create( + stream_id=stream_id, object_id="object123", message=commit.message + ) + commit.id = commit_id + + assert isinstance(commit_id, str) + + +def test_get(client, stream_id, commit): + fetched_commit = client.commit.get(stream_id=stream_id, commit_id=commit.id) + + assert fetched_commit.message == commit.message + + +def test_update(client, stream_id, commit, updated_commit): + updated = client.commit.update( + stream_id=stream_id, commit_id=commit.id, message=updated_commit.message + ) + + fetched_commit = client.commit.get(stream_id=stream_id, commit_id=commit.id) + + assert updated == True + assert fetched_commit.message == updated_commit.message diff --git a/tests/test_objects.py b/tests/test_objects.py new file mode 100644 index 0000000..5871ed8 --- /dev/null +++ b/tests/test_objects.py @@ -0,0 +1 @@ +import pytest