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

⬆️ CI/CD: Update #1

Merged
merged 9 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 0 additions & 18 deletions .github/workflows/python-app-coverage.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/python-app-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: ❤️️ Unit Testing

on:
pull_request:
branches: [ "develop" ]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v3
- name: ⚙️ Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: ⚙️ Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt --no-cache-dir
pip install tox tox-gh-actions
- name: 📝️ Code Scan
run: |
flake8 email_profile/ --count --show-source --statistics --ignore=E501
flake8 tests/ --count --show-source --statistics --ignore=E501,E712
- name: ❤️️ Test with PyTest
run: |
pytest
- name: ❤️️ Test with Tox
run: |
tox
21 changes: 1 addition & 20 deletions email_profile/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,9 @@
CLI Module
"""

import os

from datetime import date
from dotenv import load_dotenv
from email_profile import Email


def main():
"""Test"""
load_dotenv()

app = Email(
server=os.getenv("EMAIL_SERVER"),
user=os.getenv("EMAIL_USERNAME"),
password=os.getenv("EMAIL_PASSWORD")
)

# Query instance
query = app.select(mailbox="Inbox").where(subject="abc")

# Query result
print(query.execute())
pass


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion email_profile/config/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
)

mapper_registry = registry()
Base = mapper_registry.generate_base()
Base = mapper_registry.generate_base()
4 changes: 2 additions & 2 deletions email_profile/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
Data Module
"""

from typing import Dict
from typing import List, Dict
from abc import abstractmethod, ABC


class DataAbstract(ABC):

def __init__(self) -> None:
self.email: EmailModel = None
self.email: object = None
self.attachments: List[object] = list()

def add_email(self, model: object):
Expand Down
9 changes: 3 additions & 6 deletions email_profile/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def decode_field(self, header) -> str:
encoding = sub[1] or "utf-8"
try:
field += sub[0].decode(encoding)
except Exception as error:
except Exception:
field += sub[0]

return field
Expand All @@ -35,13 +35,13 @@ def get_content(self, part) -> None:
if content_type == "text/plain":
try:
self.body_text_plain = part.get_payload(decode=True).decode()
except Exception as error:
except Exception:
self.body_text_plain = part.get_payload(decode=True)

if content_type == "text/html":
try:
self.body_text_html = part.get_payload(decode=True).decode()
except Exception as error:
except Exception:
self.body_text_html = part.get_payload(decode=True)
if isinstance(self.body_text_html, bytes):
self.body_text_html = part.get_payload()
Expand All @@ -59,9 +59,6 @@ def get_content(self, part) -> None:
)

def result(self) -> EmailModel:
body_text_plain = ""
body_text_html = ""

for part in self.message.walk():
self.get_content(part=part)

Expand Down
3 changes: 1 addition & 2 deletions email_profile/models/attachment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from uuid import uuid4
from sqlalchemy import Column, String, Integer, TEXT, ForeignKey

from email_profile.config.database import Base, engine
Expand All @@ -17,4 +16,4 @@ class AttachmentModel(Base):
content_ascii = Column(TEXT)


Base.metadata.create_all(bind=engine)
Base.metadata.create_all(bind=engine)
3 changes: 1 addition & 2 deletions email_profile/models/email.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from uuid import uuid4
from sqlalchemy import Column, String, DateTime, Integer

from email_profile.config.database import Base, engine
Expand Down Expand Up @@ -50,4 +49,4 @@ class EmailModel(Base):
x_entity_id = Column(String)


Base.metadata.create_all(bind=engine)
Base.metadata.create_all(bind=engine)
4 changes: 2 additions & 2 deletions email_profile/models/mailbox.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from uuid import uuid4
from sqlalchemy import Column, String, TEXT, ForeignKey
from sqlalchemy import Column, String

from email_profile.config.database import Base, engine

Expand All @@ -13,4 +13,4 @@ class MailBoxModel(Base):
name = Column(String)


Base.metadata.create_all(bind=engine)
Base.metadata.create_all(bind=engine)
2 changes: 1 addition & 1 deletion email_profile/serializers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__all__ = [
"WhereSerializer"
]
]
12 changes: 6 additions & 6 deletions email_profile/serializers/where.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,27 @@ class WhereSerializer(BaseModel):
unique identifier set. Sequence set ranges are permitted.

UNANSWERED
Messages that do not have the \Answered flag set.
Messages that do not have the Answered flag set.

UNDELETED
Messages that do not have the \Deleted flag set.
Messages that do not have the Deleted flag set.

UNDRAFT
Messages that do not have the \Draft flag set.
Messages that do not have the Draft flag set.

UNFLAGGED
Messages that do not have the \Flagged flag set.
Messages that do not have the Flagged flag set.

UNKEYWORD <flag>
Messages that do not have the specified keyword flag set.

UNSEEN
Messages that do not have the \Seen flag set.
Messages that do not have the Seen flag set.
"""

since: date = Field(default="")
before: date = Field(default="")
subject: str = Field(default="")
subject: str = Field(default="")
from_who: str = Field(default="")

@field_validator('since')
Expand Down
1 change: 1 addition & 0 deletions email_profile/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from typing import List


class Status:
"""
------
Expand Down
6 changes: 2 additions & 4 deletions email_profile/where.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ class Where:
def __init__(self,
mode: Mode = Mode.ALL,
mailbox: Mailbox = Mailbox.INBOX,
server: any = None
) -> None:
server: any = None) -> None:
self.mode = mode
self.mailbox = mailbox
self.server = server
Expand All @@ -30,8 +29,7 @@ def where(self,
since: Optional[date] = None,
before: Optional[date] = None,
subject: Optional[str] = None,
from_who: Optional[str] = None
) -> object:
from_who: Optional[str] = None) -> object:
local = locals().copy()
options = {}

Expand Down
Loading
Loading