def test_convertCurrencies(): check( '2.179 CZK', text='10.5 Icelandic Króna to Kč', ) check( '3.913 €', text='1 mBTC to €', )
def test_convertHugeNumber(caplog): check( "Sorry, I can't convert such big numbers.", text='99999999999.999 km to m', ) check( "99,999,999,999,990 m", text='99999999999.99 km to m', )
def test_defaultHelp(): check(""" The bot supports following unit categories: - length (ft to m) - area (m² to acre) - volume (litre to pint) - currencies ($ to €) - mass (g to lb) - speed (km/h to mph) - time (min to ms) - temperature (°C to °F) - density (kg/m³ to g/cm³) - information (MB to Kbit) - pressure (atm to Pa) - fuel consumption (mpg to km/l) - power (horsepower to kW) - torque (N-m to lbf-ft) To get all available units of specific category type "/help #category#" ("/help length", for example). While asking me a question tet-a-tet you can omit a command. Just type: - 100 $ to € - 1 sq foot to m2 - 1 year to hours While asking me a question in a group please add the command "convert" (if I'm a group member too) or my username "UnitConversionBot": - /convert 10 yr to mon - @UnitConversionBot 1 ms to second You can also ask me without adding me to the chat. Just type '@UnitConversionBot 100 ft to m' when you need my help. You can use both short (`m2`) and full unit names (square meter). If you have an issue or just want to say thanks, feel free to contact my master @kirillmaltsev or rate me at https://storebot.me/bot/unitconversionbot Thank you for chatting with me :-) """.strip(), text='/help', parse_mode='Markdown')
def test_convertInvalidUnitValue(caplog): check( "Sorry, I don't understand the number 'one'. Please type it in a more ordinary way, like 100 or 12.5", text='one ft to m', )
def test_convertNotExistsUnits(): check( "Sorry, I'm just a stupid bot :-( I don't know what does 'blablagram' mean. But my master probably does. I'd ask him to teach me.", text='1.2 blablagram to wtfgram', )
def test_convertNotExistsFromUnit(caplog): check( "Sorry, I'm just a stupid bot :-( I don't know what does 'blablagram²' mean. But my master probably does. I'd ask him to teach me.", text='1 blablagram² to gram', )
def test_convertIncompatibleUnitCategories(caplog): check( "Sorry, I can't convert foot to gram (at least in this universe).", text='1 ft to g', )
def test_invalidExpression(caplog): check( "Sorry, I'm just a stupid bot :-( I don't know what does 'фут' mean. But my master probably does. I'd ask him to teach me.", text='1 фут в метры', )
def test_convertWithoutToUnit(): check( '30.48 m', text='/convert 100 ft to', )
def test_convertWithBotName(): check( '24 h', text='/convert@UnitConversionBot 1 day to hours' )
def test_emptyConvertExpression(): check( 'Please type something like "/convert 100 ft to m"', text='/convert ', )
def test_convertWithoutCommand(): check( '544.311 g', text='1.2 LB TO Gram' )
def test_convert(caplog): check( '0.093 m²', text='/convert 1 ft² to m²', )
def test_convertWithoutCommandAndWithBotName(): check( '3.6 km/h', text='@UnitConversionBot 1 m/s to km/h' )
def test_start(): check( startMessage, text='/start', )
def test_convertMultilineExpression(): check( '3,600 km/h', text='1000 m/s to km/h\n10 fl.oz to litres', )
def test_commandNotFound(): check( "Sorry, I don't understand your command.", text='/someCommand 1 m² to ft', parse_mode=None, )
def checkHelp(unitsCategory, expected_text_list): check( f'*The full list of {unitsCategory} units:*\n{expected_text_list.strip()}', text=f'/help {unitsCategory}', parse_mode='Markdown')