This file contains 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
/* debug.css | MIT License | zaydek.github.com/debug.css */ if (!("is_debugging" in window)) { is_debugging = false; var debug_el = document.createElement("style"); debug_el.append(document.createTextNode(`*:not(g):not(path) { color: hsla(210, 100%, 100%, 0.9) !important; background: hsla(210, 100%, 50%, 0.5) !important; outline: solid 0.25rem hsla(210, 100%, 100%, 0.5) !important; box-shadow: none !important; filter: none !important; }`)); } function enable_debugger() { if (!is_debugging) { document.head.appendChild(debug_el); is_debugging = true; } } function disable_debugger() { if (is_debugging) { document.head.removeChild(debug_el); is_debugging = false; } } !is_debugging ? enable_debugger() : disable_debugger(); |
This file contains 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(scope='function') | |
def session(connection): | |
transaction = connection.begin() | |
session = Session(bind=connection) | |
UserFactory._meta.sqlalchemy_session = session # NB: This line added | |
yield session | |
session.close() | |
transaction.rollback() | |
def my_func_to_delete_user(session, user_id): |
This file contains 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
import pytest | |
import factory | |
from sqlalchemy import create_engine, Column, String, BigInteger | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy.orm import sessionmaker | |
engine = create_engine('DB_CONNECTION_URL') | |
Base = declarative_base(bind=engine) | |
Session = sessionmaker() |
This file contains 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
class UserModel(Base): | |
__tablename__ = 'account' | |
id = Column(BigInteger, primary_key=True) | |
name = Column(String, nullable=False) | |
email = Column(String, nullable=False) | |
class UserFactory(factory.alchemy.SQLAlchemyModelFactory): | |
id = factory.Sequence(lambda n: '%s' % n) | |
name = factory.Faker('name') |
This file contains 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
import factory | |
class User: | |
def __init__(self, name, email): | |
self.name = name | |
self.email = email | |
class UserFactory(factory.Factory): | |
name = factory.Faker('name') | |
email = factory.Faker('email') |
This file contains 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
import pytest | |
from sqlalchemy.orm import sessionmaker | |
from sqlalchemy import create_engine | |
engine = create_engine('DB_CONNECTION_URL') | |
Session = sessionmaker() | |
@pytest.fixture(scope='module') | |
def connection(): | |
connection = engine.connect() |
This file contains 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
# Clean all local tags and fetch from remote | |
git tag | xargs -n 1 -I% git tag -d % && git fetch | |
# Remove from history deleted files. For wrongly committed BIG files that makes repository heavy | |
# Reference https://superuser.com/questions/1191186/remove-large-file-from-several-commits-ago-in-git | |
git filter-branch --tree-filter 'rm -f <filepath>' HEAD |
This file contains 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
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D | |
sh -c 'echo deb https://apt.dockerproject.org/repo ubuntu-trusty main > /etc/apt/sources.list.d/docker.list' | |
echo 'deb http://cz.archive.ubuntu.com/ubuntu trusty main' >> /etc/apt/sources.list | |
# Install docker | |
sudo apt-get update | |
sudo apt-get purge lxc-docker | |
sudo apt-get install -y linux-image-extra-$(uname -r) | |
sudo apt-get install -y libsystemd-journal0 |