diff --git a/src/_cutecoin_test/models/account/test_account.py b/src/_cutecoin_test/models/account/test_account.py new file mode 100644 index 0000000000000000000000000000000000000000..7dd1bdd7029d38d49a9cf4bd9c04719bbbc7c6ad --- /dev/null +++ b/src/_cutecoin_test/models/account/test_account.py @@ -0,0 +1,60 @@ +import pytest +import ucoinpy as ucoin +from cutecoin.models.account import Account + + +#TODO: Test account +def test_account_create(): + pass + + +def test_account_load(): + pass + + +def test_account_add_wallet(): + pass + + +def test_account_add_contact(): + pass + + +def test_account_fingerprint(): + pass + + +def test_account_transactions_received(): + pass + + +def test_account_transactions_sent(): + pass + + +def test_account_last_issuances(): + pass + + +def test_account_issued_last_dividend(): + pass + + +def test_account_issue_dividend(): + pass + + +def test_account_transfer_coins(): + pass + + +def test_account_push_tht(): + pass + + +def test_account_pull_tht(): + pass + + +def test_account_quality(): + pass diff --git a/src/_cutecoin_test/models/account/test_communities.py b/src/_cutecoin_test/models/account/test_communities.py new file mode 100644 index 0000000000000000000000000000000000000000..0f02f64680be7a8d668bf9d1f9aecde3468ecdb8 --- /dev/null +++ b/src/_cutecoin_test/models/account/test_communities.py @@ -0,0 +1,14 @@ +import pytest +import ucoinpy as ucoin +from cutecoin.models.account.communities import Communities + + +#TODO: Test communities +def test_communities_add_community(): + pass + + +def test_communities_jsonify(): + pass + + diff --git a/src/_cutecoin_test/models/account/test_wallets.py b/src/_cutecoin_test/models/account/test_wallets.py new file mode 100644 index 0000000000000000000000000000000000000000..dd036c79d0f1f0d67ec2fcea2a02c0af9a21a894 --- /dev/null +++ b/src/_cutecoin_test/models/account/test_wallets.py @@ -0,0 +1,20 @@ +import pytest +import ucoinpy as ucoin +from mock import Mock +from cutecoin.models.account.wallets import Wallets + +#TODO: Test wallets +def test_wallets_add_wallet(): + pass + + +def test_wallets_get_wallet(): + pass + + +def test_wallets_remove_all_wallets_of(): + pass + + +def test_wallets_jsonify(): + pass diff --git a/src/_cutecoin_test/models/test_coin.py b/src/_cutecoin_test/models/test_coin.py new file mode 100644 index 0000000000000000000000000000000000000000..0bf8f8ed0b0c04674f14bd8a9d5374cdaf53f293 --- /dev/null +++ b/src/_cutecoin_test/models/test_coin.py @@ -0,0 +1,27 @@ +import pytest +import re +from cutecoin.models.coin import Coin + + +issuer = "2E69197FAB029D8669EF85E82457A1587CA0ED9C" +number = "0" +base = "1" +power = "1" +origin = "A-2" + + +@pytest.fixture +def coin_id_regex(): + return re.compile("^([A-Z\d]{40})-(\d+)-(\d)-(\d+)-((A|F|D)-\d+)$") + + +def test_coin_init(coin_id_regex): + coin = Coin(issuer, number, base, power, origin) + assert coin_id_regex.match(coin.get_id()) is not None + + +def test_coin_from_id(coin_id_regex): + coin_id = issuer + "-" + number + "-" + base + "-" + power + "-" + origin + coin = Coin.from_id(coin_id) + assert coin is not None + assert coin_id_regex.match(coin.get_id()) is not None diff --git a/src/_cutecoin_test/models/test_community.py b/src/_cutecoin_test/models/test_community.py new file mode 100644 index 0000000000000000000000000000000000000000..d727a49ac5d0607a9cc8ec8e93439563bf89f109 --- /dev/null +++ b/src/_cutecoin_test/models/test_community.py @@ -0,0 +1,45 @@ +import pytest +from mock import Mock +import ucoinpy as ucoin +from cutecoin.models.community import Community + + +#TODO: Unit test for community +def test_community_create(monkeypatch): + pass + + +def test_community_dividend(monkeypatch): + pass + + +def test_community_coin_minimal_power(monkeypatch): + pass + + +def test_community_amendment_id(monkeypatch): + pass + + +def test_community_amendment_number(monkeypatch): + pass + + +def test_community_person_quality(monkeypatch): + pass + + +def test_community_members_fingerprint(monkeypatch): + pass + + +def test_community_voters_fingerprint(monkeypatch): + pass + + +def test_community_to_json(): + pass + + +def test_community_from_json(): + pass diff --git a/src/_cutecoin_test/models/test_node.py b/src/_cutecoin_test/models/test_node.py new file mode 100644 index 0000000000000000000000000000000000000000..3d7241cf86278e1746196ad61186f110746dcddb --- /dev/null +++ b/src/_cutecoin_test/models/test_node.py @@ -0,0 +1,57 @@ +import pytest +import ucoinpy as ucoin +from mock import Mock +from cutecoin.models.node import Node + + +def test_peers(monkeypatch): + mock_peers_get = Mock(spec=ucoin.ucg.peering.Peers.__get__) + mock_peers_get.return_value = [{"version": "1", + "currency": "beta_brousouf", + "fingerprint": "A70B8E8E16F91909B6A06DFB7EEF1651D9CCF468", + "dns": "DNS_VALUE", + "ipv4": "192.168.100.10", + "ipv6": "", + "port": "3800", + "signature": "-----BEGIN PGP SIGNATURE----- ... -----END PGP SIGNATURE-----" + }, + {"version": "1", + "currency": "beta_brousouf", + "fingerprint": "A70B8E8E16F91909B6A06DFB7EEF1651D9CCF469", + "dns": "DNS_VALUE", + "ipv4": "192.168.100.11", + "ipv6": "", + "port": "3801", + "signature": "-----BEGIN PGP SIGNATURE----- ... -----END PGP SIGNATURE-----" +}] + monkeypatch.setattr(ucoin.ucg.peering.Peers, '__get__', mock_peers_get) + + node = Node("192.168.100.12", 3800) + peers = node.peers() + assert peers[0]["ipv4"] == "192.168.100.10" + assert peers[1]["ipv4"] == "192.168.100.11" + + +def test_peering(monkeypatch): + mock_peering_get = Mock(spec=ucoin.ucg.peering.Peer.__get__) + mock_peering_get.return_value = { + "version": "1", + "currency": "beta_brousouf", + "fingerprint": "A70B8E8E16F91909B6A06DFB7EEF1651D9CCF468", + "dns": "DNS_VALUE", + "ipv4": "192.168.100.10", + "ipv6": "", + "port": "3800", + "signature": "-----BEGIN PGP SIGNATURE----- ... -----END PGP SIGNATURE-----" +} + monkeypatch.setattr(ucoin.ucg.peering.Peer, '__get__', mock_peering_get) + + node = Node("192.168.100.12", 3800) + peering = node.peering() + assert peering["ipv4"] == "192.168.100.10" + assert peering["port"] == str(3800) + + +#TODO: Test node jsonify +def test_node_jsonify(monkeypatch): + pass diff --git a/src/_cutecoin_test/models/test_person.py b/src/_cutecoin_test/models/test_person.py new file mode 100644 index 0000000000000000000000000000000000000000..82387a086f68f3443c3f967f1ba4994737a98375 --- /dev/null +++ b/src/_cutecoin_test/models/test_person.py @@ -0,0 +1,41 @@ +import pytest +import ucoinpy as ucoin +from mock import Mock +from cutecoin.models.person import Person +from cutecoin.models.community import Community + + +#TODO: Lookup for person after community was tested +def test_person_lookup(monkeypatch): + pks_lookup_get = Mock(spec = ucoin.pks.Lookup.get) + pks_lookup_get.return_value = [ + { + "signature": "-----BEGIN PGP SIGNATURE----- ... -----END PGP SIGNATURE-----", + "key": + { + "email":"misterk@supermail.com", + "comment":"udid2;c;CAT;LOL;2000-04-19;e+43.70-079.42;0;", + "name":"LoL Cat", + "fingerprint":"C73882B64B7E72237A2F460CE9CAB76D19A8651E", + "raw":"-----BEGIN PGP PUBLIC KEY BLOCK----- ... -----END PGP PUBLIC KEY BLOCK-----\r\n" + } + }, + { + "signature": "-----BEGIN PGP SIGNATURE----- ... -----END PGP SIGNATURE-----", + "key": + { + "email":"mistery@undermail.com", + "comment":"udid2;c;CAT;LOL;2000-04-19;e+43.70-079.42;0;", + "name":"LoL Cat", + "fingerprint":"C73882B64B7E72237A2F460CE9CAB76D19A8651E", + "raw":"-----BEGIN PGP PUBLIC KEY BLOCK----- ... -----END PGP PUBLIC KEY BLOCK-----\r\n" + } + }] + + +def test_person_jsonify(): + pass + + +def test_person_from_json(): + pass diff --git a/src/_cutecoin_test/models/test_transaction.py b/src/_cutecoin_test/models/test_transaction.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/_cutecoin_test/models/test_wallet.py b/src/_cutecoin_test/models/test_wallet.py new file mode 100644 index 0000000000000000000000000000000000000000..87995cc862556ce3d67430061f5ff1eb0a2418b5 --- /dev/null +++ b/src/_cutecoin_test/models/test_wallet.py @@ -0,0 +1,28 @@ +import pytest +import ucoinpy as ucoin +from cutecoin.models.wallet import Wallet + + +#TODO: Test wallet +def test_wallet_create(): + pass + + +def test_wallet_load(): + pass + + +def test_wallet_value(): + pass + + +def test_wallet_refresh_coins(): + pass + + +def test_wallet_get_text(): + pass + + +def test_wallet_jsonify(): + pass diff --git a/src/_cutecoin_test/test_scenarios.py b/src/_cutecoin_test/test_scenarios.py new file mode 100644 index 0000000000000000000000000000000000000000..29543a6391d5690a84572a64c0d5fc191fac426d --- /dev/null +++ b/src/_cutecoin_test/test_scenarios.py @@ -0,0 +1,18 @@ +''' +Created on 6 avr. 2014 + +@author: inso +''' + +#TODO: Scenario de tests +''' +def pytest_generate_tests(metafunc): + idlist = [] + argvalues = [] + for scenario in metafunc.cls.scenarios: + idlist.append(scenario[0]) + items = scenario[1].items() + argnames = [x[0] for x in items] + argvalues.append(([x[1] for x in items])) + metafunc.parametrize(argnames, argvalues, ids=idlist, scope="class") + ''' diff --git a/src/cutecoin/gui/transferMoneyDialog.py b/src/cutecoin/gui/transferMoneyDialog.py index 4b033a2e45ba85f5ced69a268ee0302ad062a5e1..f7cf0542e421374c43d5e345aa46453fc20cb218 100644 --- a/src/cutecoin/gui/transferMoneyDialog.py +++ b/src/cutecoin/gui/transferMoneyDialog.py @@ -7,7 +7,6 @@ import logging from math import pow from PyQt5.QtWidgets import QDialog, QFrame, QSlider, QLabel, QDialogButtonBox, QErrorMessage -from PyQt5.QtCore import Qt, QSignalMapper from cutecoin.models.coin import Coin diff --git a/src/cutecoin/models/wallet/__init__.py b/src/cutecoin/models/wallet/__init__.py index 2f99ab89f3be2854c14cc159846416695962e44b..45b4af45c9e5bdcbf890665ac83d1bbcce512f7b 100644 --- a/src/cutecoin/models/wallet/__init__.py +++ b/src/cutecoin/models/wallet/__init__.py @@ -45,7 +45,7 @@ class Wallet(object): return value # TODO: Refresh coins when changing current account - def refreshCoins(self, fingerprint): + def refresh_coins(self, fingerprint): data_list = self.community.network.request( ucoin.hdc.coins.List({'pgp_fingerprint': fingerprint})) for issaunces in data_list['coins']: @@ -55,7 +55,7 @@ class Wallet(object): coin = Coin.from_id(issuer + "-" + shortened_id) self.coins.append(coin) - def getText(self): + def get_text(self): return self.name + " : " + \ str(self.value()) + " " + self.community.currency