Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge from master #577

Merged
merged 25 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8e5724a
Update requirements.txt
ikostan Dec 24, 2024
8fdde8e
Merge pull request #573 from iKostanOrg/kyu8
ikostan Dec 24, 2024
73457ed
pydocstyle for main
ikostan Dec 24, 2024
4e001d6
Update closest_elevator.py
ikostan Dec 24, 2024
86d4a41
Update test_take.py
ikostan Dec 24, 2024
47bab94
Update README.md
ikostan Dec 24, 2024
3b68c84
Update lint_test_build_pipeline.yml
ikostan Dec 24, 2024
c8b9a8d
Update lint_test_build_pipeline.yml
ikostan Dec 24, 2024
2f84a83
Update markdown_lint.yml
ikostan Dec 24, 2024
c5f9151
Merge pull request #575 from iKostanOrg/master
ikostan Dec 25, 2024
6714668
Update requirements.txt
ikostan Dec 25, 2024
d05537e
Merge branch 'kyu7' of https://github.com/iKostanOrg/codewars into kyu7
ikostan Dec 25, 2024
c984b53
Complete The Pattern #5 - Even Ladder
ikostan Dec 25, 2024
710e437
Complete The Pattern #5 - Even Ladder.
ikostan Dec 25, 2024
d33aef1
Update solution.py
ikostan Dec 25, 2024
c554733
Create test_logical_calculator_error.py
ikostan Dec 25, 2024
bee5ccc
Update solution.py
ikostan Dec 25, 2024
372d14f
Update test_pattern.py
ikostan Dec 25, 2024
afa284c
Update test_logical_calculator_error.py
ikostan Dec 25, 2024
947261e
Update test_logical_calculator_error.py
ikostan Dec 25, 2024
10e9323
Update test_logical_calculator_error.py
ikostan Dec 25, 2024
763f6bf
Merge pull request #576 from iKostanOrg/kyu7
ikostan Dec 25, 2024
cbdfe06
Update solution.py
ikostan Dec 25, 2024
8af04df
Update test_logical_calculator_error.py
ikostan Dec 25, 2024
cb8aece
Update test_logical_calculator_error.py
ikostan Dec 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/lint_test_build_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
yamllint:
name: YAML Lint
uses: iKostanOrg/codewars/.github/workflows/yamllint.yml@master
pydocstyle:
name: PyDocStyle Lint
uses: iKostanOrg/codewars/.github/workflows/pydocstyle.yml@master
pytest:
name: Unitest with pytest
needs:
Expand All @@ -30,6 +33,7 @@ jobs:
- markdown
- mypy
- yamllint
- pydocstyle
uses: iKostanOrg/codewars/.github/workflows/pytest.yml@master
codecov:
name: Codecov GitHub Action
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/markdown_lint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: 'Markdown Lint'
name: Markdown Lint

on: # yamllint disable-line rule:truthy
push:
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/pydocstyle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
name: pydocstyle

on: # yamllint disable-line rule:truthy
push:
branches:
- 'utils'
- 'none'
workflow_call:

permissions:
contents: read
pull-requests: read

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.x"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
# This is the version of the action for setting up Python,
# not the Python version.
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# You can test your matrix by printing the current Python version
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.txt
pip install pydocstyle
pip install types-requests
- name: Check to make sure that the module is in your Python path
run: |
echo $PYTHONPATH
- name: Check pydocstyle version
run: |
pydocstyle --version
# Pydocstyle testing (Guide)
# https://www.pydocstyle.org/en/stable/usage.html#cli-usage
- name: Doc style checking with pydocstyle for kyu_2
run: |
pydocstyle --verbose --explain --count kyu_2
- name: Doc style checking with pydocstyle for kyu_3
run: |
pydocstyle --verbose --explain --count kyu_3
- name: Doc style checking with pydocstyle for kyu_4
run: |
pydocstyle --verbose --explain --count kyu_4
- name: Doc style checking with pydocstyle for kyu_5
run: |
pydocstyle --verbose --explain --count kyu_5
- name: Doc style checking with pydocstyle for kyu_6
run: |
pydocstyle --verbose --explain --count kyu_6
- name: Doc style checking with pydocstyle for kyu_7
run: |
pydocstyle --verbose --explain --count kyu_7
- name: Doc style checking with pydocstyle for kyu_8
run: |
pydocstyle --verbose --explain --count kyu_8
72 changes: 37 additions & 35 deletions kyu_7/README.md

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions kyu_7/coloured_triangles/test_triangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ def test_triangle(self, string, expected):

:return:
"""
# pylint: disable-msg=R0801
allure.dynamic.title("Basic test case for triangle func.")
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></p>")
# pylint: enable-msg=R0801
with allure.step(f"Enter test string: {string} "
f"and verify the output: {expected}"):
result = triangle(string)
Expand Down
38 changes: 38 additions & 0 deletions kyu_7/complete_the_pattern_5_even_ladder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Complete The Pattern #5 - Even Ladder

## Description

You have to write a function pattern which creates the following pattern
up to `n/2` number of lines.

If `n <= 1` then it should return `""` (i.e. empty string).

If any odd number is passed as argument then the pattern should last up to
the largest even number which is smaller than the passed odd number.


## Examples

```bash
n = 8:

22
4444
666666
88888888

n = 5:

22
4444
```

### Note

There are no spaces in the pattern.

### Hint

Use `\n` in string to jump to next line.

[Source](https://www.codewars.com/kata/55749101ae1cf7673800003e)
1 change: 1 addition & 0 deletions kyu_7/complete_the_pattern_5_even_ladder/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Complete The Pattern #5 - Even Ladder."""
26 changes: 26 additions & 0 deletions kyu_7/complete_the_pattern_5_even_ladder/solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""
Solution for -> Complete The Pattern #5 - Even Ladder.

Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""


def pattern(n: int) -> str:
"""
'pattern' function.

Create the pattern up to n/2 number of lines.
:param n:
:return:
"""
# If n <= 1 then it should return "" (i.e. empty string).
if n < 2:
return ''
# If any odd number is passed as argument then the pattern
# should last up to the largest even number which is smaller
# than the passed odd number.
# Note: There are no spaces in the pattern.lines.append()
# Use \n in string to jump to next line.
lines: list = [(f'{i}' * i) for i in range(2, n + 1, 2)]
return '\n'.join(lines)
94 changes: 94 additions & 0 deletions kyu_7/complete_the_pattern_5_even_ladder/test_pattern.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
"""
Test for -> Complete The Pattern #5 - Even Ladder.

Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""

# ASCII FUNDAMENTALS

import unittest
import allure # pylint: disable=import-error
from parameterized import parameterized
from utils.log_func import print_log
from kyu_7.complete_the_pattern_5_even_ladder.solution import pattern


# pylint: disable-msg=R0801
@allure.epic('7 kyu')
@allure.parent_suite('Beginner')
@allure.suite("Fundamentals")
@allure.sub_suite("Unit Tests")
@allure.feature("Lists")
@allure.story('Complete The Pattern #5 - Even Ladder')
@allure.tag('ASCII',
'FUNDAMENTALS')
@allure.link(
url='https://www.codewars.com/kata/55749101ae1cf7673800003e',
name='Source/Kata')
# pylint: enable-msg=R0801
class PatternTestCase(unittest.TestCase):
"""Testing pattern function."""

@parameterized.expand([
(2, "22"),
(1, ""),
(5, "22\n4444"),
(6, "22\n4444\n666666"),
(0, ""),
(-25, "")])
def test_pattern(self, n, expected):
"""
Basic test case for pattern func.

:return:
"""
# pylint: disable-msg=R0801
allure.dynamic.title("Basic test case for pattern func.")
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>"
"If n <= 1 then it should return "" (i.e. empty string)."
"</p>"
"<p>"
"If any odd number is passed as argument then the pattern "
"should last up to the largest even number which is smaller "
"than the passed odd number."
"</p>")
# pylint: enable-msg=R0801
with allure.step(f"Enter test number (n): {n} "
f"and verify the output: {expected}"):
result = pattern(n)
print_log(n=n, expected=expected, result=result)
self.assertEqual(expected, result, msg=expected)

@parameterized.expand([
(8, "22\n4444\n666666\n88888888")])
def test_pattern_has_no_spaces(self, n, expected):
"""
Output should not have any spaces..

:return:
"""
# pylint: disable-msg=R0801
allure.dynamic.title("Test no spaces in output.")
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>"
"There are no spaces in the pattern."
"</p>")
# pylint: enable-msg=R0801
with allure.step(f"Enter test number (n): {n} "
"and verify the output has no spaces."):
result = pattern(n)
print_log(n=n, expected=expected, result=result)
self.assertEqual(result, expected)
self.assertEqual(result.count(' '), 0)
2 changes: 1 addition & 1 deletion kyu_8/closest_elevator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You can assume that the inputs will always be valid integers between 0-2.

## Examples

```
```bash
left right call result
0 1 0 "left"
0 1 1 "right"
Expand Down
1 change: 1 addition & 0 deletions kyu_8/closest_elevator/closest_elevator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
GitHub: https://github.com/ikostan
"""


def elevator(left: int, right: int, call: int) -> str:
"""
Return closest elevator number.
Expand Down
8 changes: 4 additions & 4 deletions kyu_8/enumerable_magic_25/test_take.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ def test_take(self, arr, n, expected):
f"expected output ({expected}) "
f"vs actual result ({actual_result})"):

print_log(rr=arr,
n=n,
expected=expected,
result=actual_result)
print_log(arr=arr,
n=n,
expected=expected,
result=actual_result)

self.assertEqual(expected, actual_result)
61 changes: 61 additions & 0 deletions kyu_8/logical_calculator/test_logical_calculator_error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"""
Test for -> Logical Calculator ValueError.

Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""

# FUNDAMENTALS ARRAYS

import unittest
import allure
import pytest
from kyu_8.logical_calculator.logical_calculator \
import logical_calc


# pylint: disable=R0801
@allure.epic('8 kyu')
@allure.parent_suite('Beginner')
@allure.suite("Data Structures")
@allure.sub_suite("Unit Tests")
@allure.feature("Lists")
@allure.story('Logical Calculator')
@allure.tag('FUNDAMENTALS',
'ARRAYS'
"ValueError")
@allure.link(
url='https://www.codewars.com/kata/57096af70dad013aa200007b',
name='Source/Kata')
# pylint: enable=R0801
class LogicalCalculatorValueErrorTestCase(unittest.TestCase):
"""Testing ValueError."""

def test_logical_calc_value_error(self):
"""
Testing ValueError for logical_calc function.

:return:
"""
# pylint: disable=R0801
allure.dynamic.title("Testing ValueError for logical_calc 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>"
"Test Python Exception Handling Using 'pytest.raises'."
"</p>")
# pylint: enable=R0801
with allure.step("Pass an array with invalid operator."):
arr: list = []
op: str = 'RO' # invalid operator
operators: list = ['AND', 'OR', 'XOR']
err = (f'ERROR: {op} is not a valid operator. '
f'Please use one of the followings: {operators}')
with pytest.raises(ValueError) as calc_err:
logical_calc(arr, op)
self.assertEqual(str(calc_err.value), err)
sourcery-ai[bot] marked this conversation as resolved.
Show resolved Hide resolved
Loading