def test_unit_interface_get_per_values(): pcs = UnitInterface(PiecesSalesUnit()) gram = get_g_in_kg_unit(decimals=3, display_decimals=1) gram.display_unit.comparison_value = 100 with translation.override('en'): assert pcs.get_per_values() == (1, '') assert pcs.get_per_values(force_symbol=True) == (1, 'pc.') assert gram.get_per_values() == (Decimal('0.1'), '100.0g')
def test_unit_interface_get_per_values(): pcs = UnitInterface(PiecesSalesUnit()) gram = get_g_in_kg_unit(decimals=3, display_decimals=1) gram.display_unit.comparison_value = 100 with translation.override("en"): assert pcs.get_per_values() == (1, "") assert pcs.get_per_values(force_symbol=True) == (1, "pc.") assert gram.get_per_values() == (Decimal("0.1"), "100.0g")
def test_pieces_sales_unit(): pcs = PiecesSalesUnit() assert pcs.identifier == '_internal_pieces_unit' with translation.override(None): assert pcs.name == "Pieces" assert pcs.symbol == "pc." assert '{}'.format(pcs) == "Pieces" assert isinstance(pcs.display_unit, SalesUnitAsDisplayUnit) assert pcs.display_unit.internal_unit == pcs
def test_unit_interface_render_quantity_internal_pieces(): pcs = UnitInterface(PiecesSalesUnit()) with translation.override('en'): assert pcs.render_quantity_internal(123) == '123' assert pcs.render_quantity_internal(1234567) == '1,234,567' assert pcs.render_quantity_internal(0.123) == '0' assert pcs.render_quantity_internal('52.1') == '52' assert pcs.render_quantity_internal('52.5') == '53' assert pcs.render_quantity_internal('53.5') == '54' assert pcs.render_quantity_internal(123, force_symbol=True) == '123pc.'
def test_unit_interface_render_quantity_internal_pieces(): pcs = UnitInterface(PiecesSalesUnit()) with translation.override("en"): assert pcs.render_quantity_internal(123) == "123" assert pcs.render_quantity_internal(1234567) == "1,234,567" assert pcs.render_quantity_internal(0.123) == "0" assert pcs.render_quantity_internal("52.1") == "52" assert pcs.render_quantity_internal("52.5") == "53" assert pcs.render_quantity_internal("53.5") == "54" assert pcs.render_quantity_internal(123, force_symbol=True) == "123pc."