Skip to content

Instantly share code, notes, and snippets.

# Standard imports
import tempfile
# Third party imports
import pytest
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from pytest_postgresql import factories
# 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
# 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
# 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):
@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
# 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 """
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'
#!/usr/bin/env python
# Standard imports
from abc import ABCMeta, abstractmethod
import logging
import os
import shlex
import subprocess
from typing import Callable
local = ExecutorFactory.create_executor('local')
out, err = local.run('ls -ltra')
print(out)
@ExecutorFactory.register('local')
class LocalExecutor(ExecutorBase):
# The rest of the code as above
pass