def test_credentials_returns_sorted_list_credentials(mocker): db = Database(path='path', extension='.pass') mocker.patch.object(db, 'all', mocker.MagicMock()) mock_sorted = mocker.patch('passpie.database.sorted', create=True) credentials = db.credentials() assert credentials == mock_sorted()
def test_credentials_returns_sorted_list_credentials(mocker): config = {"path": "path", "extension": ".pass"} db = Database(config) mocker.patch.object(db, "all", mocker.MagicMock()) mock_sorted = mocker.patch("passpie.database.sorted", create=True) credentials = db.credentials() assert credentials == mock_sorted()
def test_credentials_returns_sorted_list_credentials(mocker): config = { 'path': 'path', 'extension': '.pass', } db = Database(config) mocker.patch.object(db, 'all', mocker.MagicMock()) mock_sorted = mocker.patch('passpie.database.sorted', create=True) credentials = db.credentials() assert credentials == mock_sorted()
def test_credentials_returns_sorted_list_credentials(mocker): config = { 'path': 'path', 'extension': '.pass', } db = Database(config) mocker.patch.object(db, 'all', mocker.MagicMock()) mock_sorted = mocker.patch('passpie.database.sorted', create=True) credentials = db.credentials() assert credentials == mock_sorted()
def test_credentials_filter_credentials_by_login_and_name_when_name_only_fullname_passed(mocker): config = {"path": "path", "extension": ".pass"} db = Database(config) mocker.patch.object(db, "search") mocker.patch.object(db, "all") mocker.patch("passpie.database.split_fullname", return_value=(None, "example.com")) Credential = Query() credentials = db.credentials(fullname="@example.com") assert db.search.called is True assert db.all.called is False db.search.assert_called_once_with((Credential.name == "example.com"))
def test_credentials_filter_credentials_by_login_and_name_when_name_only_fullname_passed(mocker): db = Database(path='path', extension='.pass') mocker.patch.object(db, 'search') mocker.patch.object(db, 'all') mocker.patch('passpie.database.split_fullname', return_value=(None, 'example.com')) Credential = Query() credentials = db.credentials(fullname="@example.com") assert db.search.called is True assert db.all.called is False db.search.assert_called_once_with( (Credential.name == "example.com") )
def test_credentials_filter_credentials_by_login_and_name_when_empty_login_fullname_passed(mocker): config = { 'path': 'path', 'extension': '.pass', } db = Database(config) mocker.patch.object(db, 'search') mocker.patch.object(db, 'all') mocker.patch('passpie.database.split_fullname', return_value=('', 'example.com')) Credential = Query() credentials = db.credentials(fullname="@example.com") assert db.search.called is True assert db.all.called is False db.search.assert_called_once_with( (Credential.login == "") & (Credential.name == "example.com") )
def test_credentials_filter_credentials_by_login_and_name_when_name_only_fullname_passed( mocker): config = { 'path': 'path', 'extension': '.pass', } db = Database(config) mocker.patch.object(db, 'search') mocker.patch.object(db, 'all') mocker.patch('passpie.database.split_fullname', return_value=(None, 'example.com')) Credential = Query() credentials = db.credentials(fullname="@example.com") assert db.search.called is True assert db.all.called is False db.search.assert_called_once_with((Credential.name == "example.com"))