This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Standard imports | |
import tempfile | |
# Third party imports | |
import pytest | |
from sqlalchemy import create_engine | |
from sqlalchemy.orm import sessionmaker | |
from pytest_postgresql import factories | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Third party imports | |
import pytest | |
from sqlalchemy import create_engine | |
from sqlalchemy.orm import sessionmaker | |
# Application imports | |
from core import get_user, get_accounts_by_user, compute_balance, debit | |
from models import Base, User, Account, UserAccount, Transaction | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Standard imports | |
from typing import List | |
# Third party imports | |
from sqlalchemy.orm.session import Session | |
from sqlalchemy.orm.exc import NoResultFound | |
# Application imports | |
from models import Account, User, Transaction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Third party imports | |
from sqlalchemy import Column, Integer, String, DateTime, Float, ForeignKey | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy.orm import relationship | |
from sqlalchemy.sql import func | |
Base = declarative_base() | |
class User(Base): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@pytest.fixture | |
def setup_database(): | |
""" Fixture to set up the in-memory database with test data """ | |
conn = sqlite3.connect(':memory:') | |
cursor = conn.cursor() | |
cursor.execute(''' | |
CREATE TABLE stocks | |
(date text, trans text, symbol text, qty real, price real)''') | |
yield conn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Standard imports | |
import requests | |
import sqlite3 | |
# Third party imports | |
import pytest | |
@pytest.fixture | |
def setup_database(): | |
""" Fixture to set up the in-memory database with test data """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add(a, b): | |
""" Simple function to add two numbers """ | |
return a + b | |
def test_add(): | |
assert add(2, 4) == 6, 'The correct answer should be 6' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Standard imports | |
from abc import ABCMeta, abstractmethod | |
import logging | |
import os | |
import shlex | |
import subprocess | |
from typing import Callable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local = ExecutorFactory.create_executor('local') | |
out, err = local.run('ls -ltra') | |
print(out) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ExecutorFactory.register('local') | |
class LocalExecutor(ExecutorBase): | |
# The rest of the code as above | |
pass |
NewerOlder