예제 #1
0
    def test_success(self, mock_logic, mock_rootdir):
        mock_open = mock.mock_open(read_data=metadata_factory(
            '[email protected]:yelp/detect-secrets',
            baseline_filename='foobar',
            plugins={
                'HexHighEntropyString': {
                    'hex_limit': 3.5,
                },
            },
            json=True,
        ), )

        repo = mock_logic(mock_open)

        mock_open.assert_called_with('{}/tracked/{}.json'.format(
            mock_rootdir,
            FileStorage.hash_filename('will_be_mocked'),
        ))

        assert repo.last_commit_hash == 'sha256-hash'
        assert repo.repo == '[email protected]:yelp/detect-secrets'
        assert repo.crontab == '0 0 * * *'
        assert repo.plugin_config == {
            'HexHighEntropyString': {
                'hex_limit': 3.5,
            },
        }
        assert repo.baseline_filename == 'foobar'
        assert not repo.exclude_regex
        assert isinstance(repo.storage, FileStorage)
예제 #2
0
def assert_writes_accurately(mock_open, mock_rootdir):
    mock_open.assert_called_with(
        '{}/tracked/{}.json'.format(
            mock_rootdir,
            FileStorage.hash_filename('yelp/detect-secrets'),
        ),
        'w',
    )
    mock_open().write.assert_called_with(
        metadata_factory(
            '[email protected]:yelp/detect-secrets',
            baseline_filename='foobar',
            json=True,
        ), )