Example #1
0
    def test_should_create_a_new_account_if_required(self, mocker):
        """... it should create a new account if required"""
        mt = MailTm()

        account = mt.get_account()

        spied_load = mocker.spy(mt, "_load_account")
        spied_get = mocker.spy(mt, "get_account")
        mocked_copy = mocker.patch("pymailtm.pymailtm.pyperclip.copy",
                                   new=create_autospec(pyperclip.copy))

        acc = mt._open_account(new=True)

        spied_load.assert_not_called()
        spied_get.assert_called()
        mocked_copy.assert_called_once_with(acc.address)
        assert account.address != acc.address
Example #2
0
    def test_should_be_be_able_to_recover_existing_account(self, mocker):
        """... it should be be able to recover existing account"""
        mt = MailTm()

        account = mt.get_account()

        spied_load = mocker.spy(mt, "_load_account")
        spied_get = mocker.spy(mt, "get_account")
        mocked_copy = mocker.patch("pymailtm.pymailtm.pyperclip.copy",
                                   new=create_autospec(pyperclip.copy))

        acc = mt._open_account()

        spied_load.assert_called()
        spied_get.assert_not_called()
        mocked_copy.assert_called_once_with(acc.address)
        assert account.address == acc.address