mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-07 15:48:29 +02:00
Fix broken test import paths
This commit is contained in:
parent
3444414638
commit
853b708ece
10 changed files with 0 additions and 0 deletions
0
tests/test_data/test_embeds/__init__.py
Normal file
0
tests/test_data/test_embeds/__init__.py
Normal file
45
tests/test_data/test_embeds/test_urban_dictionary.py
Normal file
45
tests/test_data/test_embeds/test_urban_dictionary.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
from data.embeds.urban_dictionary import Definition
|
||||
import unittest
|
||||
|
||||
|
||||
class TestUD(unittest.TestCase):
|
||||
def test_clean_string(self):
|
||||
self.assertEqual(
|
||||
Definition.clean_string("A definition [with links] to other [definitions]"),
|
||||
"A definition with links to other definitions"
|
||||
)
|
||||
|
||||
no_processing = "A string that needs no processing."
|
||||
self.assertEqual(Definition.clean_string(no_processing), no_processing)
|
||||
|
||||
long_string = "A very long string that hopefully exceeds the 1024 character limit for embed field values, " \
|
||||
"in order to test if the truncation part of this specific function works as expected. " \
|
||||
"The issue is that coming up with a string that exceeds the 1024 embed field value character " \
|
||||
"limit is quite tedious, so I have no idea how I plan on ever finishing this." \
|
||||
"As of the writing of this sentence, I'm only a third of the way there." \
|
||||
"Crazy. I could probably just toss some lorem ipsum in there, but that would be no fun." \
|
||||
"Or would it? Hey GitHub, Didier here." \
|
||||
"Instead I would like to take this opportunity to out my frustrations on the abomination of a " \
|
||||
"\"language\" that is Haskell. You see, Haskell is just terrible and useless. " \
|
||||
"It truly does pose the bane of my existence, and I deeply hope that I will never have to use it " \
|
||||
"ever again in my life. Good thing I somehow managed to pass that class, otherwise I would've " \
|
||||
"probably collapsed mentally on the spot. As it turns out, though, this sentence is already in the " \
|
||||
"900 character range, so I don't have much of a reason to continue writing about the worst " \
|
||||
"invention humanity has ever come up with."
|
||||
|
||||
self.assertGreater(len(long_string), 1024)
|
||||
self.assertEqual(len(Definition.clean_string(long_string)), 1024)
|
||||
self.assertEqual(Definition.clean_string(long_string)[-3:], "...")
|
||||
|
||||
def test_ratio(self):
|
||||
dic = {
|
||||
"thumbs_up": 5,
|
||||
"thumbs_down": 0
|
||||
}
|
||||
self.assertEqual(Definition.ratio(dic), 100.0)
|
||||
|
||||
dic["thumbs_down"] = 5
|
||||
self.assertEqual(Definition.ratio(dic), 50.0)
|
||||
|
||||
dic["thumbs_up"] = 0
|
||||
self.assertEqual(Definition.ratio(dic), 0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue