Skip to content
Snippets Groups Projects
Commit 92ece80d authored by inso's avatar inso
Browse files

Initilizing unit testing. Lot of work to do. Contributors appreciated !

parent 0ef223f6
No related branches found
No related tags found
No related merge requests found
Showing with 312 additions and 3 deletions
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
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
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
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
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
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
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
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
'''
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")
'''
...@@ -7,7 +7,6 @@ import logging ...@@ -7,7 +7,6 @@ import logging
from math import pow from math import pow
from PyQt5.QtWidgets import QDialog, QFrame, QSlider, QLabel, QDialogButtonBox, QErrorMessage from PyQt5.QtWidgets import QDialog, QFrame, QSlider, QLabel, QDialogButtonBox, QErrorMessage
from PyQt5.QtCore import Qt, QSignalMapper
from cutecoin.models.coin import Coin from cutecoin.models.coin import Coin
......
...@@ -45,7 +45,7 @@ class Wallet(object): ...@@ -45,7 +45,7 @@ class Wallet(object):
return value return value
# TODO: Refresh coins when changing current account # TODO: Refresh coins when changing current account
def refreshCoins(self, fingerprint): def refresh_coins(self, fingerprint):
data_list = self.community.network.request( data_list = self.community.network.request(
ucoin.hdc.coins.List({'pgp_fingerprint': fingerprint})) ucoin.hdc.coins.List({'pgp_fingerprint': fingerprint}))
for issaunces in data_list['coins']: for issaunces in data_list['coins']:
...@@ -55,7 +55,7 @@ class Wallet(object): ...@@ -55,7 +55,7 @@ class Wallet(object):
coin = Coin.from_id(issuer + "-" + shortened_id) coin = Coin.from_id(issuer + "-" + shortened_id)
self.coins.append(coin) self.coins.append(coin)
def getText(self): def get_text(self):
return self.name + " : " + \ return self.name + " : " + \
str(self.value()) + " " + self.community.currency str(self.value()) + " " + self.community.currency
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment