This is a common case in django ORM.
from django.db import models
class Author(models.Model):| class Building: | |
| # do not use magic words | |
| PLACE_OUT_OF_STOCK = 'Out of Stock' | |
| PLACE_REMOTE_WAREHOUSE = 'Remove Warehouse' | |
| # it's just an optimization | |
| __slots__ = ['_material', '_color', '_number', '_store_place', '_original_place'] | |
| # lets make everything private | |
| def __init__(self, material: str, color: str, store_place: str, number: int=0): |
| import sys | |
| import re | |
| from collections import defaultdict | |
| try: | |
| testing_string = sys.argv[1] | |
| except IndexError: | |
| exit(1) | |
| print('Initial String: ', testing_string) |
| import time | |
| import json | |
| import orjson | |
| import rapidjson | |
| m = { | |
| "timestamp": 1556283673.1523004, | |
| "task_uuid": "0ed1a1c3-050c-4fb9-9426-a7e72d0acfc7", | |
| "task_level": [1, 2, 1], | |
| "action_status": "started", |
| #!/usr/bin/env python3 | |
| import asyncio | |
| import ssl | |
| @asyncio.coroutine | |
| async def echo_client(data, loop): | |
| ssl_ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) | |
| ssl_ctx.options |= ssl.OP_NO_TLSv1 |
| from rest_framework.test import APITestCase | |
| from rest_framework import status | |
| from django.core.urlresolvers import reverse | |
| from core.tests.creator_mixin import TestSuitesCreatorMixin | |
| from ..models import ContractChangesRecord | |
| from profilesmanagement.constants import SUBSCRIPTION_LEVEL_CHOICES | |
| import logging | |
| logger = logging.getLogger(__name__) |
| import datetime | |
| from django.conf import settings | |
| from django.apps import apps | |
| from django.test import TestCase, mock | |
| from django.core.urlresolvers import reverse | |
| import random | |
| from rest_framework.test import APIRequestFactory | |
| from ..serializers import AccountStatusesSerializer, CreateAccountSerializer, UpdateAccountSerializer,\ | |
| RetrieveAccountSerializer | |
| from ..constants import STATUS_CHOICES |
| from django.test import TestCase, mock | |
| from django.conf import settings | |
| from django.apps import apps | |
| import datetime | |
| from ..constants import STATUS_CHOICES | |
| class AccountModelTestCase(TestCase): | |
| TEST_USERNAME = 'test_user' | |
| TEST_EMAIL = 'test_user@itoucan.com' |
| class Private: | |
| __number = 1 | |
| # def __add__(self, other): | |
| def __say(self): | |
| print('private say') | |
| def say(self): | |
| print('public say') | |
| self.__say() | |
| def _say(self): |
| class Building: | |
| __matherial = None | |
| __color = None | |
| __quantity = 0 | |
| def __init__(self, matherial, color, number = 0): | |
| self.__matherial = matherial | |
| self.__color = color | |
| self.__quantity = number |