def test_get_j_arg_live(self): localbuild = Localbuild([]) # Rather than calculating the amount of RAM on this system and # basically re-implementing the entire code here to get the exact # expected result, just pattern-match for basic sanity. result = localbuild._get_j_arg(cpus=1) assert re.match(r'-j\d+$', result)
def test_localbuild(self, testpkg, args, expected, monkeypatch): recorder = CallRecorder() monkeypatch.setattr('subprocess.check_call', recorder) monkeypatch.setattr('rhcephpkg.Localbuild._get_j_arg', lambda *a: '-j2') localbuild = Localbuild(args) localbuild.main() assert recorder.args == [ 'gbp', 'buildpackage', expected, '--git-arch=amd64', '--git-verbose', '--git-pbuilder', '-j2', '-us', '-uc' ]
def test_get_j_arg(self, cpus, ram, expected): localbuild = Localbuild([]) result = localbuild._get_j_arg(cpus=cpus, total_ram_gb=ram) assert result == expected
def test_missing_arg(self): localbuild = Localbuild(('localbuild', '--dist')) with pytest.raises(SystemExit) as e: localbuild.main() assert 'Specify a distro to --dist' in str(e.value)