Esempio n. 1
0
def test_database_remove_uses_table_remove_credential_from_database(mocker):
    db = Database(path='path', extension='.pass')
    mocker.patch.object(db, 'table', mocker.MagicMock())
    mocker.patch('passpie.database.make_fullname', return_value='login@name')

    db.remove(fullname='login@name')

    assert db.table().remove.called
    db.table().remove.assert_called_once_with((where('fullname') == 'login@name'))
Esempio n. 2
0
def test_database_remove_uses_table_remove_credential_from_database(mocker):
    config = {"path": "path", "extension": ".pass"}
    db = Database(config)
    mocker.patch.object(db, "table", mocker.MagicMock())
    mocker.patch("passpie.database.make_fullname", return_value="login@name")

    db.remove(fullname="login@name")

    assert db.table().remove.called
    db.table().remove.assert_called_once_with((where("fullname") == "login@name"))
Esempio n. 3
0
def test_database_update_uses_table_update_credential_to_database(mocker):
    config = {"path": "path", "extension": ".pass"}
    db = Database(config)
    mocker.patch.object(db, "table", mocker.MagicMock())
    mocker.patch("passpie.database.make_fullname", return_value="login@name")
    mock_datetime = mocker.patch("passpie.database.datetime")
    values = {"login": "******", "name": "name", "comment": "new comment"}

    db.update(fullname="login@name", values=values)

    assert db.table().update.called
    db.table().update.assert_called_once_with(values, (where("fullname") == "login@name"))
Esempio n. 4
0
def test_database_remove_uses_table_remove_credential_from_database(mocker):
    config = {
        'path': 'path',
        'extension': '.pass',
    }
    db = Database(config)
    mocker.patch.object(db, 'table', mocker.MagicMock())
    mocker.patch('passpie.database.make_fullname', return_value='login@name')

    db.remove(fullname='login@name')

    assert db.table().remove.called
    db.table().remove.assert_called_once_with(
        (where('fullname') == 'login@name'))
Esempio n. 5
0
def test_database_update_uses_table_update_credential_to_database(mocker):
    db = Database(path='path', extension='.pass')
    mocker.patch.object(db, 'table', mocker.MagicMock())
    mocker.patch('passpie.database.make_fullname', return_value='login@name')
    mock_datetime = mocker.patch('passpie.database.datetime')
    values = {
        'login': '******',
        'name': 'name',
        'comment': 'new comment'
    }

    db.update(fullname='login@name', values=values)

    assert db.table().update.called
    db.table().update.assert_called_once_with(values, (where('fullname') == 'login@name'))
Esempio n. 6
0
def test_database_update_uses_table_update_credential_to_database(mocker):
    config = {
        'path': 'path',
        'extension': '.pass',
    }
    db = Database(config)
    mocker.patch.object(db, 'table', mocker.MagicMock())
    mocker.patch('passpie.database.make_fullname', return_value='login@name')
    mock_datetime = mocker.patch('passpie.database.datetime')
    values = {'login': '******', 'name': 'name', 'comment': 'new comment'}

    db.update(fullname='login@name', values=values)
    query = (Query().login == 'login') & (Query().name == 'name')

    assert db.table().update.called
    db.table().update.assert_called_once_with(values, query)
Esempio n. 7
0
def test_database_update_uses_table_update_credential_to_database(mocker):
    config = {
        'path': 'path',
        'extension': '.pass',
    }
    db = Database(config)
    mocker.patch.object(db, 'table', mocker.MagicMock())
    mocker.patch('passpie.database.make_fullname', return_value='login@name')
    mock_datetime = mocker.patch('passpie.database.datetime')
    values = {
        'login': '******',
        'name': 'name',
        'comment': 'new comment'
    }

    db.update(fullname='login@name', values=values)
    query = (Query().login == 'login') & (Query().name == 'name')

    assert db.table().update.called
    db.table().update.assert_called_once_with(values, query)