Skip to content

Commit

Permalink
Merge branch 'main' into feature/set_labels
Browse files Browse the repository at this point in the history
  • Loading branch information
yazdipour committed Jun 18, 2024
2 parents 88b90ad + 074129d commit e6f741e
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 24 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Unit Tests

on: [push, pull_request]
on: [push]

jobs:
test:
Expand All @@ -18,10 +18,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run unit tests
run: |
cd tests
python -m unittest test_omnivoreql.py
run: python -m unittest discover -s tests
env:
OMNIVORE_API_TOKEN: ${{ secrets.OMNIVORE_API_TOKEN }}
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ username = profile['me']['profile']['username']
slug = articles['search']['edges'][0]['node']['slug']
articles = omnivoreql_client.get_article(username, slug)

labels = omnivoreql_client.get_labels()
subscriptions = omnivoreql_client.get_subscriptions()

labels = omnivoreql_client.get_labels()
from omnivoreql import CreateLabelInput
omnivoreql_client.create_label(CreateLabelInput("label1", "#00ff00", "This is label description"))
```

## Documentation
Expand Down
1 change: 1 addition & 0 deletions omnivoreql/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from .omnivoreql import OmnivoreQL
from .models import CreateLabelInput
3 changes: 0 additions & 3 deletions omnivoreql/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from dataclasses import dataclass
from typing import Optional

from dataclasses import dataclass, field
from typing import Optional

Expand Down
8 changes: 4 additions & 4 deletions omnivoreql/omnivoreql.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from gql import gql, Client
from gql.transport.requests import RequestsHTTPTransport
import uuid
from models import CreateLabelInput
from dataclasses import asdict
import os
from typing import List, Optional
from gql.transport.requests import RequestsHTTPTransport
from gql import gql, Client
from dataclasses import asdict
from .models import CreateLabelInput


class OmnivoreQL:
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from setuptools import setup
from setuptools import setup, find_packages
import subprocess


Expand Down Expand Up @@ -37,7 +37,7 @@ def read_requirements():
description="Omnivore API Client for Python",
author="Shahriar Yazdipour",
author_email="git@yazdipour.com",
packages=["omnivoreql"],
packages=find_packages(),
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
license="MIT",
Expand Down
18 changes: 9 additions & 9 deletions tests/test_omnivoreql.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import unittest
import sys
from dotenv import load_dotenv

# Add the parent directory to the path to import the OmnivoreQL module
current_dir = os.path.dirname(os.path.abspath(__file__))
omnivoreql_dir = os.path.join(current_dir, "..", "omnivoreql")
sys.path.insert(0, omnivoreql_dir)
from omnivoreql import OmnivoreQL, CreateLabelInput


from omnivoreql.omnivoreql import OmnivoreQL
from omnivoreql.models import CreateLabelInput

"""
Unit tests for the OmnivoreQL client.
To run the tests, execute the following command:
python -m unittest discover -s tests
"""
class TestOmnivoreQL(unittest.TestCase):
client = None

Expand All @@ -21,13 +21,13 @@ def setUpClass(cls):
This method initializes the OmnivoreQL client with an API token.
The 'OMNIVORE_API_TOKEN' must be specified either in a '.env' file located in
the same directory as this script or passed directly when executing the test script.
Example command to run tests with an environment variable:
python -m unittest test_omnivoreql.py OMNIVORE_API_TOKEN='your_api_token_here'
Raises:
ValueError: If the 'OMNIVORE_API_TOKEN' is not set.
"""
print("\nStarting OmnivoreQL tests...\n")
api_token = cls.getEnvVariable("OMNIVORE_API_TOKEN")
if api_token is None:
raise ValueError("OMNIVORE_API_TOKEN is not set")
Expand Down

0 comments on commit e6f741e

Please sign in to comment.