Skip to content

Instantly share code, notes, and snippets.

View harshvb7's full-sized avatar

Harsh harshvb7

  • Cologne, Germany
View GitHub Profile
import pytest
from example.models import Product
pytestmark = pytest.mark.django_db
class TestProductModel:
def test_save():
product = Product.objects.create(
import pytest
class TestSomething:
@pytest.fixture
def something(self):
return SomeMagic()
def test_do_something(self, something):
resp = something.do_magic()
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('/')
import datetime
import re
import urllib
from django.conf import settings
import requests
from lxml import html
from .models import Product
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.
{"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"}
},
{
from elasticsearch import Elasticsearch
client = Elasticsearch()
response = client.search(
index="my-index",
body={
"query": {
"bool": {
"must": [{"match": {"title": "python"}}],
"must_not": [{"match": {"description": "beta"}}],
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')
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')