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
# <project>/settings.py | |
DATABASES = { | |
"default": { | |
"ENGINE": "django.db.backends.postgresql", | |
# ... | |
"OPTIONS": { | |
"pool": { | |
"min_size": 2, | |
"max_size": 4, |
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
# parameter as a list: genre_list is set to ["drama", "comedy", "sci-fi"] | |
# current query_sring '?type=movie&genre=comedy&page=2' | |
{% query_string type=None genre=genre_list page=page.next_page_number %} | |
# results in '?genre=drama&genre=comedy&genre=sci-fi&page=3' |
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
# <project>/settings.py | |
MIDDLEWARE = [ | |
# ... | |
'django.contrib.auth.middleware.LoginRequiredMiddleware', | |
] | |
# <app>/urls.py | |
from django.contrib.auth.decorators import login_not_required |
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 Property(models.Model): | |
# fields | |
class Meta: | |
abstract = True |
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 Property(models.Model): | |
price = models.DecimalField(max_digits=15, decimal_places=2) | |
rooms = models.PositiveIntegerField() | |
address = models.TextField(null=True, blank=True) | |
city = models.CharField(max_length=255) | |
country = models.CharField(max_length=255) | |
class Meta: | |
abstract = True |
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
$ # mut.py --target node --unit-test test_node | |
$ mut.py --target calculator --unit-test test_calculator -m |
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
[*] Start mutation process: | |
- targets: calculator | |
- tests: test_calculator | |
[*] All tests passed: | |
- test_calculator [0.00031 s] | |
[*] Start mutants generation and execution: | |
- [# 1] AOR calculator.py:2 : | |
-------------------------------------------------------------------- | |
1: def mul(x, y): | |
~2: return x / y |
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 ProductQuestionnaireCreateTestCase(SimpleTestCase): | |
def test_vat_20_if_biscuit_coated_in_chocolate(self): | |
calc = VATCalculator() | |
self.assertEqual( | |
calc.calculate_vat( | |
is_biscuit=True, | |
is_coated_in_chocolate=True | |
), 20) |
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 VATCalculator(object): | |
def calculate_vat(self, **kwargs): | |
is_biscuit = kwargs['is_biscuit'] | |
is_coated_in_chocolate = kwargs['is_coated_in_chocolate'] | |
if is_biscuit and is_coated_in_chocolate: | |
return 20 |
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 ProductQuestionnaireTestCase(TestCase): | |
def test_vat_20_if_biscuit_coated_in_chocolate(self): | |
product = ProductFactory() | |
form = ProductQuestionnaireForm(data={ | |
'is_biscuit': True, | |
'is_coated_in_chocolate': True | |
}) | |
self.assertTrue(form.is_valid()) | |
form.save() |
NewerOlder