Skip to content
Snippets Groups Projects
Commit 8ee8ffe4 authored by inso's avatar inso Committed by GitHub
Browse files

Merge pull request #478 from vtexier/dev

fix wrong date of last UD in referential relative_to_past
parents 945b0103 5eb504cb
No related branches found
No related tags found
No related merge requests found
...@@ -72,7 +72,7 @@ class RelativeToPast(BaseReferential): ...@@ -72,7 +72,7 @@ class RelativeToPast(BaseReferential):
async def localized(self, units=False, international_system=False): async def localized(self, units=False, international_system=False):
from . import Relative from . import Relative
value = await self.value() value = await self.value()
block = await self.community.get_block() block = await self.community.get_ud_block()
prefix = "" prefix = ""
if international_system: if international_system:
localized_value, prefix = Relative.to_si(value, self.app.preferences['digits_after_comma']) localized_value, prefix = Relative.to_si(value, self.app.preferences['digits_after_comma'])
...@@ -95,7 +95,7 @@ class RelativeToPast(BaseReferential): ...@@ -95,7 +95,7 @@ class RelativeToPast(BaseReferential):
async def diff_localized(self, units=False, international_system=False): async def diff_localized(self, units=False, international_system=False):
from . import Relative from . import Relative
value = await self.differential() value = await self.differential()
block = await self.community.get_block(self._block_number) block = await self.community.get_ud_block(0, self._block_number)
prefix = "" prefix = ""
if international_system and value != 0: if international_system and value != 0:
localized_value, prefix = Relative.to_si(value, self.app.preferences['digits_after_comma']) localized_value, prefix = Relative.to_si(value, self.app.preferences['digits_after_comma'])
......
...@@ -51,7 +51,7 @@ class TestRelativeToPast(unittest.TestCase, QuamashTest): ...@@ -51,7 +51,7 @@ class TestRelativeToPast(unittest.TestCase, QuamashTest):
@patch('sakia.core.Application') @patch('sakia.core.Application')
def test_localized_no_si(self, app, community): def test_localized_no_si(self, app, community):
community.dividend = CoroutineMock(return_value=1000) community.dividend = CoroutineMock(return_value=1000)
community.get_block = CoroutineMock(return_value={'medianTime': 1452663088792}) community.get_ud_block = CoroutineMock(return_value={'medianTime': 1452663088792})
type(community).short_currency = PropertyMock(return_value="TC") type(community).short_currency = PropertyMock(return_value="TC")
app.preferences = { app.preferences = {
'digits_after_comma': 6 'digits_after_comma': 6
...@@ -70,7 +70,7 @@ class TestRelativeToPast(unittest.TestCase, QuamashTest): ...@@ -70,7 +70,7 @@ class TestRelativeToPast(unittest.TestCase, QuamashTest):
@patch('sakia.core.Application') @patch('sakia.core.Application')
def test_localized_with_si(self, app, community): def test_localized_with_si(self, app, community):
community.dividend = CoroutineMock(return_value=1000000) community.dividend = CoroutineMock(return_value=1000000)
community.get_block = CoroutineMock(return_value={'medianTime': 1452663088792}) community.get_ud_block = CoroutineMock(return_value={'medianTime': 1452663088792})
type(community).short_currency = PropertyMock(return_value="TC") type(community).short_currency = PropertyMock(return_value="TC")
app.preferences = { app.preferences = {
'digits_after_comma': 6 'digits_after_comma': 6
...@@ -89,7 +89,7 @@ class TestRelativeToPast(unittest.TestCase, QuamashTest): ...@@ -89,7 +89,7 @@ class TestRelativeToPast(unittest.TestCase, QuamashTest):
@patch('sakia.core.Application') @patch('sakia.core.Application')
def test_localized_no_units_no_si(self, app, community): def test_localized_no_units_no_si(self, app, community):
community.dividend = CoroutineMock(return_value=10000) community.dividend = CoroutineMock(return_value=10000)
community.get_block = CoroutineMock(return_value={'medianTime': 1452663088792}) community.get_ud_block = CoroutineMock(return_value={'medianTime': 1452663088792})
type(community).short_currency = PropertyMock(return_value="TC") type(community).short_currency = PropertyMock(return_value="TC")
app.preferences = { app.preferences = {
'digits_after_comma': 6 'digits_after_comma': 6
...@@ -104,7 +104,7 @@ class TestRelativeToPast(unittest.TestCase, QuamashTest): ...@@ -104,7 +104,7 @@ class TestRelativeToPast(unittest.TestCase, QuamashTest):
@patch('sakia.core.Application') @patch('sakia.core.Application')
def test_localized_no_units_with_si(self, app, community): def test_localized_no_units_with_si(self, app, community):
community.dividend = CoroutineMock(return_value=1000000) community.dividend = CoroutineMock(return_value=1000000)
community.get_block = CoroutineMock(return_value={'medianTime': 1452663088792}) community.get_ud_block = CoroutineMock(return_value={'medianTime': 1452663088792})
type(community).short_currency = PropertyMock(return_value="TC") type(community).short_currency = PropertyMock(return_value="TC")
app.preferences = { app.preferences = {
'digits_after_comma': 6 'digits_after_comma': 6
...@@ -123,7 +123,7 @@ class TestRelativeToPast(unittest.TestCase, QuamashTest): ...@@ -123,7 +123,7 @@ class TestRelativeToPast(unittest.TestCase, QuamashTest):
@patch('sakia.core.Application') @patch('sakia.core.Application')
def test_diff_localized_no_si(self, app, community): def test_diff_localized_no_si(self, app, community):
community.dividend = CoroutineMock(return_value=10000) community.dividend = CoroutineMock(return_value=10000)
community.get_block = CoroutineMock(return_value={'medianTime': 1452663088792}) community.get_ud_block = CoroutineMock(return_value={'medianTime': 1452663088792})
type(community).short_currency = PropertyMock(return_value="TC") type(community).short_currency = PropertyMock(return_value="TC")
app.preferences = { app.preferences = {
'digits_after_comma': 6 'digits_after_comma': 6
...@@ -142,7 +142,7 @@ class TestRelativeToPast(unittest.TestCase, QuamashTest): ...@@ -142,7 +142,7 @@ class TestRelativeToPast(unittest.TestCase, QuamashTest):
@patch('sakia.core.Application') @patch('sakia.core.Application')
def test_diff_localized_with_si(self, app, community): def test_diff_localized_with_si(self, app, community):
community.dividend = CoroutineMock(return_value=1000000) community.dividend = CoroutineMock(return_value=1000000)
community.get_block = CoroutineMock(return_value={'medianTime': 1452663088792}) community.get_ud_block = CoroutineMock(return_value={'medianTime': 1452663088792})
type(community).short_currency = PropertyMock(return_value="TC") type(community).short_currency = PropertyMock(return_value="TC")
app.preferences = { app.preferences = {
'digits_after_comma': 6 'digits_after_comma': 6
...@@ -161,7 +161,7 @@ class TestRelativeToPast(unittest.TestCase, QuamashTest): ...@@ -161,7 +161,7 @@ class TestRelativeToPast(unittest.TestCase, QuamashTest):
@patch('sakia.core.Application') @patch('sakia.core.Application')
def test_diff_localized_no_units_no_si(self, app, community): def test_diff_localized_no_units_no_si(self, app, community):
community.dividend = CoroutineMock(return_value=10000) community.dividend = CoroutineMock(return_value=10000)
community.get_block = CoroutineMock(return_value={'medianTime': 1452663088792}) community.get_ud_block = CoroutineMock(return_value={'medianTime': 1452663088792})
type(community).short_currency = PropertyMock(return_value="TC") type(community).short_currency = PropertyMock(return_value="TC")
app.preferences = { app.preferences = {
'digits_after_comma': 6 'digits_after_comma': 6
...@@ -176,7 +176,7 @@ class TestRelativeToPast(unittest.TestCase, QuamashTest): ...@@ -176,7 +176,7 @@ class TestRelativeToPast(unittest.TestCase, QuamashTest):
@patch('sakia.core.Application') @patch('sakia.core.Application')
def test_diff_localized_no_units_with_si(self, app, community): def test_diff_localized_no_units_with_si(self, app, community):
community.dividend = CoroutineMock(return_value=1000000) community.dividend = CoroutineMock(return_value=1000000)
community.get_block = CoroutineMock(return_value={'medianTime': 1452663088792}) community.get_ud_block = CoroutineMock(return_value={'medianTime': 1452663088792})
type(community).short_currency = PropertyMock(return_value="TC") type(community).short_currency = PropertyMock(return_value="TC")
app.preferences = { app.preferences = {
'digits_after_comma': 6 'digits_after_comma': 6
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment