Skip to content

Commit

Permalink
Update test_generate_hashtag.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Dec 14, 2024
1 parent 39b58e0 commit f952729
Showing 1 changed file with 35 additions and 36 deletions.
71 changes: 35 additions & 36 deletions kyu_5/the_hashtag_generator/test_generate_hashtag.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import unittest
import allure
from parameterized import parameterized
from utils.log_func import print_log
from kyu_5.the_hashtag_generator.hashtag_generator \
import generate_hashtag
Expand All @@ -30,33 +31,8 @@
class GenerateHashtagTestCase(unittest.TestCase):
"""Testing generate_hashtag function."""

def test_generate_hashtag(self):
"""
Testing 'generate_hashtag' function with various test data.
:return:
"""
allure.dynamic.title("Testing 'generate_hashtag' function")
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'<h3>Codewars badge:</h3>'
'<img src='
'"https://www.codewars.com/users/myFirstCode/badges/large">'
'<h3>Test Description:</h3>'
"<p>The function should do the following:"
"<br/>1. It must start with a hashtag (#)."
"<br/>2. "
"All words must have their first letter capitalized."
"<br/>3. "
"If the final result is longer than 140 chars it "
"must return false."
"<br/>4. "
"If the input or the result is an empty string it "
"must return false."
"</p>")

test_data: tuple = (
('',
@parameterized.expand(
[('',
False,
'Expected an empty string to return False'),
('Codewars',
Expand Down Expand Up @@ -89,14 +65,37 @@ def test_generate_hashtag(self):
'oooooong Cat',
False,
'Should return False if the final word is '
'longer than 140 chars.'))
'longer than 140 chars.')]
)
def test_generate_hashtag(self, string, expected, message):
"""
Testing 'generate_hashtag' function with various test data.
for string, expected, message in test_data:
actual_result = generate_hashtag(string)
:return:
"""
allure.dynamic.title("Testing 'generate_hashtag' function")
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html(
'<h3>Codewars badge:</h3>'
'<img src='
'"https://www.codewars.com/users/myFirstCode/badges/large">'
'<h3>Test Description:</h3>'
"<p>The function should do the following:"
"<br/>1. It must start with a hashtag (#)."
"<br/>2. "
"All words must have their first letter capitalized."
"<br/>3. "
"If the final result is longer than 140 chars it "
"must return false."
"<br/>4. "
"If the input or the result is an empty string it "
"must return false."
"</p>")

with allure.step("Enter a test string and verify the output:"):
print_log(string=string,
message=message,
expected=expected,
actual_result=actual_result)
self.assertEqual(expected, actual_result, msg=message)
with allure.step("Enter a test string and verify the output:"):
actual_result = generate_hashtag(string)
print_log(string=string,
message=message,
expected=expected,
actual_result=actual_result)
self.assertEqual(expected, actual_result, message)

0 comments on commit f952729

Please sign in to comment.