Skip to content

Instantly share code, notes, and snippets.

View katiayn's full-sized avatar

Kátia Nakamura katiayn

View GitHub Profile
@katiayn
katiayn / keybase.md
Last active November 16, 2016 09:43

Keybase proof

I hereby claim:

  • I am katiayn on github.
  • I am katia (https://keybase.io/katia) on keybase.
  • I have a public key ASA3faIPF-NFIki-kBa6U-JSE7oP34bH_DEjw9kYp5KLmgo

To claim this, I am signing this object:

import random
import string
from django.test import TestCase
import factory
from codekiwi.core.models import Employee
def generate_random_str(length=10):
from django.test import TestCase
import factory
from codekiwi.core.models import Employee
class EmployeeFactory(factory.DjangoModelFactory):
class Meta:
model = Employee
from hypothesis.extra.django import TestCase
from hypothesis import given
from hypothesis.extra.django.models import models
from hypothesis.strategies import lists, integers
class TestProjectManagement(TestCase):
@given(
models(Project, collaborator_limit=integers(min_value=0, max_value=20)),
lists(models(User), max_size=20))
def mul(x, y):
return x * y
from unittest import TestCase
from calculator import mul
class CalculatorTest(TestCase):
def test_mul(self):
self.assertEqual(mul(2, 2), 4)
@katiayn
katiayn / models.py
Last active January 23, 2017 21:43
from django.db import models
from django.utils.translation import ugettext as _
class Product(models.Model):
name = models.CharField(max_length=255, verbose_name='Name', blank=True)
price = models.DecimalField(
_('Price'),
max_digits=5,
decimal_places=2,
def form_valid(self, form):
self.instance = form.save(commit=False)
object = self.get_object()
if self.instance.is_biscuit and self.instance.is_coated_in_chocolate:
object.set_vat_20()
return super().form_valid(form)
class ProductQuestionnaireTestCase(TestCase):
def test_vat_20_if_biscuit_coated_in_chocolate(self):
product = ProductFactory()
url = '/{}/questionnaire/'.format(product.pk)
self.client.post(url, {
'is_biscuit': True,
'is_coated_in_chocolate': True
})
product.refresh_from_db()
class ProductQuestionnaireForm(forms.ModelForm):
class Meta:
model = ProductQuestionnaire
exclude = (
'id',
'product',
)
def save(self, commit=True):