Skip to content

Commit 27ea1d0

Browse files
committed
add test_fetch_sources_git to easyblock suite
1 parent ee772f7 commit 27ea1d0

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test/framework/easyblock.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import sys
3636
import tempfile
3737
from inspect import cleandoc
38+
from test.framework.github import requires_github_access
3839
from test.framework.utilities import EnhancedTestCase, TestLoaderFiltered, init_config
3940
from unittest import TextTestRunner
4041

@@ -1618,6 +1619,40 @@ def test_fetch_sources(self):
16181619
error_pattern = "Found one or more unexpected keys in 'sources' specification: {'nosuchkey': 'foobar'}"
16191620
self.assertErrorRegex(EasyBuildError, error_pattern, eb.fetch_sources, sources, checksums=[])
16201621

1622+
@requires_github_access()
1623+
def test_fetch_sources_git(self):
1624+
"""Test fetch_sources method from git repo."""
1625+
testdir = os.path.abspath(os.path.dirname(__file__))
1626+
ec = process_easyconfig(os.path.join(testdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0.eb'))[0]
1627+
eb = get_easyblock_instance(ec)
1628+
eb.src = []
1629+
sources = [
1630+
{
1631+
'filename': 'testrepository.tar.xz',
1632+
'git_config': {
1633+
'repo_name': 'testrepository',
1634+
'url': 'https://github.com/easybuilders',
1635+
'tag': 'branch_tag_for_test',
1636+
}
1637+
}
1638+
]
1639+
checksums = ["00000000"]
1640+
with self.mocked_stdout_stderr():
1641+
eb.fetch_sources(sources, checksums=checksums)
1642+
1643+
self.assertEqual(len(eb.src), 1)
1644+
self.assertEqual(eb.src[0]['name'], "testrepository.tar.xz")
1645+
self.assertExists(eb.src[0]['path'])
1646+
self.assertEqual(eb.src[0]['cmd'], None)
1647+
1648+
reference_checksum = "00000000"
1649+
if sys.version_info[0] >= 3 and sys.version_info[1] < 9:
1650+
# checksums of tarballs made by EB cannot be reliably checked prior to Python 3.9
1651+
# due to changes introduced in python/cpython#90021
1652+
reference_checksum = None
1653+
1654+
self.assertEqual(eb.src[0]['checksum'], reference_checksum)
1655+
16211656
def test_download_instructions(self):
16221657
"""Test use of download_instructions easyconfig parameter."""
16231658

0 commit comments

Comments
 (0)