Skip to content

Commit

Permalink
Merge pull request #518 from Abdur-rahmaanJ/test/init
Browse files Browse the repository at this point in the history
Test/init
  • Loading branch information
Abdur-rahmaanJ authored Dec 6, 2022
2 parents 2220bb5 + 19f2ee8 commit be1a2bf
Show file tree
Hide file tree
Showing 24 changed files with 550 additions and 935 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@


name: Tests
on:
push:
branches:
- dev
pull_request:
branches:
- dev
paths-ignore:
- 'shopyo/sphinx_src/**'
- '*.md'
- '*.rst'
jobs:
tests:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# - {name: Windows, python: '3.9', os: windows-latest, tox: py39}
# - {name: Mac, python: '3.9', os: macos-latest, tox: py39}
- {name: Linux, python: '3.9', os: ubuntu-latest, tox: py39}
# - {name: '3.8', python: '3.8', os: ubuntu-latest, tox: py38}
# - {name: '3.7', python: '3.7', os: ubuntu-latest, tox: py37}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: update pip
run: |
pip install -U wheel
pip install -U setuptools
python -m pip install -U pip
- name: install requirements
run: |
python -m pip install pytest pytest-coverage coverage
python -m pip install .
- name: get pip cache dir
id: pip-cache
run: echo "::set-output name=dir::$(pip cache dir)"
- name: cache pip
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: pip|${{ runner.os }}|${{ matrix.python }}|${{ hashFiles('setup.py') }}|${{ hashFiles('requirements/*.txt') }}|${{ hashFiles('requirements.txt') }}
- run: pip install tox codecov
- run: tox -e py
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,12 @@ SQLALCHEMY_DATABASE_URI: sqlite:///shopcube.db
![](screenshots/new_screenshots/2.png)
![](screenshots/new_screenshots/3.png)
![](screenshots/new_screenshots/4.png)

# Tests

In venv

```
cd src/shopcube
python -m pytest ./
```
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
long_description = f.read()
setup(
name="shopcube", # Required
version="4.3.2", # Required
version="4.4.0", # Required
description="E-commerce solution", # Optional
long_description=long_description, # Optional
long_description_content_type="text/markdown", # Optional (see note above)
Expand Down
33 changes: 16 additions & 17 deletions src/shopcube/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,27 @@
import os
import sys

import click

# from flask import redirect
from flask import Flask
from flask import send_from_directory
from flask import url_for

import click
from flask_login import current_user
from flask_wtf.csrf import CSRFProtect

sys.path.append(".")

import datetime

import flask
import jinja2
import shopyo
from shopyo.api.file import trycopy

from config import app_config
from init import configure_all_uploads
from init import csrf
from init import db
from init import login_manager
from init import ma
from init import mail
from init import migrate
from init import load_extensions
from init import modules_path
from shopyo.api.file import trycopy

logging.basicConfig(level=logging.DEBUG)

Expand Down Expand Up @@ -82,13 +79,7 @@ def create_app(config_name, configs=None):

# app.logger.info(app.config)

migrate.init_app(app, db)
db.init_app(app)
ma.init_app(app)
login_manager.init_app(app)

mail.init_app(app)
csrf.init_app(app)
load_extensions(app)

configure_all_uploads(app)

Expand Down Expand Up @@ -260,6 +251,14 @@ def flight_info():
)
)

# some stuffs

@app.before_request
def before_request():
flask.session.permanent = True
app.permanent_session_lifetime = datetime.timedelta(minutes=20)
flask.session.modified = True

# end of func
return app

Expand Down
14 changes: 11 additions & 3 deletions src/shopcube/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class Config:

UPLOADED_PRODUCTPHOTOS_DEST = os.path.join(STATIC, "uploads", "products")
UPLOADED_CATEGORYPHOTOS_DEST = os.path.join(STATIC, "uploads", "category")
UPLOADED_SUBCATEGORYPHOTOS_DEST = os.path.join(STATIC, "uploads", "subcategory")
UPLOADED_SUBCATEGORYPHOTOS_DEST = os.path.join(
STATIC, "uploads", "subcategory"
)
UPLOADED_PRODUCTEXCEL_DEST = os.path.join(STATIC, "uploads")
UPLOADED_PRODUCTEXCEL_ALLOW = ("xls", "xlsx", "xlsm", "xlsb", "odf")
PASSWORD_SALT = "abcdefghi"
Expand All @@ -36,7 +38,7 @@ class DevelopmentConfig(Config):
ENV = "development"
DEBUG = True
# EXPLAIN_TEMPLATE_LOADING = True
LOGIN_DISABLED = True
# LOGIN_DISABLED = True
# control email confirmation for user registration
EMAIL_CONFIRMATION_DISABLED = False
# flask-mailman configs
Expand All @@ -46,7 +48,9 @@ class DevelopmentConfig(Config):
MAIL_USE_SSL = False
MAIL_USERNAME = "" # os.environ.get("MAIL_USERNAME")
MAIL_PASSWORD = "" # os.environ.get("MAIL_PASSWORD")
MAIL_DEFAULT_SENDER = "[email protected]" # os.environ.get("MAIL_DEFAULT_SENDER")
MAIL_DEFAULT_SENDER = (
"[email protected]" # os.environ.get("MAIL_DEFAULT_SENDER")
)


class TestingConfig(Config):
Expand All @@ -59,7 +63,11 @@ class TestingConfig(Config):
SERVER_NAME = "localhost.com"
BCRYPT_LOG_ROUNDS = 4
TESTING = True
ENV = "testing"
LOGIN_DISABLED = False
WTF_CSRF_ENABLED = False
PREFERRED_URL_SCHEME = "http"
SECRET_KEY = "abcd"


app_config = {
Expand Down
Loading

0 comments on commit be1a2bf

Please sign in to comment.