Skip to content

Commit

Permalink
Merge pull request #42 from unt-libraries/test-models
Browse files Browse the repository at this point in the history
Add tests for models.
  • Loading branch information
damonkelley committed Oct 28, 2015
2 parents e2cc171 + 773fe8c commit cde7c27
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import pytest

from django.core.urlresolvers import reverse
from . import factories


class TestAgent:

def test_unicode(self):
agent = factories.AgentFactory.build()
assert agent.agent_name == unicode(agent)

def test_get_absolute_url(self):
agent = factories.AgentFactory.build()
url = '/agent/{0}/'.format(agent.agent_identifier)
assert agent.get_absolute_url() == url


class TestLinkObject:

def test_unicode(self):
link_object = factories.LinkObjectFactory.build()
assert link_object.object_identifier == unicode(link_object)


class TestEvent:

def test_unicode(self):
event = factories.EventFactory.build()
assert event.event_identifier == unicode(event)

@pytest.mark.django_db
def test_link_objects_string_with_link_objects(self):
event = factories.EventFactory.create(
linking_objects=True,
linking_objects__count=2)

linking_objects = event.linking_objects.all()
string = '\n'.join([s.object_identifier for s in linking_objects])
assert string == event.link_objects_string()

@pytest.mark.django_db
def test_link_objects_string_without_link_objects(self):
event = factories.EventFactory.build()
assert '' == event.link_objects_string()

def test_is_good_is_true(self):
event = factories.EventFactory.build(
event_outcome='http://example.com/#success')

assert event.is_good() is True

def test_is_good_is_false(self):
event = factories.EventFactory.build(
event_outcome='http://example.com/#not-success')

assert event.is_good() is False

0 comments on commit cde7c27

Please sign in to comment.