Skip to content

Instantly share code, notes, and snippets.

@mustafaileri
mustafaileri / search_indexes.py
Created December 5, 2016 20:46
drf-sample-search_indexes.py
from haystack import indexes
from models import Model
from django.db.models import Min, Max, Avg
class ModelIndex(indexes.SearchIndex, indexes.Indexable):
id = indexes.IntegerField()
text = indexes.CharField(document=True, use_template=True)
transmission_type = indexes.CharField()
fuel_type = indexes.CharField()
from drf_haystack.serializers import HaystackSerializer
from drf_haystack.viewsets import HaystackViewSet
from api import models
from api import search_indexes
class SearchModelSerializer(HaystackSerializer):
class Meta:
index_classes = [search_indexes.ModelIndex]
POST /example/application HTTP/1.1
Host: example.org
Content-Type: multipart/batch;
type="application/http;version=1.1";
boundary=batch
Mime-Version: 1.0
--batch
Content-Type: application/http;version=1.1
Content-Transfer-Encoding: binary
HTTP/1.1 200 OK
Date: Wed, 29 Apr 2009 20:00:00 GMT
Server: example.org
Content-Type: multipart/batch;
type="application/http;type=1.1";
boundary=batch
Mime-Version: 1.0
--batch
Content-Type: application/http;version=1.1
@mustafaileri
mustafaileri / gist:4e46842c404db46ecb0761db82f7d34a
Created January 3, 2017 21:42
redis-sentinel master mymaster
➜ redis-sentinel-sample git:(master) redis-cli -p 26000
127.0.0.1:26000>
127.0.0.1:26000> sentinel master mymaster
1) "name"
2) "mymaster"
3) "ip"
4) "10.10.10.14"
5) "port"
6) "6379"
7) "runid"
@mustafaileri
mustafaileri / restirctedInvoker.php
Last active January 27, 2017 14:02
Call a private or protected method or property.
<?php
private function invokeRestrictedMethodAndProperties($object, $methodName, $args = [], $properties = [])
{
$reflectionClass = new \ReflectionClass(get_class($object));
$method = $reflectionClass->getMethod($methodName);
$method->setAccessible(true);
foreach ($properties as $propertyKey => $value) {
$prop = $reflectionClass->getProperty($propertyKey);
$prop->setAccessible(true);
$prop->setValue($object, $value);
Feature: journey
@mink:goutte_session
Scenario Outline: Sayfaların 200 kontrolleri
Given Aşağıdaki sayfaları ("<url>") kontrol ettiğimde
Then Sayfa http durum kodu ("<status code>") dönmelidir
Examples:
| url | status code |
| / | 200 |
| /yeni-urunler | 200 |
@mustafaileri
mustafaileri / BaseContext.php
Last active January 30, 2017 07:52
Base context
<?php
use Behat\MinkExtension\Context\MinkContext;
class BaseContext extends MinkContext
{
/**
*
* @BeforeScenario @resetDB
*/
public function resetDB(BeforeScenarioScope $beforeScenarioScope = null)
@mustafaileri
mustafaileri / spin.php
Last active January 30, 2017 08:17
Spin metodu
<?php
use Behat\MinkExtension\Context\MinkContext;
class BaseContext extends MinkContext
{
/**
* @param $closure
* @param int $tries
* @return mixed
* @throws Exception
*/
@mustafaileri
mustafaileri / saveScreenshotAndContent.php
Last active January 30, 2017 08:59
save screenshot and document on behat test fail
<?php
use Behat\MinkExtension\Context\MinkContext;
class BaseContext extends MinkContext
{
...
...
/*
* @AfterStep
*/