Skip to content

Commit

Permalink
bugfix, fixed tests and adjust testing configs
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Banduhn committed Dec 19, 2015
1 parent ca6c082 commit d2f2f7c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
5 changes: 2 additions & 3 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[run]
branch = True
omit =
*/__init__.py
howl/migrations/*
howl/tests/*
*/__init__.py
*migrations*
9 changes: 5 additions & 4 deletions howl/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import datetime, timedelta
from datetime import timedelta

from django.db import models
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _

from .operators import get_operator_class, get_operator_types
Expand Down Expand Up @@ -28,10 +29,10 @@ def compare(self, compare_value):

if operator_class(self).compare(compare_value):
Alert.clear(self)
return False
return True

Alert.set(self, compare_value)
return True
return False


class Alert(models.Model):
Expand Down Expand Up @@ -66,7 +67,7 @@ def set(cls, observer, compare_value):

alert_time = obj.timestamp + timedelta(seconds=observer.waiting_period)

if alert_time < datetime.now():
if alert_time < timezone.now():
if obj.state == obj.STATE_NOTIFIED and observer.alert_every_time:
obj.value = compare_value
obj.save(update_fields=['value'])
Expand Down
2 changes: 1 addition & 1 deletion howl/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TestAlertAdmin:

def test_list_display(self, rf):
modeladmin = AlertAdmin(Alert, admin.site)
assert modeladmin.list_display == ('get_observer_name', 'timestamp', 'state')
assert modeladmin.list_display == ('get_observer_name', 'timestamp', 'value', 'state')

def test_get_observer_name(self, rf):
observer = ObserverFactory.create()
Expand Down
6 changes: 3 additions & 3 deletions howl/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def test_repr(self):
assert str(obj) == 'test observer'

@pytest.mark.parametrize('value, compare_value, return_value, count_objects', [
(49, 50, True, 1),
(50, 50, False, 0),
(51, 50, True, 1),
(49, 50, False, 1),
(50, 50, True, 0),
(51, 50, False, 1),
])
def test_compare(self, value, compare_value, return_value, count_objects):
obj = ObserverFactory.create(value=value)
Expand Down
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ pep8ignore =
flakes-ignore =
*/.ropeproject/* ALL

isort_ignore=
*migrations/*.py

DJANGO_SETTINGS_MODULE = howl.tests.settings

0 comments on commit d2f2f7c

Please sign in to comment.