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

[Dakshta | Dhruvi] add Test workflow #112

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Test

on:
push:
branches: [main]

jobs:
build:
name: Build and Test
runs-on: ubuntu-latest

steps:
- name: Github Action Setup
uses: actions/checkout@v3

- name: Python Setup
uses: actions/setup-python@v4
with:
python-version: '3.8.18'

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies with poetry
run: |
poetry install --only main

- name: Build
run: |
poetry build

- name: Test Run
run: |
make test
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: debug-statements

- repo: https://github.com/myint/autoflake
rev: v1.4
rev: v2.2.1
hooks:
- id: autoflake
args: ['--in-place', '--remove-unused-variable', '--ignore-init-module-imports', '--remove-all-unused-imports']

- repo: https://github.com/asottile/pyupgrade
rev: v2.19.4
rev: v3.15.0
hooks:
- id: pyupgrade
args: ['--py3-plus']
Expand All @@ -24,12 +24,12 @@ repos:
- id: seed-isort-config

- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.9.1
rev: v5.10.1
hooks:
- id: isort

- repo: https://github.com/ambv/black
rev: 22.3.0
rev: 23.10.0
hooks:
- id: black
language_version: python3
Expand All @@ -44,7 +44,7 @@ repos:
exclude: run.py

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.27.1
rev: v0.37.0
hooks:
- id: markdownlint
args: [-s, .markdownlint.rb]
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ docker-release: docker
@docker push -a $(DOCKER_REPO)

release: pypi docker-release

test:
@poetry run pytest
2 changes: 0 additions & 2 deletions bhagavad_gita_api/SocialBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def __init__(self, verse, translations):
self.create_image_post(text=self.translation_english)

def create_image_post(self, text):

"""
using pillow to add text on an image template, adjusting font
size and line width to avoid overflows
Expand Down Expand Up @@ -113,7 +112,6 @@ def post_on_twitter(self):
return e

def post_on_instagram(self):

# remove cookie if exists, package throws error on expired cookie
if os.path.exists("cookie_iiradhakrishnaii.bot"):
os.remove("cookie_iiradhakrishnaii.bot")
Expand Down
1 change: 0 additions & 1 deletion bhagavad_gita_api/api/api_v2/endpoints/gita.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ async def get_particular_verse_from_chapter(

@router.post("/set-daily-verse/", tags=["verses"])
async def set_daily_verse(db: Session = Depends(deps.get_db)):

verse_order = random.randint(1, 700)

verse = (
Expand Down
1 change: 0 additions & 1 deletion bhagavad_gita_api/api/api_v2/endpoints/social.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ async def post_instagram(db: Session = Depends(deps.get_db)):
)

if verse:

# CALL INSTAGRAM POSTING FUNCTION HERE
translations = db.query(models.GitaTranslation).filter(
models.GitaTranslation.verse_id == verse.id
Expand Down
8 changes: 0 additions & 8 deletions bhagavad_gita_api/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class Meta:
# filtering Pending

def resolve_translations(parent, info, **kwargs):

if parent.id:
verse_id = parent.id
else:
Expand All @@ -64,7 +63,6 @@ def resolve_translations(parent, info, **kwargs):
)[0]

if "limit" in kwargs.keys():

query = (
GitaTranslationModel.get_query(info)
.filter(GitaTranslation.verse_id == verse_id)
Expand Down Expand Up @@ -111,7 +109,6 @@ def resolve_commentaries(parent, info, **kwargs):
)[0]

if "limit" in kwargs.keys():

query = (
GitaCommentryModel.get_query(info)
.filter(GitaCommentary.verse_id == verse_id)
Expand Down Expand Up @@ -146,7 +143,6 @@ def resolve_commentaries(parent, info, **kwargs):


class GitaChapterModel(SQLAlchemyObjectType):

verses = List(
GitaVerseModel,
verse_number=Int(),
Expand All @@ -160,7 +156,6 @@ class Meta:
exclude_fields = ("verses",)

def resolve_verses(parent, info, **kwargs):

if "limit" in kwargs.keys():
query = (
GitaVerseModel.get_query(info)
Expand Down Expand Up @@ -209,15 +204,13 @@ class Query(ObjectType):

@staticmethod
async def resolve_chapters(self, info, **kwargs):

if "chapter_number" in kwargs.keys():
query = GitaChapterModel.get_query(info).filter(
GitaChapter.chapter_number == kwargs.get("chapter_number")
) # SQLAlchemy query
elif "limit" in kwargs.keys():
query = GitaChapterModel.get_query(info).limit(kwargs.get("limit"))
else:

query = GitaChapterModel.get_query(info) # SQLAlchemy query

if "skip" in kwargs.keys():
Expand All @@ -230,7 +223,6 @@ async def resolve_chapters(self, info, **kwargs):

@staticmethod
async def resolve_verses(self, info, **kwargs):

if "verse_number" in kwargs.keys():
query = GitaVerseModel.get_query(info).filter(
GitaVerse.verse_number == kwargs.get("verse_number")
Expand Down
Empty file.
9 changes: 9 additions & 0 deletions bhagavad_gita_api/test/test_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class TestClass:
def test_one(self):
x = "this"
assert "h" in x

# this works too
@staticmethod
def test_three():
pass