GithubHelp home page GithubHelp logo

freelancing-solutions / gcp-database-as-a-service-stock-markets Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 1.0 85.4 MB

GCP NDB database as a service for a stock market investment and social web services.

License: MIT License

Python 99.68% HTML 0.18% Batchfile 0.01% Dockerfile 0.13%
stock market python ndb python38

gcp-database-as-a-service-stock-markets's Introduction

GCP Based Database as a service

The purpose of the project is to make it easy to use datastore database on GCP Platform with several of its cloud platform offerings such as GCP by offering a single end point from which to access data.

Development Time

wakatime

How it Works?

 by creating API endpoints for databases hosted in Google Cloud Platform this service is able to 
 offer endpoints to access, save, and update data to services running in 
 Google Cloud Run and GCP Functions, and in the future can be expanded without affecting the 
 services depending on the databases being managed by this data-service.

What it Handles

Presently the database can handle several services

  • Users
  • Stocks
  • Brokers
  • Stock Exchanges
  • API
    • (Settings Database, & Temp Data )
  • Scrapping
    • (Settings Database, & Temp Data)
  • Affiliates
  • HelpDesk
  • Memberships
  • Stats --
    ####Access to the our service is provided through:
  • PubSub
  • HTTP Endpoints

Catching Policy

The database service will utilize aggressive caching to avoid multiple
database searches for the same content on the datastore.

This will be done in the following manner.
--
1. ***Through catching JSON Responses*** from database queries with Service Workers registered on Cloud Flare.     
    - The data-service is able to purge the cached data through an API call.
    - The Cache will expired through a predetermined time(TTL) if a purge was not triggered.
2. Through Catching Requests for data on the browser through a service worker registered on each client browser.
    - The data stored maybe be purged from the back-end through push messages triggered events.
    - The data stored will expire when a cache TTL expires 
    - Cache TTL for both the CDN and the browser settings will be dynamically calculated by the 
    database service whenever a new request is made.

3. Through Mem Cache on Client Servers Application, so as to avoid searching the database twice for the same info
the client cache will also dynamically determine the Cache TTL, and also the data-service may 
purge the cache through an API Call to the client server. thereby causing the client to fetch fresh data.         

gcp-database-as-a-service-stock-markets's People

Contributors

dependabot[bot] avatar freelancing-solutions avatar neurotictools avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

webclinic017

gcp-database-as-a-service-stock-markets's Issues

add ndb put mock- in order to test more options such as error checking on the da...

add ndb put mock- in order to test more options such as error checking on the database level

https://github.com/freelancing-solutions/GCP-Based-Database-as-a-Service/blob/a7349eccb9b9ef22d0716d46682612df2aba5425/tests/test_store/test_stock.py#L7

stock_instance: Stock = Stock()

# TODO add ndb put mock- in order to test more options such as error checking on the database level
def test_stock_instance():
    assert isinstance(stock_instance, Stock), "Stock not properly initialized"

8ea4bae6420b6456c533eaa362677d75596be80b

Pytest coverage single falls below minimum 80

Name Stmts Miss Cover
data_service/api/init.py 0 0 100%
data_service/api/affiliates/init.py 0 0 100%
data_service/api/affiliates/routes.py 64 64 0%
data_service/api/api_authenticator.py 43 43 0%
data_service/api/coupons/init.py 0 0 100%
data_service/api/coupons/routes.py 27 27 0%
data_service/api/memberships/init.py 0 0 100%
data_service/api/memberships/routes.py 74 74 0%
data_service/api/pubsub/init.py 0 0 100%
data_service/api/pubsub/routes.py 42 42 0%
data_service/api/scrapper/init.py 0 0 100%
data_service/api/scrapper/routes.py 17 17 0%
data_service/api/settings/init.py 0 0 100%
data_service/api/settings/routes.py 84 84 0%
data_service/api/stocks/init.py 0 0 100%
data_service/api/stocks/routes.py 132 132 0%
data_service/api/users/init.py 0 0 100%
data_service/api/users/routes.py 121 121 0%
data_service/config/init.py 15 15 0%
data_service/config/exceptions.py 22 22 0%
data_service/config/stocks.py 6 6 0%
data_service/config/types.py 7 7 0%
data_service/cron/init.py 0 0 100%
data_service/cron/routes.py 17 17 0%
data_service/frontpage/init.py 0 0 100%
data_service/frontpage/routes.py 7 7 0%
data_service/handlers/init.py 0 0 100%
data_service/handlers/routes.py 31 31 0%
data_service/main/init.py 38 38 0%
data_service/store/init.py 0 0 100%
data_service/store/affiliates.py 241 241 0%
data_service/store/helpdesk.py 58 58 0%
data_service/store/memberships.py 199 199 0%
data_service/store/mixins.py 52 52 0%
data_service/store/scrapper.py 34 34 0%
data_service/store/settings.py 153 153 0%
data_service/store/stats.py 38 38 0%
data_service/store/stocks.py 225 225 0%
data_service/store/users.py 101 101 0%
data_service/store/wallet.py 60 60 0%
data_service/tasks_input_handlers/init.py 0 0 100%
data_service/tasks_input_handlers/routers.py 18 18 0%
data_service/utils/init.py 0 0 100%
data_service/utils/utils.py 54 54 0%
data_service/views/init.py 0 0 100%
data_service/views/affiliates.py 260 260 0%
data_service/views/exception_handlers.py 43 43 0%
data_service/views/memberships.py 412 412 0%
data_service/views/scrapper.py 32 32 0%
data_service/views/settings.py 164 164 0%
data_service/views/stocks.py 622 622 0%
data_service/views/use_context.py 10 10 0%
data_service/views/users.py 142 142 0%
data_service/views/wallet.py 86 86 0%
TOTAL 3751 3751 0%
=========================== short test summary
info ============================ ERROR tests/test_store/test_broker.py
ERROR tests/test_store/test_buy_volume.py ERROR tests/test_store/test_sell_volume.py
ERROR tests/test_store/test_stock.py ERROR tests/test_store/test_stock_model.py
ERROR tests/test_store/test_user.py !!!!!!!!!!!!!!!!!!! Interrupted:
6 errors during collection
!!!!!!!!!!!!!!!!!!!!

Add more test cases

Add more test cases

noinspection PyShadowingNames,DuplicatedCode

        affiliates_view_instance = AffiliatesView()
        response, status = affiliates_view_instance.get_affiliate(affiliate_data=affiliate_data_mock)
        assert status == 200, 'unable to locate affiliate'
        # TODO expand the test cases
    mocker.stopall()


# noinspection PyShadowingNames,DuplicatedCode
def test_get_all_affiliate(mocker):
    mocker.patch('google.cloud.ndb.Model.put', return_value=create_id())
    mocker.patch('google.cloud.ndb.Model.query', return_value=AffiliateQueryMock())
    # TODo complete the test cases
    with test_app().app_context():
        pass
    mocker.stopall()

# noinspection PyShadowingNames,DuplicatedCode
def get_active_affiliates(mocker):
    mocker.patch('google.cloud.ndb.Model.put', return_value=create_id())
    mocker.patch('google.cloud.ndb.Model.query', return_value=AffiliateQueryMock())
    # TODO Add more test cases

    with test_app().app_context():
        pass
    mocker.stopall()

# noinspection PyShadowingNames,DuplicatedCode
def get_inactive_affiliates(mocker):
    mocker.patch('google.cloud.ndb.Model.put', return_value=create_id())
    mocker.patch('google.cloud.ndb.Model.query', return_value=AffiliateQueryMock())

2cc0ba235db37f7409cb0f65cfa0b03702df7033

Pytest coverage single falls below minimum 80

Name Stmts Miss Cover
data_service/init.py 0 0 100%
data_service/api/init.py 0 0 100%
data_service/api/affiliates/init.py 0 0 100%
data_service/api/affiliates/routes.py 64 64 0%
data_service/api/api_authenticator.py 43 43 0%
data_service/api/coupons/init.py 0 0 100%
data_service/api/coupons/routes.py 27 27 0%
data_service/api/memberships/init.py 0 0 100%
data_service/api/memberships/routes.py 74 74 0%
data_service/api/pubsub/init.py 0 0 100%
data_service/api/pubsub/routes.py 42 42 0%
data_service/api/scrapper/init.py 0 0 100%
data_service/api/scrapper/routes.py 17 17 0%
data_service/api/settings/init.py 0 0 100%
data_service/api/settings/routes.py 84 84 0%
data_service/api/stocks/init.py 0 0 100%
data_service/api/stocks/routes.py 132 132 0%
data_service/api/users/init.py 0 0 100%
data_service/api/users/routes.py 121 121 0%
data_service/config/init.py 15 15 0%
data_service/config/exceptions.py 22 22 0%
data_service/config/stocks.py 6 6 0%
data_service/config/types.py 7 7 0%
data_service/cron/init.py 0 0 100%
data_service/cron/routes.py 17 17 0%
data_service/frontpage/init.py 0 0 100%
data_service/frontpage/routes.py 7 7 0%
data_service/handlers/init.py 0 0 100%
data_service/handlers/routes.py 31 31 0%
data_service/main/init.py 38 38 0%
data_service/store/init.py 0 0 100%
data_service/store/affiliates.py 241 241 0%
data_service/store/helpdesk.py 58 58 0%
data_service/store/memberships.py 199 199 0%
data_service/store/mixins.py 52 52 0%
data_service/store/scrapper.py 34 34 0%
data_service/store/settings.py 153 153 0%
data_service/store/stats.py 38 38 0%
data_service/store/stocks.py 215 215 0%
data_service/store/users.py 101 101 0%
data_service/store/wallet.py 60 60 0%
data_service/tasks_input_handlers/init.py 0 0 100%
data_service/tasks_input_handlers/routers.py 18 18 0%
data_service/utils/init.py 0 0 100%
data_service/utils/utils.py 54 54 0%
data_service/views/init.py 0 0 100%
data_service/views/affiliates.py 260 260 0%
data_service/views/exception_handlers.py 43 43 0%
data_service/views/memberships.py 412 412 0%
data_service/views/scrapper.py 32 32 0%
data_service/views/settings.py 164 164 0%
data_service/views/stocks.py 622 622 0%
data_service/views/use_context.py 10 10 0%
data_service/views/users.py 142 142 0%
data_service/views/wallet.py 86 86 0%
initial_data/transactions/transaction/utility.py 3 3 0%
run.py 5 5 0%
tests/init.py 8 7 12%
tests/test_api/init.py 0 0 100%
tests/test_store/init.py 0 0 100%
tests/test_store/test_broker.py 39 39 0%
tests/test_store/test_buy_volume.py 92 92 0%
tests/test_store/test_sell_volume.py 50 50 0%
tests/test_store/test_stock.py 59 59 0%
tests/test_store/test_stock_model.py 59 59 0%
tests/test_store/test_user.py 102 102 0%
tests/test_views/init.py 0 0 100%
TOTAL 4158 4157 1%
=========================== short test summary
info ============================ ERROR tests/test_store/test_broker.py
ERROR tests/test_store/test_buy_volume.py ERROR tests/test_store/test_sell_volume.py
ERROR tests/test_store/test_stock.py ERROR tests/test_store/test_stock_model.py
ERROR tests/test_store/test_user.py !!!!!!!!!!!!!!!!!!! Interrupted:
6 errors during collection
!!!!!!!!!!!!!!!!!!!!

Pytest coverage single falls below minimum 80

Name Stmts Miss Cover
data_service/api/init.py 0 0 100%
data_service/api/affiliates/init.py 0 0 100%
data_service/api/affiliates/routes.py 64 64 0%
data_service/api/api_authenticator.py 43 43 0%
data_service/api/coupons/init.py 0 0 100%
data_service/api/coupons/routes.py 27 27 0%
data_service/api/memberships/init.py 0 0 100%
data_service/api/memberships/routes.py 74 74 0%
data_service/api/pubsub/init.py 0 0 100%
data_service/api/pubsub/routes.py 42 42 0%
data_service/api/scrapper/init.py 0 0 100%
data_service/api/scrapper/routes.py 17 17 0%
data_service/api/settings/init.py 0 0 100%
data_service/api/settings/routes.py 84 84 0%
data_service/api/stocks/init.py 0 0 100%
data_service/api/stocks/routes.py 132 132 0%
data_service/api/users/init.py 0 0 100%
data_service/api/users/routes.py 121 121 0%
data_service/config/init.py 15 15 0%
data_service/config/exceptions.py 22 22 0%
data_service/config/stocks.py 6 6 0%
data_service/config/types.py 7 7 0%
data_service/cron/init.py 0 0 100%
data_service/cron/routes.py 17 17 0%
data_service/frontpage/init.py 0 0 100%
data_service/frontpage/routes.py 7 7 0%
data_service/handlers/init.py 0 0 100%
data_service/handlers/routes.py 31 31 0%
data_service/main/init.py 38 38 0%
data_service/store/init.py 0 0 100%
data_service/store/affiliates.py 241 241 0%
data_service/store/helpdesk.py 58 58 0%
data_service/store/memberships.py 199 199 0%
data_service/store/mixins.py 52 52 0%
data_service/store/scrapper.py 34 34 0%
data_service/store/settings.py 153 153 0%
data_service/store/stats.py 38 38 0%
data_service/store/stocks.py 225 225 0%
data_service/store/users.py 101 101 0%
data_service/store/wallet.py 60 60 0%
data_service/tasks_input_handlers/init.py 0 0 100%
data_service/tasks_input_handlers/routers.py 18 18 0%
data_service/utils/init.py 0 0 100%
data_service/utils/utils.py 54 54 0%
data_service/views/init.py 0 0 100%
data_service/views/affiliates.py 260 260 0%
data_service/views/exception_handlers.py 43 43 0%
data_service/views/memberships.py 412 412 0%
data_service/views/scrapper.py 32 32 0%
data_service/views/settings.py 164 164 0%
data_service/views/stocks.py 622 622 0%
data_service/views/use_context.py 10 10 0%
data_service/views/users.py 142 142 0%
data_service/views/wallet.py 86 86 0%
TOTAL 3751 3751 0%
=========================== short test summary
info ============================ ERROR tests/test_store/test_broker.py
ERROR tests/test_store/test_buy_volume.py ERROR tests/test_store/test_sell_volume.py
ERROR tests/test_store/test_stock.py ERROR tests/test_store/test_stock_model.py
ERROR tests/test_store/test_user.py !!!!!!!!!!!!!!!!!!! Interrupted:
6 errors during collection
!!!!!!!!!!!!!!!!!!!!

Create Test Cases for Scrapper and Documentations

Create Test Cases for Scrapper and Documentations

https://github.com/freelancing-solutions/GCP-Based-Database-as-a-Service/blob/8633ab43c631d70f77e849524bed895bea19daf6/data_service/views/scrapper.py#L8

from data_service.views.exception_handlers import handle_view_errors
from data_service.views.use_context import use_context

# TODO Create Test Cases for Scrapper and Documentations
class ScrapperView:

    def __init__(self):

3fecef79665bce79903f767d1b660b32773daa74

use ndb.tasklets to refactor stock input validators

use ndb.tasklets to refactor stock input validators

https://github.com/freelancing-solutions/GCP-Based-Database-as-a-Service/blob/23a879ade9a6a61a01287b47a696f09ae24c1db1/data_service/views/stocks.py#L264

        self._max_retries = current_app.config.get('DATASTORE_RETRIES')
        self._max_timeout = current_app.config.get('DATASTORE_TIMEOUT')

    # TODO use ndb.tasklets to refactor stock input validators
    @staticmethod
    def symbol_exist(symbol: str) -> typing.Union[None, bool]:
        # noinspection DuplicatedCode

0535311adcaafcd8034a069fed5bd8e6c25f88fc

complete validations for all Wallet Models

complete validations for all Wallet Models

https://github.com/freelancing-solutions/GCP-Based-Database-as-a-Service/blob/ac31d7222e383fbe8bfed71c77f093a8d1fbbb2f/data_service/store/wallet.py#L16

        wallet_instance: WalletModel = WalletModel.query(WalletModel.uid == uid).get()
        return True if isinstance(wallet_instance, WalletModel) else False

    # TODO complete validations for all Wallet Models
    # TODO be sure to intergrate all models to the view
class ClassSetters:
    def __init__(self):
        self.transaction_types = ['withdrawal', 'deposit']

62466ff8d8841e3e7a054f38cd5d4a9e0e562b44

Refactor Settings View and Write Test Cases and Documentation

Refactor Settings View and Write Test Cases and Documentation

https://github.com/freelancing-solutions/GCP-Based-Database-as-a-Service/blob/8633ab43c631d70f77e849524bed895bea19daf6/data_service/views/settings.py#L15

scrape_list_type = typing.List[ScrappingPagesModel]
api_list_type = typing.List[StockAPIEndPointModel]

# TODO Refactor Settings View and Write Test Cases and Documentation
class UserSettingsView:
    def __init__(self):
        pass

ca40cdfdfe6e44a770480a76d12b21c8d1b10bd3

complete the intergration of memberships view and the

complete the intergration of memberships view and the

API also refer to admin app

https://github.com/freelancing-solutions/GCP-Based-Database-as-a-Service/blob/ac31d7222e383fbe8bfed71c77f093a8d1fbbb2f/data_service/api/memberships/routes.py#L107

def get_membership_plans() -> tuple:
    member_ship_instance_view: MembershipPlansView = MembershipPlansView()
    return member_ship_instance_view.return_all_plans()

# TODO complete the intergration of memberships view and the
#  API also refer to admin app

42027346ed1a4a3762bde2a2deb90440b86e5280

Create Test Cases for Affiliates View and Documentations

Create Test Cases for Affiliates View and Documentations

https://github.com/freelancing-solutions/GCP-Based-Database-as-a-Service/blob/8633ab43c631d70f77e849524bed895bea19daf6/data_service/views/affiliates.py#L13

from data_service.views.exception_handlers import handle_view_errors
from data_service.views.use_context import use_context

# TODO Create Test Cases for Affiliates View and Documentations

class Validator(ValidAffiliate, ValidRecruit, ValidEarnings):

    @staticmethod

a4fd9d454a22334d7ef9563cdb391cf82ebbc973

Pytest coverage single falls below minimum 10

Name Stmts Miss Cover
data_service/init.py 0 0 100%
data_service/api/init.py 0 0 100%
data_service/api/affiliates/init.py 0 0 100%
data_service/api/affiliates/routes.py 64 64 0%
data_service/api/api_authenticator.py 43 43 0%
data_service/api/coupons/init.py 0 0 100%
data_service/api/coupons/routes.py 27 27 0%
data_service/api/memberships/init.py 0 0 100%
data_service/api/memberships/routes.py 74 74 0%
data_service/api/pubsub/init.py 0 0 100%
data_service/api/pubsub/routes.py 42 42 0%
data_service/api/scrapper/init.py 0 0 100%
data_service/api/scrapper/routes.py 17 17 0%
data_service/api/settings/init.py 0 0 100%
data_service/api/settings/routes.py 84 84 0%
data_service/api/stocks/init.py 0 0 100%
data_service/api/stocks/routes.py 132 132 0%
data_service/api/users/init.py 0 0 100%
data_service/api/users/routes.py 121 121 0%
data_service/config/init.py 15 15 0%
data_service/config/exceptions.py 22 22 0%
data_service/config/stocks.py 6 6 0%
data_service/config/types.py 7 7 0%
data_service/cron/init.py 0 0 100%
data_service/cron/routes.py 17 17 0%
data_service/frontpage/init.py 0 0 100%
data_service/frontpage/routes.py 7 7 0%
data_service/handlers/init.py 0 0 100%
data_service/handlers/routes.py 31 31 0%
data_service/main/init.py 38 38 0%
data_service/store/init.py 0 0 100%
data_service/store/affiliates.py 241 241 0%
data_service/store/helpdesk.py 58 58 0%
data_service/store/memberships.py 199 199 0%
data_service/store/mixins.py 52 52 0%
data_service/store/scrapper.py 34 34 0%
data_service/store/settings.py 153 153 0%
data_service/store/stats.py 38 38 0%
data_service/store/stocks.py 217 217 0%
data_service/store/users.py 101 101 0%
data_service/store/wallet.py 60 60 0%
data_service/tasks_input_handlers/init.py 0 0 100%
data_service/tasks_input_handlers/routers.py 18 18 0%
data_service/utils/init.py 0 0 100%
data_service/utils/utils.py 54 54 0%
data_service/views/init.py 0 0 100%
data_service/views/affiliates.py 260 260 0%
data_service/views/exception_handlers.py 43 43 0%
data_service/views/memberships.py 412 412 0%
data_service/views/scrapper.py 32 32 0%
data_service/views/settings.py 164 164 0%
data_service/views/stocks.py 622 622 0%
data_service/views/use_context.py 10 10 0%
data_service/views/users.py 142 142 0%
data_service/views/wallet.py 86 86 0%
initial_data/transactions/transaction/utility.py 3 3 0%
run.py 5 5 0%
tests/init.py 8 7 12%
tests/test_api/init.py 0 0 100%
tests/test_store/init.py 0 0 100%
tests/test_store/test_broker.py 39 39 0%
tests/test_store/test_buy_volume.py 92 92 0%
tests/test_store/test_sell_volume.py 60 60 0%
tests/test_store/test_stock.py 59 59 0%
tests/test_store/test_stock_model.py 59 59 0%
tests/test_store/test_user.py 102 102 0%
tests/test_views/init.py 0 0 100%
TOTAL 4170 4169 1%
=========================== short test summary
info ============================ ERROR tests/test_store/test_broker.py
ERROR tests/test_store/test_buy_volume.py ERROR tests/test_store/test_sell_volume.py
ERROR tests/test_store/test_stock.py ERROR tests/test_store/test_stock_model.py
ERROR tests/test_store/test_user.py !!!!!!!!!!!!!!!!!!! Interrupted:
6 errors during collection
!!!!!!!!!!!!!!!!!!!!

create a decent front page with

create a decent front page with

API Documentation and a github link to support further development

https://github.com/freelancing-solutions/GCP-Based-Database-as-a-Service/blob/ac31d7222e383fbe8bfed71c77f093a8d1fbbb2f/data_service/frontpage/routes.py#L12

home_bp = Blueprint('home', __name__, template_folder='templates', static_folder='static')


@home_bp.route('/', methods=["GET"])
@cache_stocks.cached(timeout=default_timeout)
def home():
    return render_template('index.html')

# TODO create a decent front page with
# API Documentation and a github link to support further development

043f2fff480387b71faf33bfb17b539fb629189d

expand the test cases

expand the test cases

noinspection PyShadowingNames,DuplicatedCode

        affiliates_view_instance = AffiliatesView()
        response, status = affiliates_view_instance.get_affiliate(affiliate_data=affiliate_data_mock)
        assert status == 200, 'unable to locate affiliate'
        # TODO expand the test cases
    mocker.stopall()


# noinspection PyShadowingNames,DuplicatedCode
def test_get_all_affiliate(mocker):
    mocker.patch('google.cloud.ndb.Model.put', return_value=create_id())
    mocker.patch('google.cloud.ndb.Model.query', return_value=AffiliateQueryMock())
    # TODo complete the test cases
    with test_app().app_context():
        pass
    mocker.stopall()

# noinspection PyShadowingNames,DuplicatedCode
def get_active_affiliates(mocker):
    mocker.patch('google.cloud.ndb.Model.put', return_value=create_id())
    mocker.patch('google.cloud.ndb.Model.query', return_value=AffiliateQueryMock())
    # TODO Add more test cases

    with test_app().app_context():
        pass
    mocker.stopall()

# noinspection PyShadowingNames,DuplicatedCode
def get_inactive_affiliates(mocker):
    mocker.patch('google.cloud.ndb.Model.put', return_value=create_id())
    mocker.patch('google.cloud.ndb.Model.query', return_value=AffiliateQueryMock())

76bf4e4b5b75be001537f9c5c3d5411db0b8e925

Pytest coverage single falls below minimum 80

Name Stmts Miss Cover
data_service/init.py 0 0 100%
data_service/api/init.py 0 0 100%
data_service/api/affiliates/init.py 0 0 100%
data_service/api/affiliates/routes.py 64 64 0%
data_service/api/api_authenticator.py 43 43 0%
data_service/api/coupons/init.py 0 0 100%
data_service/api/coupons/routes.py 27 27 0%
data_service/api/memberships/init.py 0 0 100%
data_service/api/memberships/routes.py 74 74 0%
data_service/api/pubsub/init.py 0 0 100%
data_service/api/pubsub/routes.py 42 42 0%
data_service/api/scrapper/init.py 0 0 100%
data_service/api/scrapper/routes.py 17 17 0%
data_service/api/settings/init.py 0 0 100%
data_service/api/settings/routes.py 84 84 0%
data_service/api/stocks/init.py 0 0 100%
data_service/api/stocks/routes.py 132 132 0%
data_service/api/users/init.py 0 0 100%
data_service/api/users/routes.py 121 121 0%
data_service/config/init.py 15 15 0%
data_service/config/exceptions.py 22 22 0%
data_service/config/stocks.py 6 6 0%
data_service/config/types.py 7 7 0%
data_service/cron/init.py 0 0 100%
data_service/cron/routes.py 17 17 0%
data_service/frontpage/init.py 0 0 100%
data_service/frontpage/routes.py 7 7 0%
data_service/handlers/init.py 0 0 100%
data_service/handlers/routes.py 31 31 0%
data_service/main/init.py 38 38 0%
data_service/store/init.py 0 0 100%
data_service/store/affiliates.py 241 241 0%
data_service/store/helpdesk.py 58 58 0%
data_service/store/memberships.py 199 199 0%
data_service/store/mixins.py 52 52 0%
data_service/store/scrapper.py 34 34 0%
data_service/store/settings.py 153 153 0%
data_service/store/stats.py 38 38 0%
data_service/store/stocks.py 225 225 0%
data_service/store/users.py 101 101 0%
data_service/store/wallet.py 60 60 0%
data_service/tasks_input_handlers/init.py 0 0 100%
data_service/tasks_input_handlers/routers.py 18 18 0%
data_service/utils/init.py 0 0 100%
data_service/utils/utils.py 54 54 0%
data_service/views/init.py 0 0 100%
data_service/views/affiliates.py 260 260 0%
data_service/views/exception_handlers.py 43 43 0%
data_service/views/memberships.py 412 412 0%
data_service/views/scrapper.py 32 32 0%
data_service/views/settings.py 164 164 0%
data_service/views/stocks.py 622 622 0%
data_service/views/use_context.py 10 10 0%
data_service/views/users.py 142 142 0%
data_service/views/wallet.py 86 86 0%
run.py 5 5 0%
TOTAL 3756 3756 0%
=========================== short test summary
info ============================ ERROR tests/test_store/test_broker.py
ERROR tests/test_store/test_buy_volume.py ERROR tests/test_store/test_sell_volume.py
ERROR tests/test_store/test_stock.py ERROR tests/test_store/test_stock_model.py
ERROR tests/test_store/test_user.py !!!!!!!!!!!!!!!!!!! Interrupted:
6 errors during collection
!!!!!!!!!!!!!!!!!!!!

find a way to better check for Cell Number

find a way to better check for Cell Number

a regex can work best here

# TODO find a way to better check for Cell Number

        return True

    def set_cell(self, cell: str) -> bool:
        # TODO find a way to better check for Cell Number
        #  a regex can work best here
        if cell is None or cell == "":
            raise ValueError('cell cannot be Null')
        if not isinstance(cell, str):
            raise TypeError('cell can only be a string')

5b202efed9490efbd21a26febfbdaacec193fac1

[typing] Add a protocol for mark_rewrite() and use it

Add a protocol for mark_rewrite() and use it

for importhook and for PytestPluginManager.rewrite_hook.

so for example not in the master process of pytest-xdist

(which does not collect test modules).

# TODO(typing): Add a protocol for mark_rewrite() and use it

"""Support for presenting detailed information in failing assertions."""
import sys
from typing import Any
from typing import Generator
from typing import List
from typing import Optional
from typing import TYPE_CHECKING

from _pytest.assertion import rewrite
from _pytest.assertion import truncate
from _pytest.assertion import util
from _pytest.assertion.rewrite import assertstate_key
from _pytest.config import Config
from _pytest.config import hookimpl
from _pytest.config.argparsing import Parser
from _pytest.nodes import Item

if TYPE_CHECKING:
    from _pytest.main import Session


def pytest_addoption(parser: Parser) -> None:
    group = parser.getgroup("debugconfig")
    group.addoption(
        "--assert",
        action="store",
        dest="assertmode",
        choices=("rewrite", "plain"),
        default="rewrite",
        metavar="MODE",
        help=(
            "Control assertion debugging tools.\n"
            "'plain' performs no assertion debugging.\n"
            "'rewrite' (the default) rewrites assert statements in test modules"
            " on import to provide assert expression information."
        ),
    )
    parser.addini(
        "enable_assertion_pass_hook",
        type="bool",
        default=False,
        help="Enables the pytest_assertion_pass hook."
        "Make sure to delete any previously generated pyc cache files.",
    )


def register_assert_rewrite(*names: str) -> None:
    """Register one or more module names to be rewritten on import.

    This function will make sure that this module or all modules inside
    the package will get their assert statements rewritten.
    Thus you should make sure to call this before the module is
    actually imported, usually in your __init__.py if you are a plugin
    using a package.

    :raises TypeError: If the given module names are not strings.
    """
    for name in names:
        if not isinstance(name, str):
            msg = "expected module names as *args, got {0} instead"  # type: ignore[unreachable]
            raise TypeError(msg.format(repr(names)))
    for hook in sys.meta_path:
        if isinstance(hook, rewrite.AssertionRewritingHook):
            importhook = hook
            break
    else:
        # TODO(typing): Add a protocol for mark_rewrite() and use it
        # for importhook and for PytestPluginManager.rewrite_hook.
        importhook = DummyRewriteHook()  # type: ignore
    importhook.mark_rewrite(*names)


class DummyRewriteHook:
    """A no-op import hook for when rewriting is disabled."""

    def mark_rewrite(self, *names: str) -> None:
        pass


class AssertionState:
    """State for the assertion plugin."""

    def __init__(self, config: Config, mode) -> None:
        self.mode = mode
        self.trace = config.trace.root.get("assertion")
        self.hook: Optional[rewrite.AssertionRewritingHook] = None


def install_importhook(config: Config) -> rewrite.AssertionRewritingHook:
    """Try to install the rewrite hook, raise SystemError if it fails."""
    config._store[assertstate_key] = AssertionState(config, "rewrite")
    config._store[assertstate_key].hook = hook = rewrite.AssertionRewritingHook(config)
    sys.meta_path.insert(0, hook)
    config._store[assertstate_key].trace("installed rewrite import hook")

    def undo() -> None:
        hook = config._store[assertstate_key].hook
        if hook is not None and hook in sys.meta_path:
            sys.meta_path.remove(hook)

    config.add_cleanup(undo)
    return hook


def pytest_collection(session: "Session") -> None:
    # This hook is only called when test modules are collected
    # so for example not in the master process of pytest-xdist
    # (which does not collect test modules).
    assertstate = session.config._store.get(assertstate_key, None)
    if assertstate:
        if assertstate.hook is not None:
            assertstate.hook.set_session(session)


@hookimpl(tryfirst=True, hookwrapper=True)
def pytest_runtest_protocol(item: Item) -> Generator[None, None, None]:
    """Setup the pytest_assertrepr_compare and pytest_assertion_pass hooks.

    The rewrite module will use util._reprcompare if it exists to use custom
    reporting via the pytest_assertrepr_compare hook.  This sets up this custom
    comparison for the test.
    """

    ihook = item.ihook

    def callbinrepr(op, left: object, right: object) -> Optional[str]:
        """Call the pytest_assertrepr_compare hook and prepare the result.

        This uses the first result from the hook and then ensures the
        following:
        * Overly verbose explanations are truncated unless configured otherwise
          (eg. if running in verbose mode).
        * Embedded newlines are escaped to help util.format_explanation()
          later.
        * If the rewrite mode is used embedded %-characters are replaced
          to protect later % formatting.

        The result can be formatted by util.format_explanation() for
        pretty printing.
        """
        hook_result = ihook.pytest_assertrepr_compare(
            config=item.config, op=op, left=left, right=right
        )
        for new_expl in hook_result:
            if new_expl:
                new_expl = truncate.truncate_if_required(new_expl, item)
                new_expl = [line.replace("\n", "\\n") for line in new_expl]
                res = "\n~".join(new_expl)
                if item.config.getvalue("assertmode") == "rewrite":
                    res = res.replace("%", "%%")
                return res
        return None

    saved_assert_hooks = util._reprcompare, util._assertion_pass
    util._reprcompare = callbinrepr

    if ihook.pytest_assertion_pass.get_hookimpls():

        def call_assertion_pass_hook(lineno: int, orig: str, expl: str) -> None:
            ihook.pytest_assertion_pass(item=item, lineno=lineno, orig=orig, expl=expl)

        util._assertion_pass = call_assertion_pass_hook

    yield

    util._reprcompare, util._assertion_pass = saved_assert_hooks


def pytest_sessionfinish(session: "Session") -> None:
    assertstate = session.config._store.get(assertstate_key, None)
    if assertstate:
        if assertstate.hook is not None:
            assertstate.hook.set_session(None)


def pytest_assertrepr_compare(
    config: Config, op: str, left: Any, right: Any
) -> Optional[List[str]]:
    return util.assertrepr_compare(config=config, op=op, left=left, right=right)

bc7a9431512878abae0e6f75a4211fe19276ccc5

Start Cron Jobs

Cron Jobs Devlopment should be started for the following purposes

  1. insuring scrapping services runs at certain intervals
  2. Insuring that API will be launched to obtain extra data if needed

be sure to intergrate all models to the view

be sure to intergrate all models to the view

https://github.com/freelancing-solutions/GCP-Based-Database-as-a-Service/blob/ac31d7222e383fbe8bfed71c77f093a8d1fbbb2f/data_service/store/wallet.py#L17

        wallet_instance: WalletModel = WalletModel.query(WalletModel.uid == uid).get()
        return True if isinstance(wallet_instance, WalletModel) else False

    # TODO complete validations for all Wallet Models
    # TODO be sure to intergrate all models to the view
class ClassSetters:
    def __init__(self):
        self.transaction_types = ['withdrawal', 'deposit']

04aab543e3754f211841870ded69e2707d067126

Pytest coverage single falls below minimum 10

Name Stmts Miss Cover
data_service/init.py 0 0 100%
data_service/api/init.py 0 0 100%
data_service/api/affiliates/init.py 0 0 100%
data_service/api/affiliates/routes.py 64 64 0%
data_service/api/api_authenticator.py 43 43 0%
data_service/api/coupons/init.py 0 0 100%
data_service/api/coupons/routes.py 27 27 0%
data_service/api/memberships/init.py 0 0 100%
data_service/api/memberships/routes.py 74 74 0%
data_service/api/pubsub/init.py 0 0 100%
data_service/api/pubsub/routes.py 42 42 0%
data_service/api/scrapper/init.py 0 0 100%
data_service/api/scrapper/routes.py 17 17 0%
data_service/api/settings/init.py 0 0 100%
data_service/api/settings/routes.py 84 84 0%
data_service/api/stocks/init.py 0 0 100%
data_service/api/stocks/routes.py 132 132 0%
data_service/api/users/init.py 0 0 100%
data_service/api/users/routes.py 121 121 0%
data_service/config/init.py 15 15 0%
data_service/config/exceptions.py 22 22 0%
data_service/config/stocks.py 6 6 0%
data_service/config/types.py 7 7 0%
data_service/cron/init.py 0 0 100%
data_service/cron/routes.py 17 17 0%
data_service/frontpage/init.py 0 0 100%
data_service/frontpage/routes.py 7 7 0%
data_service/handlers/init.py 0 0 100%
data_service/handlers/routes.py 31 31 0%
data_service/main/init.py 38 38 0%
data_service/store/init.py 0 0 100%
data_service/store/affiliates.py 241 241 0%
data_service/store/helpdesk.py 58 58 0%
data_service/store/memberships.py 199 199 0%
data_service/store/mixins.py 52 52 0%
data_service/store/scrapper.py 34 34 0%
data_service/store/settings.py 153 153 0%
data_service/store/stats.py 38 38 0%
data_service/store/stocks.py 215 215 0%
data_service/store/users.py 101 101 0%
data_service/store/wallet.py 60 60 0%
data_service/tasks_input_handlers/init.py 0 0 100%
data_service/tasks_input_handlers/routers.py 18 18 0%
data_service/utils/init.py 0 0 100%
data_service/utils/utils.py 54 54 0%
data_service/views/init.py 0 0 100%
data_service/views/affiliates.py 260 260 0%
data_service/views/exception_handlers.py 43 43 0%
data_service/views/memberships.py 412 412 0%
data_service/views/scrapper.py 32 32 0%
data_service/views/settings.py 164 164 0%
data_service/views/stocks.py 622 622 0%
data_service/views/use_context.py 10 10 0%
data_service/views/users.py 142 142 0%
data_service/views/wallet.py 86 86 0%
initial_data/transactions/transaction/utility.py 3 3 0%
run.py 5 5 0%
tests/init.py 8 7 12%
tests/test_api/init.py 0 0 100%
tests/test_store/init.py 0 0 100%
tests/test_store/test_broker.py 39 39 0%
tests/test_store/test_buy_volume.py 92 92 0%
tests/test_store/test_sell_volume.py 50 50 0%
tests/test_store/test_stock.py 59 59 0%
tests/test_store/test_stock_model.py 59 59 0%
tests/test_store/test_user.py 102 102 0%
tests/test_views/init.py 0 0 100%
TOTAL 4158 4157 1%
=========================== short test summary
info ============================ ERROR tests/test_store/test_broker.py
ERROR tests/test_store/test_buy_volume.py ERROR tests/test_store/test_sell_volume.py
ERROR tests/test_store/test_stock.py ERROR tests/test_store/test_stock_model.py
ERROR tests/test_store/test_user.py !!!!!!!!!!!!!!!!!!! Interrupted:
6 errors during collection
!!!!!!!!!!!!!!!!!!!!

Pytest coverage single falls below minimum 80

Name Stmts Miss Cover
tests/init.py 30 29 3%
tests/test_api/init.py 0 0 100%
tests/test_store/init.py 0 0 100%
tests/test_store/test_broker.py 40 40 0%
tests/test_store/test_buy_volume.py 104 104 0%
tests/test_store/test_sell_volume.py 120 120 0%
tests/test_store/test_stock.py 59 59 0%
tests/test_store/test_stock_model.py 59 59 0%
tests/test_store/test_user.py 102 102 0%
tests/test_views/init.py 0 0 100%
TOTAL 514 513 1%
=========================== short test summary
info ============================ ERROR tests/test_store/test_broker.py
ERROR tests/test_store/test_buy_volume.py ERROR tests/test_store/test_sell_volume.py
ERROR tests/test_store/test_stock.py ERROR tests/test_store/test_stock_model.py
ERROR tests/test_store/test_user.py !!!!!!!!!!!!!!!!!!! Interrupted:
6 errors during collection
!!!!!!!!!!!!!!!!!!!!

find out why it seems i can set values of None even if i am checking against

find out why it seems i can set values of None even if i am checking against

# TODO find out why it seems i can set values of None even if i am checking against

    """
        daily buy volumes
    """
    # TODO find out why it seems i can set values of None even if i am checking against
    def set_stock_id(self, value: str) -> str:
        if (value is None) or (value == ""):
            raise ValueError('{} cannot be Null'.format(self))
        if not isinstance(value, str):
            raise TypeError("{} can only be a string".format(self))

        return value.strip()

    def set_date(self, value: datetime.date) -> datetime.date:
        if isinstance(value, datetime.date):

f1a9be5416e71dc024b7d5a4083106869dbbd74e

Create Test Cases for Stock View and Documentations

Create Test Cases for Stock View and Documentations

https://github.com/freelancing-solutions/GCP-Based-Database-as-a-Service/blob/8633ab43c631d70f77e849524bed895bea19daf6/data_service/views/stocks.py#L18

stock_list_type = typing.List[Stock]

# TODO Create Test Cases for Stock View and Documentations
class StockDataWrappers:
    """
        # NOTES: request wrappers for stock, broker, buy_volume sell_volume, and net_volume

487ae6b15aef8f25c56f52f0a1df1e40b605893a

- Verify that the tasklets return correct results

  • Verify that the tasklets return correct results

https://github.com/freelancing-solutions/GCP-Based-Database-as-a-Service/blob/13fb36c86370469141c89b87bedcb5f7811a4b95/data_service/views/stocks.py#L455

    @use_context
    @handle_view_errors
    def create_stock_model(self, exchange_id: str, sid: str, stock_id: str, broker_id: str) -> tuple:
        # TODO -  use tasklets to fetch both stock and broker at the same time
        # TODO - Verify that the tasklets return correct results
        stock = yield self.fetch_stock(stock_id=stock_id)
        broker = yield self.fetch_broker(broker_id=broker_id)

        stock_model_instance: StockModel = StockModel(exchange_id=exchange_id,
                                                      sid=sid, stock=stock, broker=broker)

f84d1047919e8ba55b906c4e0e867199f97ed3e2

add mocks for ndb.put calls

add mocks for ndb.put calls

from data_service.store.stocks import StockModel
from data_service.store.stocks import Stock, Broker
from data_service.utils.utils import create_id

stock_model_instance: StockModel = StockModel()
stock_instance: Stock = Stock()
broker_instance: Broker = Broker()
# TODO add mocks for ndb.put calls
def test_stock_model_instance():
    assert isinstance(stock_model_instance, StockModel), "stock model instance not instatiating correctly"
    assert isinstance(stock_instance, Stock), "Stock not instantiating correctly"
    assert isinstance(broker_instance, Broker), "Broker not instanting correctly"

def test_exchanged_id():
    assert stock_model_instance.exchange_id is None, "Exchange ID Initial value invalid"
    e_id: str = create_id()
    stock_model_instance.exchange_id = e_id
    assert stock_model_instance.exchange_id == e_id, "exchange id not being set correctly"


def test_transaction_id():
    assert stock_model_instance.transaction_id is None, "transaction id initial value invalid"
    t_id: str = create_id()
    stock_model_instance.transaction_id = t_id
    assert stock_model_instance.transaction_id == t_id, "transaction id not being set correctly"

def test_stock_instance():
    assert stock_model_instance.stock is None, "stock model instance initial instance incorrect"
    stock_model_instance.stock = stock_instance
    assert isinstance(stock_model_instance.stock, Stock), "Stock model not setting stock correctly"

def test_broker_instance():
    assert stock_model_instance.broker is None, "Broker model instance initial value invalid"
    stock_model_instance.broker = broker_instance
    assert isinstance(stock_model_instance.broker, Broker), "Broker Model instance not being set correctly"

68add05bda94d0e78132eb76ebc9d439eff93781

add more tests here to confirm user_model_instance

add more tests here to confirm user_model_instance

# TODO add more tests here to confirm user_model_instance

        test if user model can instantiate correctly
    """
    assert isinstance(user_model_instance, UserModel), "user model not correctly instatiating"
    # TODO add more tests here to confirm user_model_instance

def test_user_uid():
    """

f74fa8676ce0366e64048575ca51b3bd7c7b96e3

Pytest coverage single falls below minimum 80

Name Stmts Miss Cover
data_service/api/init.py 0 0 100%
data_service/api/affiliates/init.py 0 0 100%
data_service/api/affiliates/routes.py 64 64 0%
data_service/api/api_authenticator.py 43 43 0%
data_service/api/coupons/init.py 0 0 100%
data_service/api/coupons/routes.py 27 27 0%
data_service/api/memberships/init.py 0 0 100%
data_service/api/memberships/routes.py 74 74 0%
data_service/api/pubsub/init.py 0 0 100%
data_service/api/pubsub/routes.py 42 42 0%
data_service/api/scrapper/init.py 0 0 100%
data_service/api/scrapper/routes.py 17 17 0%
data_service/api/settings/init.py 0 0 100%
data_service/api/settings/routes.py 84 84 0%
data_service/api/stocks/init.py 0 0 100%
data_service/api/stocks/routes.py 132 132 0%
data_service/api/users/init.py 0 0 100%
data_service/api/users/routes.py 121 121 0%
data_service/config/init.py 15 15 0%
data_service/config/exceptions.py 22 22 0%
data_service/config/stocks.py 6 6 0%
data_service/config/types.py 7 7 0%
data_service/cron/init.py 0 0 100%
data_service/cron/routes.py 17 17 0%
data_service/frontpage/init.py 0 0 100%
data_service/frontpage/routes.py 7 7 0%
data_service/handlers/init.py 0 0 100%
data_service/handlers/routes.py 31 31 0%
data_service/main/init.py 38 38 0%
data_service/store/init.py 0 0 100%
data_service/store/affiliates.py 241 241 0%
data_service/store/helpdesk.py 58 58 0%
data_service/store/memberships.py 199 199 0%
data_service/store/mixins.py 52 52 0%
data_service/store/scrapper.py 34 34 0%
data_service/store/settings.py 153 153 0%
data_service/store/stats.py 38 38 0%
data_service/store/stocks.py 225 225 0%
data_service/store/users.py 101 101 0%
data_service/store/wallet.py 60 60 0%
data_service/tasks_input_handlers/init.py 0 0 100%
data_service/tasks_input_handlers/routers.py 18 18 0%
data_service/utils/init.py 0 0 100%
data_service/utils/utils.py 54 54 0%
data_service/views/init.py 0 0 100%
data_service/views/affiliates.py 260 260 0%
data_service/views/exception_handlers.py 43 43 0%
data_service/views/memberships.py 412 412 0%
data_service/views/scrapper.py 32 32 0%
data_service/views/settings.py 164 164 0%
data_service/views/stocks.py 622 622 0%
data_service/views/use_context.py 10 10 0%
data_service/views/users.py 142 142 0%
data_service/views/wallet.py 86 86 0%
TOTAL 3751 3751 0%
=========================== short test summary
info ============================ ERROR tests/test_store/test_broker.py
ERROR tests/test_store/test_buy_volume.py ERROR tests/test_store/test_sell_volume.py
ERROR tests/test_store/test_stock.py ERROR tests/test_store/test_stock_model.py
ERROR tests/test_store/test_user.py !!!!!!!!!!!!!!!!!!! Interrupted:
6 errors during collection
!!!!!!!!!!!!!!!!!!!!

Pytest coverage single falls below minimum 10

Name Stmts Miss Cover
data_service/init.py 0 0 100%
data_service/api/init.py 0 0 100%
data_service/api/affiliates/init.py 0 0 100%
data_service/api/affiliates/routes.py 64 64 0%
data_service/api/api_authenticator.py 43 43 0%
data_service/api/coupons/init.py 0 0 100%
data_service/api/coupons/routes.py 27 27 0%
data_service/api/memberships/init.py 0 0 100%
data_service/api/memberships/routes.py 74 74 0%
data_service/api/pubsub/init.py 0 0 100%
data_service/api/pubsub/routes.py 42 42 0%
data_service/api/scrapper/init.py 0 0 100%
data_service/api/scrapper/routes.py 17 17 0%
data_service/api/settings/init.py 0 0 100%
data_service/api/settings/routes.py 84 84 0%
data_service/api/stocks/init.py 0 0 100%
data_service/api/stocks/routes.py 132 132 0%
data_service/api/users/init.py 0 0 100%
data_service/api/users/routes.py 121 121 0%
data_service/config/init.py 15 15 0%
data_service/config/exceptions.py 22 22 0%
data_service/config/stocks.py 6 6 0%
data_service/config/types.py 7 7 0%
data_service/cron/init.py 0 0 100%
data_service/cron/routes.py 17 17 0%
data_service/frontpage/init.py 0 0 100%
data_service/frontpage/routes.py 7 7 0%
data_service/handlers/init.py 0 0 100%
data_service/handlers/routes.py 31 31 0%
data_service/main/init.py 38 38 0%
data_service/store/init.py 0 0 100%
data_service/store/affiliates.py 241 241 0%
data_service/store/helpdesk.py 58 58 0%
data_service/store/memberships.py 199 199 0%
data_service/store/mixins.py 52 52 0%
data_service/store/scrapper.py 34 34 0%
data_service/store/settings.py 153 153 0%
data_service/store/stats.py 38 38 0%
data_service/store/stocks.py 215 215 0%
data_service/store/users.py 101 101 0%
data_service/store/wallet.py 60 60 0%
data_service/tasks_input_handlers/init.py 0 0 100%
data_service/tasks_input_handlers/routers.py 18 18 0%
data_service/utils/init.py 0 0 100%
data_service/utils/utils.py 54 54 0%
data_service/views/init.py 0 0 100%
data_service/views/affiliates.py 260 260 0%
data_service/views/exception_handlers.py 43 43 0%
data_service/views/memberships.py 412 412 0%
data_service/views/scrapper.py 32 32 0%
data_service/views/settings.py 164 164 0%
data_service/views/stocks.py 622 622 0%
data_service/views/use_context.py 10 10 0%
data_service/views/users.py 142 142 0%
data_service/views/wallet.py 86 86 0%
initial_data/transactions/transaction/utility.py 3 3 0%
run.py 5 5 0%
tests/init.py 8 7 12%
tests/test_api/init.py 0 0 100%
tests/test_store/init.py 0 0 100%
tests/test_store/test_broker.py 39 39 0%
tests/test_store/test_buy_volume.py 92 92 0%
tests/test_store/test_sell_volume.py 50 50 0%
tests/test_store/test_stock.py 59 59 0%
tests/test_store/test_stock_model.py 59 59 0%
tests/test_store/test_user.py 102 102 0%
tests/test_views/init.py 0 0 100%
TOTAL 4158 4157 1%
=========================== short test summary
info ============================ ERROR tests/test_store/test_broker.py
ERROR tests/test_store/test_buy_volume.py ERROR tests/test_store/test_sell_volume.py
ERROR tests/test_store/test_stock.py ERROR tests/test_store/test_stock_model.py
ERROR tests/test_store/test_user.py !!!!!!!!!!!!!!!!!!! Interrupted:
6 errors during collection
!!!!!!!!!!!!!!!!!!!!

Pytest coverage single falls below minimum 80

Name Stmts Miss Cover
data_service/init.py 0 0 100%
data_service/api/init.py 0 0 100%
data_service/api/affiliates/init.py 0 0 100%
data_service/api/affiliates/routes.py 64 64 0%
data_service/api/api_authenticator.py 43 43 0%
data_service/api/coupons/init.py 0 0 100%
data_service/api/coupons/routes.py 27 27 0%
data_service/api/memberships/init.py 0 0 100%
data_service/api/memberships/routes.py 74 74 0%
data_service/api/pubsub/init.py 0 0 100%
data_service/api/pubsub/routes.py 42 42 0%
data_service/api/scrapper/init.py 0 0 100%
data_service/api/scrapper/routes.py 17 17 0%
data_service/api/settings/init.py 0 0 100%
data_service/api/settings/routes.py 84 84 0%
data_service/api/stocks/init.py 0 0 100%
data_service/api/stocks/routes.py 132 132 0%
data_service/api/users/init.py 0 0 100%
data_service/api/users/routes.py 121 121 0%
data_service/config/init.py 15 15 0%
data_service/config/exceptions.py 22 22 0%
data_service/config/stocks.py 6 6 0%
data_service/config/types.py 7 7 0%
data_service/cron/init.py 0 0 100%
data_service/cron/routes.py 17 17 0%
data_service/frontpage/init.py 0 0 100%
data_service/frontpage/routes.py 7 7 0%
data_service/handlers/init.py 0 0 100%
data_service/handlers/routes.py 31 31 0%
data_service/main/init.py 38 38 0%
data_service/store/init.py 0 0 100%
data_service/store/affiliates.py 241 241 0%
data_service/store/helpdesk.py 58 58 0%
data_service/store/memberships.py 199 199 0%
data_service/store/mixins.py 52 52 0%
data_service/store/scrapper.py 34 34 0%
data_service/store/settings.py 153 153 0%
data_service/store/stats.py 38 38 0%
data_service/store/stocks.py 217 217 0%
data_service/store/users.py 101 101 0%
data_service/store/wallet.py 60 60 0%
data_service/tasks_input_handlers/init.py 0 0 100%
data_service/tasks_input_handlers/routers.py 18 18 0%
data_service/utils/init.py 0 0 100%
data_service/utils/utils.py 54 54 0%
data_service/views/init.py 0 0 100%
data_service/views/affiliates.py 260 260 0%
data_service/views/exception_handlers.py 43 43 0%
data_service/views/memberships.py 412 412 0%
data_service/views/scrapper.py 32 32 0%
data_service/views/settings.py 164 164 0%
data_service/views/stocks.py 622 622 0%
data_service/views/use_context.py 10 10 0%
data_service/views/users.py 142 142 0%
data_service/views/wallet.py 86 86 0%
run.py 5 5 0%
TOTAL 3748 3748 0%
=========================== short test summary
info ============================ ERROR tests/test_store/test_broker.py
ERROR tests/test_store/test_buy_volume.py ERROR tests/test_store/test_sell_volume.py
ERROR tests/test_store/test_stock.py ERROR tests/test_store/test_stock_model.py
ERROR tests/test_store/test_user.py !!!!!!!!!!!!!!!!!!! Interrupted:
6 errors during collection
!!!!!!!!!!!!!!!!!!!!

Refactor the entire codebase to use this function to obtain todays date

Refactor the entire codebase to use this function to obtain todays date

# TODO Refactor the entire codebase to use this function to obtain todays date

        return cache_ttl_medium
    return cache_ttl_short

# TODO Refactor the entire codebase to use this function to obtain todays date
def today() -> date:
    return datetime.now().date()

def time_now() -> time_class:
    return datetime.now().time()

a1492f81769b1403d4dbb034daabb24e7e45f96a

- use tasklets to fetch both stock and broker at the same time

  • use tasklets to fetch both stock and broker at the same time

https://github.com/freelancing-solutions/GCP-Based-Database-as-a-Service/blob/13fb36c86370469141c89b87bedcb5f7811a4b95/data_service/views/stocks.py#L454

    @use_context
    @handle_view_errors
    def create_stock_model(self, exchange_id: str, sid: str, stock_id: str, broker_id: str) -> tuple:
        # TODO -  use tasklets to fetch both stock and broker at the same time
        # TODO - Verify that the tasklets return correct results
        stock = yield self.fetch_stock(stock_id=stock_id)
        broker = yield self.fetch_broker(broker_id=broker_id)

        stock_model_instance: StockModel = StockModel(exchange_id=exchange_id,
                                                      sid=sid, stock=stock, broker=broker)

ef8147a62f8fd6d7e5b5245386b97bbc5ebdba62

Refactor with ndb.Tasklets in order to get input validity check resolutions fast...

Refactor with ndb.Tasklets in order to get input validity check resolutions faster

https://github.com/freelancing-solutions/GCP-Based-Database-as-a-Service/blob/23a879ade9a6a61a01287b47a696f09ae24c1db1/data_service/views/stocks.py#L377

        except Aborted:
            return None

    # TODO Refactor with ndb.Tasklets in order to get input validity check resolutions faster
    def can_add_broker(self, broker_id: str, broker_code: str) -> bool:
        broker_id_exist: bool = self.broker_id_exist(broker_id=broker_id)
        broker_code_exist: bool = self.broker_code_exist(broker_code=broker_code)

bfa9cf56799dd1a5ac68d7cb6e439b5601f9a576

Pytest coverage single falls below minimum 80

Name Stmts Miss Cover
data_service/init.py 0 0 100%
data_service/api/init.py 0 0 100%
data_service/api/affiliates/init.py 0 0 100%
data_service/api/affiliates/routes.py 64 64 0%
data_service/api/api_authenticator.py 43 43 0%
data_service/api/coupons/init.py 0 0 100%
data_service/api/coupons/routes.py 27 27 0%
data_service/api/memberships/init.py 0 0 100%
data_service/api/memberships/routes.py 74 74 0%
data_service/api/pubsub/init.py 0 0 100%
data_service/api/pubsub/routes.py 42 42 0%
data_service/api/scrapper/init.py 0 0 100%
data_service/api/scrapper/routes.py 17 17 0%
data_service/api/settings/init.py 0 0 100%
data_service/api/settings/routes.py 84 84 0%
data_service/api/stocks/init.py 0 0 100%
data_service/api/stocks/routes.py 132 132 0%
data_service/api/users/init.py 0 0 100%
data_service/api/users/routes.py 121 121 0%
data_service/config/init.py 15 15 0%
data_service/config/exceptions.py 22 22 0%
data_service/config/stocks.py 6 6 0%
data_service/config/types.py 7 7 0%
data_service/cron/init.py 0 0 100%
data_service/cron/routes.py 17 17 0%
data_service/frontpage/init.py 0 0 100%
data_service/frontpage/routes.py 7 7 0%
data_service/handlers/init.py 0 0 100%
data_service/handlers/routes.py 31 31 0%
data_service/main/init.py 38 38 0%
data_service/store/init.py 0 0 100%
data_service/store/affiliates.py 241 241 0%
data_service/store/helpdesk.py 58 58 0%
data_service/store/memberships.py 199 199 0%
data_service/store/mixins.py 52 52 0%
data_service/store/scrapper.py 34 34 0%
data_service/store/settings.py 153 153 0%
data_service/store/stats.py 38 38 0%
data_service/store/stocks.py 225 225 0%
data_service/store/users.py 101 101 0%
data_service/store/wallet.py 60 60 0%
data_service/tasks_input_handlers/init.py 0 0 100%
data_service/tasks_input_handlers/routers.py 18 18 0%
data_service/utils/init.py 0 0 100%
data_service/utils/utils.py 54 54 0%
data_service/views/init.py 0 0 100%
data_service/views/affiliates.py 260 260 0%
data_service/views/exception_handlers.py 43 43 0%
data_service/views/memberships.py 412 412 0%
data_service/views/scrapper.py 32 32 0%
data_service/views/settings.py 164 164 0%
data_service/views/stocks.py 622 622 0%
data_service/views/use_context.py 10 10 0%
data_service/views/users.py 142 142 0%
data_service/views/wallet.py 86 86 0%
run.py 5 5 0%
TOTAL 3756 3756 0%
=========================== short test summary
info ============================ ERROR tests/test_store/test_broker.py
ERROR tests/test_store/test_buy_volume.py ERROR tests/test_store/test_sell_volume.py
ERROR tests/test_store/test_stock.py ERROR tests/test_store/test_stock_model.py
ERROR tests/test_store/test_user.py !!!!!!!!!!!!!!!!!!! Interrupted:
6 errors during collection
!!!!!!!!!!!!!!!!!!!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.