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 example.models import Product | |
pytestmark = pytest.mark.django_db | |
class TestProductModel: | |
def test_save(): | |
product = Product.objects.create( |
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 | |
class TestSomething: | |
@pytest.fixture | |
def something(self): | |
return SomeMagic() | |
def test_do_something(self, something): | |
resp = something.do_magic() |
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
from django.contrib.messages.storage.fallback import FallbackStorage | |
from django.contrib.sessions.middleware import SessionMiddleware | |
from django.test import RequestFactory | |
class TestSomeView: | |
def test_view(self): | |
request = RequestFactory().get('/') | |
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 datetime | |
import re | |
import urllib | |
from django.conf import settings | |
import requests | |
from lxml import html | |
from .models import Product |
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 Solution(object): | |
def __init__(self): | |
self.arr = [] | |
def add_product(self, name, locations): | |
self.arr.append((name, locations)) | |
def get_locations(self): | |
data = {} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
{"SBALCONY": | |
[{ | |
"t": "path", | |
"a": {"d": "M303.6,631.5c6.3,0,11.3,5.1,11.3,11.3s-5.1,11.3-11.3,11.3s-11.3-5.1-11.3-11.3S297.4,631.5,303.6,631.5z"} | |
}, | |
{ | |
"t": "path", | |
"a": {"d": "M332,642.8c6.3,0.6,10.8,6.1,10.3,12.2c-0.5,6.2-6.1,10.8-12.2,10.3c-6.2-0.5-10.8-6.1-10.3-12.2 C320.3,646.9,325.8,642.3,332,642.8z"} | |
}, | |
{ |
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
from elasticsearch import Elasticsearch | |
client = Elasticsearch() | |
response = client.search( | |
index="my-index", | |
body={ | |
"query": { | |
"bool": { | |
"must": [{"match": {"title": "python"}}], | |
"must_not": [{"match": {"description": "beta"}}], |
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
from datetime import datetime | |
from elasticsearch_dsl import Document, Date, Keyword, Text | |
from elasticsearch_dsl.connections import connections | |
# Define a default Elasticsearch client | |
connections.create_connection(hosts=['localhost']) | |
class Article(Document): | |
title = Text(analyzer='snowball', fields={'raw': Keyword()}) | |
body = Text(analyzer='snowball') |
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 elasticsearch_dsl as es | |
from some_app import abstract_index | |
from some_app.models import Post | |
class Article(abstract_index.DocumentBase): | |
title = es.Text(analyzer='snowball', fields={'raw': es.Keyword()}) | |
body = es.Text(analyzer='snowball') |