2022-08-04 11:47:07 +02:00
|
|
|
import pytest
|
|
|
|
from repo_cloner.lib import DetectedCommit
|
2022-08-04 11:53:54 +02:00
|
|
|
import os
|
|
|
|
import time
|
2022-08-04 11:47:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
@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):
|
2022-08-04 16:52:43 +02:00
|
|
|
return DetectedCommit(det_dict, "wut")
|
2022-08-04 11:47:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_detected_commit_dict(det_dict):
|
2022-08-04 16:52:43 +02:00
|
|
|
det = DetectedCommit(det_dict, "wut")
|
2022-08-04 11:47:07 +02:00
|
|
|
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):
|
2022-08-04 11:53:54 +02:00
|
|
|
os.environ['TZ'] = 'Europe/Prague'
|
|
|
|
time.tzset()
|
2022-08-04 11:47:07 +02:00
|
|
|
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"
|