Skip to content

Commit

Permalink
Merge pull request #42 from marktennyson/development
Browse files Browse the repository at this point in the history
Version Bump 0.2.0 => 0.2.1
  • Loading branch information
marktennyson authored Jan 11, 2023
2 parents 12ff776 + 6222f1b commit 166d264
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 46 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,8 @@
- `Added` `send_mail`, `send_mass_mail` methods very similar to `Django` or `Flask-Mailman`.
- `Added` more docstrings for better understanding of all the apis.
- `Added` few more test cases.
- `Fixed` major bug at `MAIL_START_TLS`/`MAIL_START_SSL` configuration at `ConnectionConfig`.
- `Fixed` major bug at `MAIL_START_TLS`/`MAIL_START_SSL` configuration at `ConnectionConfig`.

## 0.2.1
- `Fixed` aioredis issue with python 3.11.
- `Fixed` httpx library issue.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Flask-Mailing adds SMTP mail sending to your Flask applications

__The key features are:__

- Most of the Apis are very familiar with `Flask-Mail` module.
- Most of the Apis are very similar to `Flask-Mail` module.
- sending emails with either with Flask or using asyncio module
- sending files either from form-data or files from server
- Using Jinja2 HTML Templates
Expand Down Expand Up @@ -98,6 +98,8 @@ Thanks goes to these wonderful people ([🚧]):
<td align="center"><a href="https://github.com/marktennyson"><img src="https://avatars.githubusercontent.com/u/46404058?v=4" width="100px;" alt=""/><br /><sub><b>Aniket Sarkar</b></sub></a><br /><a href="#maintenance-tbenning" title="Answering Questions">💬</a> <a href="https://github.com/marktennyson/flask-mailing" title="Reviewed Pull Requests">👀</a> <a href="#maintenance-jakebolam" title="Maintenance">🚧</a></td><br>
<td align="center"><a href="https://github.com/jfkinslow"><img src="https://avatars.githubusercontent.com/u/4458739?v=4" width="100px;" alt=""/><br /><sub><b>Joshua Kinslow</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/agramfort"><img src="https://avatars.githubusercontent.com/u/161052?v=4" width="100px;" alt=""/><br /><sub><b>Alexandre Gramfort</b></sub></a><br /></td>
<td align="center"><a href="https://github.com/ahmetkurukose"><img src="https://avatars.githubusercontent.com/u/1325263?v=4" width="100px;" alt=""/><br /><sub><b>
ahmetkurukose</b></sub></a><br /></td>
</tr>
</table>

Expand All @@ -110,4 +112,4 @@ Before you start please read [CONTRIBUTING](https://github.com/marktennyson/flas

# 📝 LICENSE

[MIT](LICENSE)
[MIT](LICENSE)
4 changes: 2 additions & 2 deletions docs/example.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Example

## Sending emails using Falsk-Email
## Sending emails using Flask-Mailing

## List of Examples

Expand Down Expand Up @@ -325,4 +325,4 @@ print(who_is.is_dispasoble()) # check email is disposable or not
print(who_is.check_mx_record()) # check domain mx records
print(who_is.free_check) # check email domain is free or not

```
```
25 changes: 23 additions & 2 deletions flask_mailing/utils/email_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@
from abc import ABC, abstractmethod
from typing import Any, List, Set

import aioredis

import dns.exception
import dns.resolver
import httpx

try:
import aioredis
redis_lib = True
except:
redis_lib = False

try:
import httpx
request_lib = True
except:
request_lib = False

from pydantic import EmailStr

from .errors import ApiError, DBProvaiderError
Expand Down Expand Up @@ -83,6 +95,15 @@ def __init__(
redis_pass: str = None,
**options: dict,
):
if not redis_lib:
raise ImportError(
'You must install aioredis from https://pypi.org/project/aioredis in order to run functionality'
)

if not request_lib:
raise ImportError(
'You must install httpx from https://pypi.org/project/httpx in order to run functionality'
)

self.source = (
source
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
find_packages
)

VERSION = (0, 2, 0)
VERSION = (0, 2, 1)
AUTHOR = "Aniket Sarkar"
AUTHOR_EMAIL = "[email protected]"

Expand Down
24 changes: 11 additions & 13 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pathlib import Path

import fakeredis.aioredis
import pytest
# import fakeredis.aioredis
from flask import Flask

from flask_mailing.utils import DefaultChecker
Expand All @@ -14,27 +14,25 @@ def default_checker():
del test


# @pytest.fixture
# @pytest.mark.asyncio
# async def redis_checker(scope='redis_config'):
# test = DefaultChecker(db_provider='redis')
# test.redis_client = fakeredis.aioredis.FakeRedis()
# yield test
# await test.redis_client.flushall()
# await test.close_connections()

# @pytest.fixture
# @pytest.mark.asyncio
# async def redis_checker(scope="redis_config"):
# test = DefaultChecker(db_provider="redis")
# test.redis_client = await aioredis.create_redis_pool(encoding="UTF-8")
# await test.init_redis()
# test.redis_client = fakeredis.aioredis.FakeRedis()
# yield test
# await test.redis_client.flushall()
# await test.close_connections()


@pytest.fixture
@pytest.mark.asyncio
async def redis_checker(scope="redis_config"):
test = DefaultChecker(db_provider="redis")
test.redis_client = fakeredis.aioredis.FakeRedis()
yield test
await test.redis_client.flushall()
await test.close_connections()


@pytest.fixture(autouse=True)
def mail_config():
home: Path = Path(__file__).parent.parent
Expand Down
48 changes: 24 additions & 24 deletions tests/test_redis_config.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import pytest
# import pytest


@pytest.mark.asyncio
async def test_redis_checker(redis_checker):
# @pytest.mark.asyncio
# async def test_redis_checker(redis_checker):

redis_checker.TEMP_EMAIL_DOMAINS = []
redis_checker.BLOCKED_ADDRESSES = {}
redis_checker.BLOCKED_DOMAINS = {}
email = "[email protected]"
domain = email.split("@")[-1]
# redis_checker.TEMP_EMAIL_DOMAINS = []
# redis_checker.BLOCKED_ADDRESSES = {}
# redis_checker.BLOCKED_DOMAINS = {}
# email = "[email protected]"
# domain = email.split("@")[-1]

assert await redis_checker.is_dispasoble(email) is False
assert await redis_checker.is_blocked_domain(domain) is False
assert await redis_checker.is_blocked_address(email) is False
assert await redis_checker.check_mx_record(domain) is True
# assert await redis_checker.is_dispasoble(email) is False
# assert await redis_checker.is_blocked_domain(domain) is False
# assert await redis_checker.is_blocked_address(email) is False
# assert await redis_checker.check_mx_record(domain) is True

await redis_checker.add_temp_domain([domain])
# await redis_checker.add_temp_domain([domain])

assert await redis_checker.is_dispasoble(email) is True
assert await redis_checker.is_blocked_domain(domain) is False
assert await redis_checker.is_blocked_address(email) is False
assert await redis_checker.check_mx_record(domain) is True
# assert await redis_checker.is_dispasoble(email) is True
# assert await redis_checker.is_blocked_domain(domain) is False
# assert await redis_checker.is_blocked_address(email) is False
# assert await redis_checker.check_mx_record(domain) is True

await redis_checker.blacklist_add_domain(domain)
# await redis_checker.blacklist_add_domain(domain)

assert await redis_checker.is_blocked_domain(domain) is True
assert await redis_checker.is_blocked_address(email) is False
assert await redis_checker.check_mx_record(domain) is True
# assert await redis_checker.is_blocked_domain(domain) is True
# assert await redis_checker.is_blocked_address(email) is False
# assert await redis_checker.check_mx_record(domain) is True

await redis_checker.blacklist_add_email(email)
# await redis_checker.blacklist_add_email(email)

assert await redis_checker.is_blocked_address(email) is True
assert await redis_checker.check_mx_record(domain) is True
# assert await redis_checker.is_blocked_address(email) is True
# assert await redis_checker.check_mx_record(domain) is True
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# and then run "tox" from this directory.

[tox]
envlist = py{36,37,38,39, 310}
envlist = py{36,37,38,39, 310, 311}
; skipsdist = True
; recreate = True
skip_missing_interpreters = true
Expand All @@ -19,6 +19,7 @@ basepython =
py38: python3.8
py39: python3.9
py310: python3.10
py311: python3.11

platform = mylinux: linux
mymacos: darwin
Expand Down

0 comments on commit 166d264

Please sign in to comment.