-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
127 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[run] | ||
branch = True | ||
source=callbaker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
sudo: false | ||
language: python | ||
python: | ||
- "3.5" | ||
- "3.6" | ||
- "3.7" | ||
- "3.8" | ||
- "3.9-dev" | ||
- "3.9" | ||
- "3.10-dev" | ||
- "nightly" | ||
|
||
# command to install dependencies | ||
install: | ||
- pip install -r requirements.txt | ||
- pip install -r requirements-tests.txt | ||
|
||
# command to run tests | ||
script: | ||
- pytest tests/ | ||
- pytest --cov=callbaker tests/ | ||
|
||
after_success: | ||
- bash <(curl -s https://codecov.io/bash) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
# 👨🍳 callbaker | ||
[![Download Callbaker](https://img.shields.io/pypi/v/callbaker.svg)](https://pypi.python.org/pypi/callbaker) | ||
![CodeQL](https://github.com/torrua/callbaker/workflows/CodeQL/badge.svg?branch=master) | ||
[![Build Status](https://travis-ci.com/torrua/callbaker.svg?branch=main)](https://travis-ci.com/torrua/callbaker) | ||
[![codecov](https://codecov.io/gh/torrua/callbaker/branch/master/graph/badge.svg?token=CHCS5JEGZI)](https://codecov.io/gh/torrua/callbaker) | ||
|
||
Telegram callback queries converter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pytest | ||
pytest-cov |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pytest | ||
|
||
from callbaker import callback_from_info | ||
|
||
|
||
class TestCallbackFromInfo: | ||
@pytest.mark.parametrize("data", [None, False, 234, "str"]) | ||
def test_info_not_a_str(self, data): | ||
with pytest.raises(TypeError) as _: | ||
callback_from_info(info=data) | ||
|
||
def test_separators_not_a_str(self): | ||
with pytest.raises(TypeError) as _: | ||
callback_from_info(info={"k": "v", }, separators=("1", "2", 3)) | ||
|
||
def test_info(self): | ||
result = callback_from_info( | ||
info={"k1": "str", "k2": 2, "k3": None, "k4": False, "k5": (1, 2)}) | ||
assert isinstance(result, str) | ||
assert result == "&k1=str&k2=2&k3=None&k4=False&k5=(1, 2)" | ||
|
||
def test_info_wrong(self): | ||
with pytest.raises(ValueError) as _: | ||
callback_from_info( | ||
info={"k1": "s" * 60, "k2": 2, "k3": None, | ||
"k4": False, "k5": (1, 2)}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import pytest | ||
|
||
from callbaker import info_from_callback | ||
|
||
|
||
class TestInfoFromCallback: | ||
""" | ||
""" | ||
|
||
bool_tuple = (None, False, True) | ||
|
||
@pytest.mark.parametrize("data", ["key_1=value_1", "&key_1=value_1"]) | ||
def test_call_data_1(self, data): | ||
result = info_from_callback(call_data=data) | ||
assert isinstance(result, dict) | ||
assert len(result) == 1 | ||
assert result == {'key_1': 'value_1'} | ||
|
||
def test_call_data_2(self): | ||
result = info_from_callback( | ||
call_data="&key_1=value_1&key_2=value_2") | ||
assert isinstance(result, dict) | ||
assert len(result) == 2 | ||
assert result == {'key_1': 'value_1', 'key_2': 'value_2'} | ||
|
||
@pytest.mark.parametrize("data", [None, False, 234]) | ||
def test_call_data_not_a_str(self, data): | ||
with pytest.raises(TypeError) as _: | ||
info_from_callback(call_data=data) | ||
|
||
def test_separators_not_a_str(self): | ||
with pytest.raises(TypeError) as _: | ||
info_from_callback(call_data="test", separators=("1", "2", 3)) | ||
|
||
def test_call_data_without_separators(self): | ||
with pytest.raises(ValueError) as _: | ||
info_from_callback(call_data="test") | ||
|
||
@pytest.mark.parametrize("value", bool_tuple) | ||
def test_call_data_bool(self, value): | ||
result = info_from_callback( | ||
call_data=f"&key_1={value}") | ||
assert isinstance(result, dict) | ||
assert result['key_1'] == value | ||
|
||
def test_call_data_digit(self): | ||
result = info_from_callback( | ||
call_data=f"&key_1=20") | ||
assert isinstance(result, dict) | ||
assert result['key_1'] == 20 |