From 41108533c9df38697952ef57cab7b58ee34a80f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Val=C3=AD=C4=8Dek?= Date: Thu, 4 Aug 2022 11:47:07 +0200 Subject: [PATCH] Test: detected commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Václav Valíček --- tests/lib/test_detected_commit.py | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 tests/lib/test_detected_commit.py diff --git a/tests/lib/test_detected_commit.py b/tests/lib/test_detected_commit.py new file mode 100644 index 0000000..e9a2b1f --- /dev/null +++ b/tests/lib/test_detected_commit.py @@ -0,0 +1,57 @@ +import pytest +from repo_cloner.lib import DetectedCommit + + +@pytest.fixture +def det_dict(): + return { + 'commit': "aa5056610ff57f73bae9633a985c6a8e41f3bc23", + 'abbrev': "aa50566", + 'author': "Mocked Tester", + 'date': 1659604838, + 'is_tag': True, + 'tags': ["tag1", "tag2"], + 'is_branch': True, + 'branches': ["br1", "br2"], + 'log': "Test message\n\nLine 2", + } + + +@pytest.fixture +def det(det_dict): + return DetectedCommit(det_dict) + + +def test_detected_commit_dict(det_dict): + det = DetectedCommit(det_dict) + assert det.dict == det_dict + + +def test_commit(det): + assert det.commit == "aa5056610ff57f73bae9633a985c6a8e41f3bc23" + + +def test_abbrev(det): + assert det.abbrev == "aa50566" + + +def test_author(det): + assert det.author == "Mocked Tester" + + +def test_date(det): + assert det.date == "04-08-2022, 11:20:38" + + +def test_tags(det): + assert det.is_tag + assert det.tags == "tag1, tag2" + + +def test_branches(det): + assert det.is_branch + assert det.branches == "br1, br2" + + +def test_log(det): + assert det.log == "Test message\n\nLine 2"