Skip to content
Snippets Groups Projects
Commit a176b05b authored by Moul's avatar Moul
Browse files

Switch from pendulum to arrow (#492, #482)

In order to have Python 3.13 support
parent 5ce5329d
No related branches found
No related tags found
No related merge requests found
Pipeline #39122 failed
...@@ -49,7 +49,7 @@ Please read their documentations on how to use them the best possible. ...@@ -49,7 +49,7 @@ Please read their documentations on how to use them the best possible.
- [DuniterPy](https://clients.pages.duniter.org/python/duniterpy/index.html): Autogenerated documentation. - [DuniterPy](https://clients.pages.duniter.org/python/duniterpy/index.html): Autogenerated documentation.
- Feel free to contribute upstream to share the code with other Python programs - Feel free to contribute upstream to share the code with other Python programs
- [Click](https://click.palletsprojects.com/#documentation) - [Click](https://click.palletsprojects.com/#documentation)
- [Pendulum](https://pendulum.eustace.io/docs/) - [Arrow](https://arrow.readthedocs.io/)
- [texttable](https://github.com/foutaise/texttable/#documentation) - [texttable](https://github.com/foutaise/texttable/#documentation)
## Pre-commit hooks ## Pre-commit hooks
......
...@@ -119,7 +119,7 @@ Silkaj is based on following Python modules: ...@@ -119,7 +119,7 @@ Silkaj is based on following Python modules:
- [Click](https://click.palletsprojects.com/): Composable command line interface toolkit - [Click](https://click.palletsprojects.com/): Composable command line interface toolkit
- [DuniterPy](https://git.duniter.org/clients/python/duniterpy/): Most complete client oriented Python library for Duniter/Ğ1 ecosystem - [DuniterPy](https://git.duniter.org/clients/python/duniterpy/): Most complete client oriented Python library for Duniter/Ğ1 ecosystem
- [Pendulum](https://pendulum.eustace.io/): Datetimes made easy - [Arrow](https://arrow.readthedocs.io/): Better dates & times for Python
- [texttable](https://github.com/foutaise/texttable/): Creation of simple ASCII tables - [texttable](https://github.com/foutaise/texttable/): Creation of simple ASCII tables
### Names ### Names
......
...@@ -18,7 +18,7 @@ python = "^3.9.0" ...@@ -18,7 +18,7 @@ python = "^3.9.0"
duniterpy = "~1.2.0" duniterpy = "~1.2.0"
rich-click = "^1.8.3" rich-click = "^1.8.3"
texttable = "^1.7.0" texttable = "^1.7.0"
pendulum = "^3.0.0" arrow = "^1.3.0"
pydiscourse = { version = "^1.7.0", optional = true } pydiscourse = { version = "^1.7.0", optional = true }
[tool.poetry.group.test.dependencies] [tool.poetry.group.test.dependencies]
......
...@@ -17,9 +17,9 @@ import time ...@@ -17,9 +17,9 @@ import time
from operator import itemgetter from operator import itemgetter
from urllib.error import HTTPError from urllib.error import HTTPError
import arrow
import rich_click as click import rich_click as click
from duniterpy.api import bma from duniterpy.api import bma
from pendulum import from_timestamp
from silkaj import tui from silkaj import tui
from silkaj.blockchain.tools import get_head_block from silkaj.blockchain.tools import get_head_block
...@@ -49,11 +49,11 @@ def list_blocks(number: int, detailed: bool) -> None: ...@@ -49,11 +49,11 @@ def list_blocks(number: int, detailed: bool) -> None:
issuer = {} issuer = {}
issuer["pubkey"] = block["issuer"] issuer["pubkey"] = block["issuer"]
if detailed or number <= 30: if detailed or number <= 30:
gentime = from_timestamp(block["time"], tz="local").format(ALL)
mediantime = from_timestamp(block["medianTime"], tz="local").format(ALL)
issuer["block"] = block["number"] issuer["block"] = block["number"]
issuer["gentime"] = gentime issuer["gentime"] = arrow.get(block["time"]).to("local").format(ALL)
issuer["mediantime"] = mediantime issuer["mediantime"] = (
arrow.get(block["medianTime"]).to("local").format(ALL)
)
issuer["hash"] = block["hash"][:10] issuer["hash"] = block["hash"][:10]
issuer["powMin"] = block["powMin"] issuer["powMin"] = block["powMin"]
issuers_dict[issuer["pubkey"]] = issuer issuers_dict[issuer["pubkey"]] = issuer
......
...@@ -16,11 +16,11 @@ ...@@ -16,11 +16,11 @@
from operator import itemgetter from operator import itemgetter
from os import system from os import system
import arrow
import jsonschema import jsonschema
import rich_click as click import rich_click as click
from duniterpy.api import bma from duniterpy.api import bma
from duniterpy.api.client import WSConnection from duniterpy.api.client import WSConnection
from pendulum import from_timestamp
from websocket._exceptions import WebSocketConnectionClosedException from websocket._exceptions import WebSocketConnectionClosedException
from silkaj import network, tui from silkaj import network, tui
...@@ -54,7 +54,7 @@ def display_diffi(current: WSConnection, diffi: dict) -> None: ...@@ -54,7 +54,7 @@ def display_diffi(current: WSConnection, diffi: dict) -> None:
d["Π diffi"] = compute_power(match_pattern(d["level"])[1]) d["Π diffi"] = compute_power(match_pattern(d["level"])[1])
d["Σ diffi"] = d.pop("level") d["Σ diffi"] = d.pop("level")
system("cls||clear") system("cls||clear")
block_gen = from_timestamp(current["time"], tz="local").format(ALL) block_gen = arrow.get(current["time"]).to("local").format(ALL)
match = match_pattern(int(current["powMin"]))[0] match = match_pattern(int(current["powMin"]))[0]
table = tui.Table(style="columns").set_cols_dtype(["t", "t", "t", "i"]) table = tui.Table(style="columns").set_cols_dtype(["t", "t", "t", "i"])
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with Silkaj. If not, see <https://www.gnu.org/licenses/>. # along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
import arrow
import rich_click as click import rich_click as click
from pendulum import from_timestamp
from silkaj.blockchain.tools import get_head_block from silkaj.blockchain.tools import get_head_block
from silkaj.constants import ALL from silkaj.constants import ALL
...@@ -26,8 +26,8 @@ from silkaj.tools import get_currency_symbol ...@@ -26,8 +26,8 @@ from silkaj.tools import get_currency_symbol
def currency_info() -> None: def currency_info() -> None:
head_block = get_head_block() head_block = get_head_block()
ep = determine_endpoint() ep = determine_endpoint()
current_time = from_timestamp(head_block["time"], tz="local") current_time = arrow.get(head_block["time"]).to("local")
mediantime = from_timestamp(head_block["medianTime"], tz="local") mediantime = arrow.get(head_block["medianTime"]).to("local")
print( print(
"Connected to node:", "Connected to node:",
ep.host, ep.host,
...@@ -45,5 +45,5 @@ def currency_info() -> None: ...@@ -45,5 +45,5 @@ def currency_info() -> None:
"\nMedian time:", "\nMedian time:",
mediantime.format(ALL), mediantime.format(ALL),
"\nDifference time:", "\nDifference time:",
current_time.diff_for_humans(mediantime, True), current_time - mediantime,
) )
...@@ -39,10 +39,9 @@ MINIMAL_RELATIVE_TX_AMOUNT = 1e-6 ...@@ -39,10 +39,9 @@ MINIMAL_RELATIVE_TX_AMOUNT = 1e-6
CENT_MULT_TO_UNIT = 100 CENT_MULT_TO_UNIT = 100
SHORT_PUBKEY_SIZE = 8 SHORT_PUBKEY_SIZE = 8
# pendulum constants # Arrow date time formats
# see https://pendulum.eustace.io/docs/#localized-formats # https://arrow.readthedocs.io/en/latest/guide.html#supported-tokens
DATE = "LL" DATE = "MMMM D, YYYY"
HOUR = "LTS" ALL = "MMMM D, YYYY hh:mm A ZZZ"
ALL = "LLL"
# Not ISO 8601 compliant but common # Not ISO 8601 compliant but common
ALL_DIGITAL = "YYYY-MM-DD HH:mm:ss" ALL_DIGITAL = "YYYY-MM-DD HH:mm:ss"
...@@ -19,12 +19,12 @@ from pathlib import Path ...@@ -19,12 +19,12 @@ from pathlib import Path
from typing import Any, Optional from typing import Any, Optional
from urllib.error import HTTPError from urllib.error import HTTPError
import arrow
import rich_click as click import rich_click as click
from duniterpy.api.bma.tx import history from duniterpy.api.bma.tx import history
from duniterpy.api.client import Client from duniterpy.api.client import Client
from duniterpy.documents.transaction import OutputSource, Transaction from duniterpy.documents.transaction import OutputSource, Transaction
from duniterpy.grammars.output import Condition from duniterpy.grammars.output import Condition
from pendulum import from_timestamp, now
from silkaj.constants import ALL, ALL_DIGITAL from silkaj.constants import ALL, ALL_DIGITAL
from silkaj.money.tools import ( from silkaj.money.tools import (
...@@ -109,7 +109,7 @@ def generate_header(pubkey: str, currency_symbol: str, ud_value: int) -> str: ...@@ -109,7 +109,7 @@ def generate_header(pubkey: str, currency_symbol: str, ud_value: int) -> str:
idty = {"uid": ""} idty = {"uid": ""}
balance = get_amount_from_pubkey(pubkey) balance = get_amount_from_pubkey(pubkey)
balance_ud = round(balance[1] / ud_value, 2) balance_ud = round(balance[1] / ud_value, 2)
date = now().format(ALL) date = arrow.now().format(ALL)
return f'Transactions history from: {idty["uid"]} {gen_pubkey_checksum(pubkey)}\n\ return f'Transactions history from: {idty["uid"]} {gen_pubkey_checksum(pubkey)}\n\
Current balance: {balance[1] / 100} {currency_symbol}, {balance_ud} UD {currency_symbol} on {date}\n' Current balance: {balance[1] / 100} {currency_symbol}, {balance_ud} UD {currency_symbol} on {date}\n'
...@@ -202,7 +202,7 @@ def parse_received_tx( ...@@ -202,7 +202,7 @@ def parse_received_tx(
identities = wt.identities_from_pubkeys(issuers, uids) identities = wt.identities_from_pubkeys(issuers, uids)
for received_tx in received_txs: for received_tx in received_txs:
tx_list = [] tx_list = []
tx_list.append(from_timestamp(received_tx.time, tz="local").format(ALL_DIGITAL)) tx_list.append(arrow.get(received_tx.time).to("local").format(ALL_DIGITAL))
tx_list.append("") tx_list.append("")
for i, issuer in enumerate(received_tx.issuers): for i, issuer in enumerate(received_tx.issuers):
tx_list[1] += prefix(None, None, i) + assign_idty_from_pubkey( tx_list[1] += prefix(None, None, i) + assign_idty_from_pubkey(
...@@ -243,7 +243,7 @@ def parse_sent_tx( ...@@ -243,7 +243,7 @@ def parse_sent_tx(
identities = wt.identities_from_pubkeys(pubkeys, uids) identities = wt.identities_from_pubkeys(pubkeys, uids)
for sent_tx in sent_txs: for sent_tx in sent_txs:
tx_list = [] tx_list = []
tx_list.append(from_timestamp(sent_tx.time, tz="local").format(ALL_DIGITAL)) tx_list.append(arrow.get(sent_tx.time).to("local").format(ALL_DIGITAL))
total_amount, outputs = tx_amount(sent_tx, pubkey, sent_func) total_amount, outputs = tx_amount(sent_tx, pubkey, sent_func)
if len(outputs) > 1: if len(outputs) > 1:
......
...@@ -15,12 +15,12 @@ ...@@ -15,12 +15,12 @@
import sys import sys
import arrow
import rich_click as click import rich_click as click
from duniterpy.api import bma from duniterpy.api import bma
from duniterpy.api.client import Client from duniterpy.api.client import Client
from duniterpy.documents import Block, BlockID, Certification, Identity, get_block_id from duniterpy.documents import Block, BlockID, Certification, Identity, get_block_id
from duniterpy.key import SigningKey from duniterpy.key import SigningKey
from pendulum import from_timestamp, now
from silkaj import tui from silkaj import tui
from silkaj.auth import auth_method from silkaj.auth import auth_method
...@@ -103,7 +103,7 @@ def pre_checks(client: Client, issuer_pubkey: str, pubkey_to_certify: str) -> di ...@@ -103,7 +103,7 @@ def pre_checks(client: Client, issuer_pubkey: str, pubkey_to_certify: str) -> di
# ĞT: 0<->4.8m - 4.8m + 12.5d # ĞT: 0<->4.8m - 4.8m + 12.5d
renewable = cert["expiresIn"] - params["sigValidity"] + params["sigReplay"] renewable = cert["expiresIn"] - params["sigValidity"] + params["sigReplay"]
if renewable > 0: if renewable > 0:
renewable_date = now().add(seconds=renewable).format(DATE) renewable_date = arrow.now().shift(seconds=renewable).format(DATE)
sys.exit(f"Certification renewable from {renewable_date}") sys.exit(f"Certification renewable from {renewable_date}")
# Check if the certification is already in the pending certifications # Check if the certification is already in the pending certifications
...@@ -125,7 +125,7 @@ def certification_confirmation( ...@@ -125,7 +125,7 @@ def certification_confirmation(
idty_timestamp = idty_to_certify["meta"]["timestamp"] idty_timestamp = idty_to_certify["meta"]["timestamp"]
block_id_idty = get_block_id(idty_timestamp) block_id_idty = get_block_id(idty_timestamp)
block = client(bma.blockchain.block, block_id_idty.number) block = client(bma.blockchain.block, block_id_idty.number)
timestamp_date = from_timestamp(block["time"], tz="local").format(ALL) timestamp_date = arrow.get(block["time"]).to("local").format(ALL)
block_id_date = f": #{idty_timestamp[:15]}{timestamp_date}" block_id_date = f": #{idty_timestamp[:15]}{timestamp_date}"
cert.append(["ID", issuer["uid"], "->", idty_to_certify["uid"] + block_id_date]) cert.append(["ID", issuer["uid"], "->", idty_to_certify["uid"] + block_id_date])
cert.append( cert.append(
...@@ -137,8 +137,8 @@ def certification_confirmation( ...@@ -137,8 +137,8 @@ def certification_confirmation(
], ],
) )
params = bc_tools.get_blockchain_parameters() params = bc_tools.get_blockchain_parameters()
cert_ends = now().add(seconds=params["sigValidity"]).format(DATE) cert_ends = arrow.now().shift(seconds=params["sigValidity"]).format(DATE)
cert.append(["Valid", now().format(DATE), "—>", cert_ends]) cert.append(["Valid", arrow.now().format(DATE), "—>", cert_ends])
table = tui.Table() table = tui.Table()
table.fill_rows( table.fill_rows(
......
...@@ -19,7 +19,7 @@ import sys ...@@ -19,7 +19,7 @@ import sys
import time import time
import urllib import urllib
import pendulum import arrow
import rich_click as click import rich_click as click
from duniterpy import constants as dp_const from duniterpy import constants as dp_const
from duniterpy.api.bma import blockchain from duniterpy.api.bma import blockchain
...@@ -222,9 +222,10 @@ def generate_identity_info(lookup, block, params): ...@@ -222,9 +222,10 @@ def generate_identity_info(lookup, block, params):
for i, certified in enumerate(lookup["signed"]): for i, certified in enumerate(lookup["signed"]):
info += elements_inbetween_list(i, lookup["signed"]) info += elements_inbetween_list(i, lookup["signed"])
info += "@" + certified["uid"] info += "@" + certified["uid"]
dt = pendulum.from_timestamp(block.mediantime + constants.ONE_HOUR, tz="local") dt = arrow.get(block.mediantime).shift(hours=1).to(tz="local")
info += ".\n- **Exclu·e le** " + dt.format("LLLL", locale="fr") arrow_format = "dddd D MMMM YYYY HH:mm ZZZ"
info += " CET\n- **Raison de l'exclusion** : " info += ".\n- **Exclu·e le** " + dt.format(arrow_format, locale="fr")
info += "\n- **Raison de l'exclusion** : "
if nbr_different_certifiers < params["sigQty"]: if nbr_different_certifiers < params["sigQty"]:
info += "manque de certifications" info += "manque de certifications"
else: else:
......
...@@ -18,7 +18,7 @@ import sys ...@@ -18,7 +18,7 @@ import sys
import urllib import urllib
from typing import Union from typing import Union
import pendulum import arrow
import rich_click as click import rich_click as click
from duniterpy.api import bma from duniterpy.api import bma
from duniterpy.documents import BlockID, Identity, Revocation from duniterpy.documents import BlockID, Identity, Revocation
...@@ -40,9 +40,7 @@ def display_identity(idty: Identity) -> Texttable: ...@@ -40,9 +40,7 @@ def display_identity(idty: Identity) -> Texttable:
id_table.append(["User ID", idty.uid]) id_table.append(["User ID", idty.uid])
id_table.append(["Blockstamp", str(idty.block_id)]) id_table.append(["Blockstamp", str(idty.block_id)])
creation_block = client(bma.blockchain.block, idty.block_id.number) creation_block = client(bma.blockchain.block, idty.block_id.number)
creation_date = pendulum.from_timestamp(creation_block["time"], tz="local").format( creation_date = arrow.get(creation_block["time"]).to("local").format(ALL)
ALL,
)
id_table.append(["Created on", creation_date]) id_table.append(["Created on", creation_date])
# display infos # display infos
table = Texttable(max_width=shutil.get_terminal_size().columns) table = Texttable(max_width=shutil.get_terminal_size().columns)
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
import logging import logging
import sys import sys
import pendulum import arrow
import rich_click as click import rich_click as click
from duniterpy.api import bma from duniterpy.api import bma
from duniterpy.documents import BlockID, Membership, get_block_id from duniterpy.documents import BlockID, Membership, get_block_id
...@@ -109,7 +109,7 @@ def display_confirmation_table( ...@@ -109,7 +109,7 @@ def display_confirmation_table(
table = [] table = []
if membership_expires: if membership_expires:
expires = pendulum.now().add(seconds=membership_expires).diff_for_humans() expires = arrow.now().shift(seconds=membership_expires).humanize()
table.append(["Expiration date of current membership", expires]) table.append(["Expiration date of current membership", expires])
if pending_memberships: if pending_memberships:
...@@ -123,7 +123,7 @@ def display_confirmation_table( ...@@ -123,7 +123,7 @@ def display_confirmation_table(
table.append( table.append(
[ [
"Pending membership documents will expire", "Pending membership documents will expire",
pendulum.now().add(seconds=pending_expires).diff_for_humans(), arrow.now().shift(seconds=pending_expires).humanize(),
], ],
) )
...@@ -136,7 +136,7 @@ def display_confirmation_table( ...@@ -136,7 +136,7 @@ def display_confirmation_table(
table.append( table.append(
[ [
"Identity published", "Identity published",
pendulum.from_timestamp(block["time"], tz="local").format(DATE), arrow.get(block["time"]).to("local").format(DATE),
], ],
) )
...@@ -144,14 +144,14 @@ def display_confirmation_table( ...@@ -144,14 +144,14 @@ def display_confirmation_table(
table.append( table.append(
[ [
"Expiration date of new membership", "Expiration date of new membership",
pendulum.now().add(seconds=params["msValidity"]).diff_for_humans(), arrow.now().shift(seconds=params["msValidity"]).humanize(),
], ],
) )
table.append( table.append(
[ [
"Expiration date of new membership from the mempool", "Expiration date of new membership from the mempool",
pendulum.now().add(seconds=params["msPeriod"]).diff_for_humans(), arrow.now().shift(seconds=params["msPeriod"]).humanize(),
], ],
) )
......
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with Silkaj. If not, see <https://www.gnu.org/licenses/>. # along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
import arrow
import rich_click as click import rich_click as click
from duniterpy.api.bma import blockchain, wot from duniterpy.api.bma import blockchain, wot
from pendulum import from_timestamp, now
from silkaj.blockchain.tools import get_blockchain_parameters from silkaj.blockchain.tools import get_blockchain_parameters
from silkaj.constants import DATE from silkaj.constants import DATE
...@@ -58,7 +58,7 @@ def status(uid_pubkey: str) -> None: ...@@ -58,7 +58,7 @@ def status(uid_pubkey: str) -> None:
for req_cert in req["certifications"]: for req_cert in req["certifications"]:
if req_cert["from"] == lookup_cert["pubkey"]: if req_cert["from"] == lookup_cert["pubkey"]:
certifications["received_expire"].append( certifications["received_expire"].append(
now().add(seconds=req_cert["expiresIn"]).format(DATE), arrow.now().shift(seconds=req_cert["expiresIn"]).format(DATE),
) )
certifications["received"].append(f'{lookup_cert["uids"][0]}') certifications["received"].append(f'{lookup_cert["uids"][0]}')
break break
...@@ -67,7 +67,7 @@ def status(uid_pubkey: str) -> None: ...@@ -67,7 +67,7 @@ def status(uid_pubkey: str) -> None:
f'{(wt.identity_of(pending_cert["from"]))["uid"]}', f'{(wt.identity_of(pending_cert["from"]))["uid"]}',
) )
certifications["received_expire"].append( certifications["received_expire"].append(
from_timestamp(pending_cert["expires_on"], tz="local").format(DATE), arrow.get(pending_cert["expires_on"]).to("local").format(DATE),
) )
certifications["sent"], certifications["sent_expire"] = get_sent_certifications( certifications["sent"], certifications["sent_expire"] = get_sent_certifications(
signed, signed,
...@@ -103,12 +103,14 @@ def membership_status(certifications: dict, pubkey: str, req: dict) -> None: ...@@ -103,12 +103,14 @@ def membership_status(certifications: dict, pubkey: str, req: dict) -> None:
is_member = bool(member_lookup) is_member = bool(member_lookup)
print("member:", is_member) print("member:", is_member)
if req["revoked"]: if req["revoked"]:
revoke_date = from_timestamp(req["revoked_on"], tz="local").format(DATE) revoke_date = arrow.get(req["revoked_on"]).to("local").format(DATE)
print(f"revoked: {req['revoked']}\nrevoked on: {revoke_date}") print(f"revoked: {req['revoked']}\nrevoked on: {revoke_date}")
if not is_member and req["wasMember"]: if not is_member and req["wasMember"]:
print("expired:", req["expired"], "\nwasMember:", req["wasMember"]) print("expired:", req["expired"], "\nwasMember:", req["wasMember"])
elif is_member: elif is_member:
expiration_date = now().add(seconds=req["membershipExpiresIn"]).format(DATE) expiration_date = (
arrow.now().shift(seconds=req["membershipExpiresIn"]).format(DATE)
)
print(f"Membership document expiration: {expiration_date}") print(f"Membership document expiration: {expiration_date}")
print("Sentry:", req["isSentry"]) print("Sentry:", req["isSentry"])
print("outdistanced:", req["outdistanced"]) print("outdistanced:", req["outdistanced"])
...@@ -143,7 +145,7 @@ def expiration_date_from_block_id( ...@@ -143,7 +145,7 @@ def expiration_date_from_block_id(
date_approximation(block_id, time_first_block, params["avgGenTime"]) date_approximation(block_id, time_first_block, params["avgGenTime"])
+ params["sigValidity"] + params["sigValidity"]
) )
return from_timestamp(expir_timestamp, tz="local").format(DATE) return arrow.get(expir_timestamp).to("local").format(DATE)
def date_approximation(block_id, time_first_block, avgentime): def date_approximation(block_id, time_first_block, avgentime):
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
import re import re
import urllib import urllib
import pendulum import arrow
import pytest import pytest
from duniterpy.api import bma from duniterpy.api import bma
from duniterpy.documents.block_id import BlockID from duniterpy.documents.block_id import BlockID
...@@ -292,7 +292,7 @@ def test_display_identity(idty, monkeypatch, capsys): ...@@ -292,7 +292,7 @@ def test_display_identity(idty, monkeypatch, capsys):
assert "| User ID | Claude" in result assert "| User ID | Claude" in result
assert "| Blockstamp | 597334" in result assert "| Blockstamp | 597334" in result
# idty_block returns a block at timestamp 1594980185,. # idty_block returns a block at timestamp 1594980185,.
creation_time = pendulum.from_timestamp(idty_block["time"], tz="local").format(ALL) creation_time = arrow.get(idty_block["time"]).to("local").format(ALL)
assert creation_time in result assert creation_time in result
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with Silkaj. If not, see <https://www.gnu.org/licenses/>. # along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
import pendulum import arrow
import pytest import pytest
from duniterpy.api import bma from duniterpy.api import bma
from duniterpy.documents import Membership, get_block_id from duniterpy.documents import Membership, get_block_id
...@@ -73,7 +73,7 @@ def test_display_confirmation_table(patched_wot_requirements, monkeypatch, capsy ...@@ -73,7 +73,7 @@ def test_display_confirmation_table(patched_wot_requirements, monkeypatch, capsy
table.append( table.append(
[ [
"Expiration date of current membership", "Expiration date of current membership",
pendulum.now().add(seconds=membership_expires).diff_for_humans(), arrow.now().shift(seconds=membership_expires).humanize(),
], ],
) )
...@@ -87,7 +87,7 @@ def test_display_confirmation_table(patched_wot_requirements, monkeypatch, capsy ...@@ -87,7 +87,7 @@ def test_display_confirmation_table(patched_wot_requirements, monkeypatch, capsy
table.append( table.append(
[ [
"Pending membership documents will expire", "Pending membership documents will expire",
pendulum.now().add(seconds=pending_expires).diff_for_humans(), arrow.now().shift(seconds=pending_expires).humanize(),
], ],
) )
...@@ -100,7 +100,7 @@ def test_display_confirmation_table(patched_wot_requirements, monkeypatch, capsy ...@@ -100,7 +100,7 @@ def test_display_confirmation_table(patched_wot_requirements, monkeypatch, capsy
table.append( table.append(
[ [
"Identity published", "Identity published",
pendulum.from_timestamp(block["time"], tz="local").format(DATE), arrow.get(block["time"]).to("local").format(DATE),
], ],
) )
...@@ -108,14 +108,14 @@ def test_display_confirmation_table(patched_wot_requirements, monkeypatch, capsy ...@@ -108,14 +108,14 @@ def test_display_confirmation_table(patched_wot_requirements, monkeypatch, capsy
table.append( table.append(
[ [
"Expiration date of new membership", "Expiration date of new membership",
pendulum.now().add(seconds=params["msValidity"]).diff_for_humans(), arrow.now().shift(seconds=params["msValidity"]).humanize(),
], ],
) )
table.append( table.append(
[ [
"Expiration date of new membership from the mempool", "Expiration date of new membership from the mempool",
pendulum.now().add(seconds=params["msPeriod"]).diff_for_humans(), arrow.now().shift(seconds=params["msPeriod"]).humanize(),
], ],
) )
......
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