Skip to content
This repository was archived by the owner on Sep 19, 2018. It is now read-only.

Commit 62e9fe1

Browse files
author
Mateja Verlic
committed
Merge pull request #2 from gandalfar/fea_search_get2
initial tests for search functionality
2 parents c8ecd8c + f9aca01 commit 62e9fe1

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

web/tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Meta:
1010
model = Event
1111

1212
organizer="Event Organizer"
13-
creator=factory.LazyAttribute(lambda n: User.objects.get(pk=1))
13+
creator=factory.LazyAttribute(lambda n: User.objects.get_or_create(username='test_user')[0])
1414
title="My Coding Event"
1515
description="Some description"
1616
location="Nonexisting location"

web/tests/test_event_search.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# -*- coding: utf-8 -*-
2+
import pytest
3+
4+
from web.tests import EventFactory, ApprovedEventFactory, PastEventFactory
5+
6+
@pytest.mark.django_db
7+
def test_search_show_only_approved(db, client):
8+
approved_event = ApprovedEventFactory.create()
9+
unapproved_event = EventFactory.create()
10+
11+
response = client.get('/search/')
12+
13+
assert approved_event.get_absolute_url() in response.content
14+
assert unapproved_event.get_absolute_url() not in response.content
15+
16+
map(lambda x: x.delete(), [approved_event, unapproved_event])
17+
18+
def test_search_do_not_show_past_events(db, client):
19+
future_event = ApprovedEventFactory.create()
20+
past_event = PastEventFactory.create(status='APPROVED')
21+
22+
response = client.get('/search/')
23+
24+
assert future_event.get_absolute_url() in response.content
25+
assert past_event.get_absolute_url() not in response.content
26+
27+
map(lambda x: x.delete(), [future_event, past_event])
28+
29+
def test_search_show_past_events(db, client):
30+
future_event = ApprovedEventFactory.create()
31+
past_event = PastEventFactory.create(status='APPROVED')
32+
33+
response = client.get('/search/?past=on')
34+
35+
assert future_event.get_absolute_url() in response.content
36+
assert past_event.get_absolute_url() in response.content
37+
38+
map(lambda x: x.delete(), [future_event, past_event])

0 commit comments

Comments
 (0)