repo-cloner/tests/lib/test_detected_commit.py
Václav Valíček de67130fd5
Added support for project-name
Signed-off-by: Václav Valíček <valicek1994@gmail.com>
2022-08-04 16:52:43 +02:00

62 lines
1.1 KiB
Python

import pytest
from repo_cloner.lib import DetectedCommit
import os
import time
@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, "wut")
def test_detected_commit_dict(det_dict):
det = DetectedCommit(det_dict, "wut")
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):
os.environ['TZ'] = 'Europe/Prague'
time.tzset()
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"