Skip to content

Commit

Permalink
Merge pull request #1265 from i12momal/rama11
Browse files Browse the repository at this point in the history
Replace bin in hard tests
  • Loading branch information
danigm authored Sep 4, 2024
2 parents 2ad97c7 + 52f0cd3 commit 5f60d5a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
15 changes: 15 additions & 0 deletions test/mockdata/mock_build_date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from Testing import get_tested_mock_package

BUILDDATE = get_tested_mock_package(
files={
'/bin/with-date': {'content': """Jan 1 2019"""},
'/bin/with-datetime': {'content': """Jan 1 2019 12:15:11"""}
}
)

BUILDDATE2 = get_tested_mock_package(
files={
'/bin/script1',
'/bin/script2'
}
)
15 changes: 8 additions & 7 deletions test/test_build_date.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import re

from mockdata.mock_build_date import BUILDDATE, BUILDDATE2
import pytest
from rpmlint.checks.BuildRootAndDateCheck import BuildRootAndDateCheck
from rpmlint.filter import Filter

from Testing import CONFIG, get_tested_package
from Testing import CONFIG


@pytest.fixture(scope='function', autouse=True)
Expand All @@ -15,21 +16,21 @@ def builddatecheck():
return output, test


@pytest.mark.parametrize('package', ['binary/builddate'])
def test_build_date_time(tmp_path, package, builddatecheck):
@pytest.mark.parametrize('package', [BUILDDATE])
def test_build_date_time(package, builddatecheck):
output, test = builddatecheck
test.istoday = re.compile('Jan 1 2019')
test.check(get_tested_package(package, tmp_path))
test.check(package)
out = output.print_results(output.results)
assert 'E: file-contains-date-and-time /bin/with-datetime' in out
assert 'E: file-contains-current-date /bin/with-date' in out


@pytest.mark.parametrize('package', ['binary/bashisms'])
def test_build_date_time_correct(tmp_path, package, builddatecheck):
@pytest.mark.parametrize('package', [BUILDDATE2])
def test_build_date_time_correct(package, builddatecheck):
output, test = builddatecheck
test.istoday = re.compile('Jan 1 2019')
test.check(get_tested_package(package, tmp_path))
test.check(package)
out = output.print_results(output.results)
assert 'E: file-contains-date-and-time' not in out
assert 'E: file-contains-current-date' not in out

0 comments on commit 5f60d5a

Please sign in to comment.