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
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}") |
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
/* 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; |
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 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 |
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
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 |
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
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): |
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
const myCoolString : string = 9; |
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
if (someString === "APPLE" /* APPLE */) { | |
console.log("This is an apple!"); | |
} |
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
// 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!" | |
} |
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
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 |