Skip to content

Instantly share code, notes, and snippets.

View GeeWee's full-sized avatar

Gustav Wengel GeeWee

View GitHub Profile
all_chefs = ItalianChef.objects.all()
for chef in all_chefs:
# Every time we reach the next line, we'll make an extra database call to fetch the
# favourite dish.
chefs_favourite_dish = chef.favourite_dish
print(f"{chef}'s favourite dish is {chefs_favourite_dish}")
/* eslint import/no-extraneous-dependencies: 0 */
const chalk = require('chalk');
const { getConsoleOutput } = require('jest-util');
const SummaryReporter = require('@jest/reporters/build/summary_reporter')
.default;
const DefaultReporter = require('@jest/reporters/build/default_reporter')
.default;
const getResultHeader = require('@jest/reporters/build/get_result_header')
.default;
import inspect
from collections import OrderedDict
from json import loads, dumps
from pprint import pprint
from typing import Type, Union
from django.core.exceptions import FieldError
from django.test import TestCase
from rest_framework.relations import RelatedField, ManyRelatedField
from rest_framework.serializers import ModelSerializer, Serializer, BaseSerializer, ListSerializer
interface ConfirmDialogConfig {
title: string;
text: string;
deleteButtonText: string;
}
/**
* A hook that will allow you to prompt a user for confirmation before doing a delete, by showing a "Are you sure" modal.
* @param action - the action to be performed when the user presses delete
def run_concurrently(times, args):
"""
Add this decorator to small pieces of code that you want to test
concurrently to make sure they don't raise exceptions when run at the
same time. E.g., some Django views that do a SELECT and then a subsequent
INSERT might fail when the INSERT assumes that the data has not changed
since the SELECT.
"""
def test_concurrently_decorator(test_func):
const myCoolString : string = 9;
if (someString === "APPLE" /* APPLE */) {
console.log("This is an apple!");
}
// This is the const enum. Notice the const in front.
const enum FRUITS {
APPLE = 'APPLE',
PEAR = 'PEAR',
}
if (someString === FRUITS.APPLE){
console.log("This is an apple!"
}
@GeeWee
GeeWee / conftest.py
Last active February 1, 2023 20:26
TEST_TENANT_NAME = "test"
@pytest.fixture(scope="function")
def db(request, django_db_setup, django_db_blocker):
from django.test import TestCase, TransactionTestCase
"""
Django db fixture.
Seeing as this has the same signature, it overrides the fixture in pytest_django.fixtures