1- # from pprint import pprint
21import os .path
32import time
43
54import pytest
65
7- from .git import Exec , Git
8-
9- # from .version_to_tag import version_to_wide_interval_tags
10- from .version_to_tag import get_possible_tags
6+ from git .git import Exec , Git
117
128NEBULA = "https://github.com/slackhq/nebula"
139BEAM = "https://github.com/apache/beam"
@@ -29,75 +25,48 @@ def repository() -> Git:
2925
3026
3127def test_extract_timestamp (repository : Git ):
32- commit = repository .get_commit (COMMIT_ID )
28+ commit = repository .get_commit (OPENCAST_COMMIT )
3329 commit .extract_timestamp (format_date = True )
34- assert commit .get_timestamp () == "2020-07-01 15:20:52 "
30+ assert commit .get_timestamp () == "2020-01-16 22:34:35 "
3531 commit .extract_timestamp (format_date = False )
36- assert commit .get_timestamp () == 1593616852
32+ assert commit .get_timestamp () == 1579214075
3733
3834
3935def test_show_tags (repository : Git ):
4036 tags = repository .execute ("git name-rev --tags" )
41- print (tags )
42- raise Exception ()
37+ assert tags is not None
4338
4439
4540def test_get_tags_for_commit (repository : Git ):
4641 commits = repository .create_commits ()
4742 commit = commits .get (OPENCAST_COMMIT )
4843 if commit is not None :
49- tags = commit .find_tag ("8.1" )
50- raise Exception (tags )
44+ tags = commit .find_tags ()
45+ assert len (tags ) == 62
46+ assert "10.2" in tags and "11.3" in tags and "9.4" in tags
5147
5248
5349def test_create_commits (repository : Git ):
5450 commits = repository .create_commits ()
55- commit = commits .get (COMMIT_ID )
56- assert len (commits ) == 357
57- assert commit .get_id () == COMMIT_ID
51+ commit = commits .get (OPENCAST_COMMIT )
52+ assert len (commits ) == 18178
53+ assert commit .get_id () == OPENCAST_COMMIT
5854
5955
6056def test_get_hunks_count (repository : Git ):
6157 commits = repository .create_commits ()
6258 commit = commits .get (OPENCAST_COMMIT )
63- diff , hunks = commit .get_diff ()
64- print (diff )
65- raise Exception ()
66- assert hunks == 2
59+ _ , hunks = commit .get_diff ()
60+ assert hunks == 7
6761
6862
6963def test_get_changed_files (repository : Git ):
70- commit = repository .get_commit (COMMIT_ID )
64+ commit = repository .get_commit (OPENCAST_COMMIT )
7165
7266 changed_files = commit .get_changed_files ()
7367 assert len (changed_files ) == 0
7468
7569
76- @pytest .mark .skip (reason = "Skipping this test" )
77- def test_extract_timestamp_from_version ():
78- repo = Git (NEBULA )
79- repo .clone ()
80- assert repo .extract_timestamp_from_version ("v1.5.2" ) == 1639518536
81- assert repo .extract_timestamp_from_version ("INVALID_VERSION_1_0_0" ) is None
82-
83-
84- def test_get_tag_for_version ():
85- repo = Git (NEBULA )
86- repo .clone ()
87- tags = repo .get_tags ()
88- assert get_possible_tags (tags , "1.5.2" ) == ["v1.5.2" ]
89-
90-
91- def test_get_commit_parent ():
92- repo = Git (NEBULA )
93- repo .clone ()
94- id = repo .get_commit_id_for_tag ("v1.6.1" )
95- commit = repo .get_commit (id )
96-
97- commit .get_parent_id ()
98- assert True # commit.parent_id == "4c0ae3df5ef79482134b1c08570ff51e52fdfe06"
99-
100-
10170def test_run_cache ():
10271 _exec = Exec (workdir = os .path .abspath ("." ))
10372 start = time .time_ns ()
0 commit comments