Skip to content

Commit

Permalink
Use the test client to verify that publishing only one of the two events
Browse files Browse the repository at this point in the history
in the fixture results in only that one event showing as published.
  • Loading branch information
jamezpolley committed Mar 24, 2012
1 parent 7c96142 commit 798e12e
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 37 deletions.
6 changes: 1 addition & 5 deletions doc/hitlist.rst
Expand Up @@ -48,11 +48,7 @@ Publish an event
* Verify that events page shows that event as being published (ie, ready to announce)
* Verify that events page does not show the other event as being published

Kinda-sorta-mostly done in :func:`usergroup.selenium_tests.create_and_manipulate_meetings_test.TestEventCreationAndPublication.testNewEventReadyToPublish`, although it only uses one event.

* TODO: Switch to using a fixture instead of clicky-clicky to save time.
* TODO: Start with two unpublished events, not one
* TODO: Add verification that the second event is not published.
Implemented in :func:`usergroup.django_tests.event_manipulation_test.TestPublishSomeEvents.test_unpublished_events_show_as_unpublished`

Normal users cannot see unpublished events
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
23 changes: 23 additions & 0 deletions usergroup/django_tests/event_manipulation_test.py
Expand Up @@ -56,3 +56,26 @@ def test_ready_to_publish(self):
response = self.client.get('/events')
self.assertContains(response, '<input id="submit_1" type="submit" '
'value="Publish event">')

class TestPublishSomeEvents(django.test.TestCase):
"""Test that only published events show as being published."""

fixtures = ['test_admin_user', 'two_unpublished_events']

def test_unpublished_events_show_as_unpublished(self):
"""Test that only published events show as being published."""
self.client.login(username="admin", password="admin")
response = self.client.get('/events')
#Two events, ready to publish
self.assertContains(response, '<input id="submit_1" type="submit" '
'value="Publish event">')
self.assertContains(response, '<input id="submit_2" type="submit" '
'value="Publish event">')
#Publish the first event
response = self.client.post('/event/1/publish', follow=True)
#First event should now be ready for announcement
self.assertContains(response, '<input id="submit_1" type="submit" '
'value="Announce event via email">')
#Second event should still be waiting to be published
self.assertContains(response, '<input id="submit_2" type="submit" '
'value="Publish event">')
36 changes: 36 additions & 0 deletions usergroup/fixtures/two_unpublished_events.json
@@ -0,0 +1,36 @@
[
{
"fields": {
"announcement": null,
"created_by": 1,
"created_on": "2012-02-25 23:26:18",
"emailed": false,
"end": "2012-03-30 20:00:00",
"html": "<p>\n<h1> March 2012 SLUG Meeting </h1>\n</p>\n<p>\n<h1>Summary</h1>\n</p>\n<ul>\n<li>Date: Friday, March 30, 2012, 6 p.m.</li>\n<li>Start: Arrive at 6pm for a 6:30pm start</li>\n<li>Format: TBA</li>\n<li>RSVP: <a href=\"http://localhost:8000/event/2\">http://localhost:8000/event/2</a></li>\n<li>Suggest or sign up for a talk at <a href=\"http://localhost:8000/talks\">http://localhost:8000/talks</a></li>\n</ul>\n<p>\n<h1> Details </h1>\n</p>\n<p>Details TBA.</p>\n<p>\n<h1>Location</h1>\n</p>\n<p>Google Sydney\n Level 5, Workplace 6\n 48 Pirrama Road\n Pyrmont, NSW</p>\n<p>Map: <a href=\"http://localhost:8000/map\">http://localhost:8000/map</a></p>\n<p>\n<h2> Getting there </h2>\n</p>\n<p>The Google office is the big black building marked \"Accenture\" opposite\nStar City Pirrama Road facade.</p>\n<p>If using the trains, you can go either get off at;</p>\n<ul>\n<li>Town Hall station, head towards Darling Harbour, walk across the Pyrmont\n footbridge and then follow Pirrama Road towards Star city.</li>\n<li>Central station, then follow the light rail instructions.</li>\n</ul>\n<p>If using the buses, the route 443 stops right out front of the building.</p>\n<p>If using the light rail, get off at Star City station and walk across the\nstreet.</p>\n<p>If you drive, then you can look for parking on the suburban streets around\nthe office (or pay for parking at the Casino), and then walk from there.</p>\n<p>\n<h1> Afterwards </h1>\n</p>\n<p>We'll be aiming to finish by 8pm and will be heading to the Pyrmont Bridge\nHotel (PBH) afterwards to socalise and eat dinner. The PBH is marked on the\nmap.</p>",
"input": "====== {{event.start|date:\"F\"}} {{event.start.year}} SLUG Meeting ======\r\n\r\n====Summary====\r\n\r\n * Date: Friday, {{event.start}}\r\n * Start: Arrive at 6pm for a 6:30pm start\r\n * Format: TBA\r\n * RSVP: http://{{ request.get_host }}{{event.get_url}}\r\n * Suggest or sign up for a talk at http://{{ request.get_host }}/talks\r\n\r\n==== Details ====\r\n\r\n{% for item in agenda %}\r\n - {{ item.offer.displayname }} - {{ item.offer.title }}\r\n{% empty %}\r\nDetails TBA.\r\n{% endfor %}\r\n\r\n====Location====\r\n\r\n Google Sydney\r\n Level 5, Workplace 6\r\n 48 Pirrama Road\r\n Pyrmont, NSW\r\n\r\n Map: http://{{ request.get_host }}/map\r\n\r\n-- Getting there --\r\n\r\nThe Google office is the big black building marked \"Accenture\" opposite\r\nStar City Pirrama Road facade.\r\n\r\nIf using the trains, you can go either get off at;\r\n\r\n * Town Hall station, head towards Darling Harbour, walk across the Pyrmont\r\n footbridge and then follow Pirrama Road towards Star city.\r\n * Central station, then follow the light rail instructions.\r\n\r\nIf using the buses, the route 443 stops right out front of the building.\r\n\r\nIf using the light rail, get off at Star City station and walk across the\r\nstreet.\r\n\r\nIf you drive, then you can look for parking on the suburban streets around\r\nthe office (or pay for parking at the Casino), and then walk from there.\r\n\r\n=== Afterwards ===\r\n\r\nWe'll be aiming to finish by 8pm and will be heading to the Pyrmont Bridge\r\nHotel (PBH) afterwards to socalise and eat dinner. The PBH is marked on the\r\nmap.\r\n",
"name": "Monthly Meeting",
"plaintext": "====== March 2012 SLUG Meeting ======\r\n\r\n====Summary====\r\n\r\n * Date: Friday, March 30, 2012, 6 p.m.\r\n * Start: Arrive at 6pm for a 6:30pm start\r\n * Format: TBA\r\n * RSVP: http://localhost:8000/event/2\r\n * Suggest or sign up for a talk at http://localhost:8000/talks\r\n\r\n==== Details ====\r\n\r\n\r\nDetails TBA.\r\n\r\n\r\n====Location====\r\n\r\n Google Sydney\r\n Level 5, Workplace 6\r\n 48 Pirrama Road\r\n Pyrmont, NSW\r\n\r\n Map: http://localhost:8000/map\r\n\r\n-- Getting there --\r\n\r\nThe Google office is the big black building marked \"Accenture\" opposite\r\nStar City Pirrama Road facade.\r\n\r\nIf using the trains, you can go either get off at;\r\n\r\n * Town Hall station, head towards Darling Harbour, walk across the Pyrmont\r\n footbridge and then follow Pirrama Road towards Star city.\r\n * Central station, then follow the light rail instructions.\r\n\r\nIf using the buses, the route 443 stops right out front of the building.\r\n\r\nIf using the light rail, get off at Star City station and walk across the\r\nstreet.\r\n\r\nIf you drive, then you can look for parking on the suburban streets around\r\nthe office (or pay for parking at the Casino), and then walk from there.\r\n\r\n=== Afterwards ===\r\n\r\nWe'll be aiming to finish by 8pm and will be heading to the Pyrmont Bridge\r\nHotel (PBH) afterwards to socalise and eat dinner. The PBH is marked on the\r\nmap.\r\n",
"published": false,
"start": "2012-03-30 18:00:00"
},
"model": "usergroup.event",
"pk": 1
},
{
"fields": {
"announcement": null,
"created_by": 2,
"created_on": "2012-03-20 12:21:05",
"emailed": false,
"end": "2012-03-30 20:00:00",
"html": "<p>\n<h1> March 2012 SLUG Meeting </h1>\n</p>\n<p>\n<h1>Summary</h1>\n</p>\n<ul>\n<li>Date: Friday, March 30, 2012, 6 p.m.</li>\n<li>Start: Arrive at 6pm for a 6:30pm start</li>\n<li>Format: TBA</li>\n<li>RSVP: <a href=\"http://localhost:8000/event/3\">http://localhost:8000/event/3</a></li>\n<li>Suggest or sign up for a talk at <a href=\"http://localhost:8000/talks\">http://localhost:8000/talks</a></li>\n</ul>\n<p>\n<h1> Details </h1>\n</p>\n<p>Details TBA.</p>\n<p>\n<h1>Location</h1>\n</p>\n<p>Google Sydney\n Level 5, Workplace 6\n 48 Pirrama Road\n Pyrmont, NSW</p>\n<p>Map: <a href=\"http://localhost:8000/map\">http://localhost:8000/map</a></p>\n<p>\n<h2> Getting there </h2>\n</p>\n<p>The Google office is the big black building marked \"Accenture\" opposite\nStar City Pirrama Road facade.</p>\n<p>If using the trains, you can go either get off at;</p>\n<ul>\n<li>Town Hall station, head towards Darling Harbour, walk across the Pyrmont\n footbridge and then follow Pirrama Road towards Star city.</li>\n<li>Central station, then follow the light rail instructions.</li>\n</ul>\n<p>If using the buses, the route 443 stops right out front of the building.</p>\n<p>If using the light rail, get off at Star City station and walk across the\nstreet.</p>\n<p>If you drive, then you can look for parking on the suburban streets around\nthe office (or pay for parking at the Casino), and then walk from there.</p>\n<p>\n<h1> Afterwards </h1>\n</p>\n<p>We'll be aiming to finish by 8pm and will be heading to the Pyrmont Bridge\nHotel (PBH) afterwards to socalise and eat dinner. The PBH is marked on the\nmap.</p>",
"input": "====== {{event.start|date:\"F\"}} {{event.start.year}} SLUG Meeting ======\r\n\r\n====Summary====\r\n\r\n * Date: Friday, {{event.start}}\r\n * Start: Arrive at 6pm for a 6:30pm start\r\n * Format: TBA\r\n * RSVP: http://{{ request.get_host }}{{event.get_url}}\r\n * Suggest or sign up for a talk at http://{{ request.get_host }}/talks\r\n\r\n==== Details ====\r\n\r\n{% for item in agenda %}\r\n - {{ item.offer.displayname }} - {{ item.offer.title }}\r\n{% empty %}\r\nDetails TBA.\r\n{% endfor %}\r\n\r\n====Location====\r\n\r\n Google Sydney\r\n Level 5, Workplace 6\r\n 48 Pirrama Road\r\n Pyrmont, NSW\r\n\r\n Map: http://{{ request.get_host }}/map\r\n\r\n-- Getting there --\r\n\r\nThe Google office is the big black building marked \"Accenture\" opposite\r\nStar City Pirrama Road facade.\r\n\r\nIf using the trains, you can go either get off at;\r\n\r\n * Town Hall station, head towards Darling Harbour, walk across the Pyrmont\r\n footbridge and then follow Pirrama Road towards Star city.\r\n * Central station, then follow the light rail instructions.\r\n\r\nIf using the buses, the route 443 stops right out front of the building.\r\n\r\nIf using the light rail, get off at Star City station and walk across the\r\nstreet.\r\n\r\nIf you drive, then you can look for parking on the suburban streets around\r\nthe office (or pay for parking at the Casino), and then walk from there.\r\n\r\n=== Afterwards ===\r\n\r\nWe'll be aiming to finish by 8pm and will be heading to the Pyrmont Bridge\r\nHotel (PBH) afterwards to socalise and eat dinner. The PBH is marked on the\r\nmap.\r\n",
"name": "asfdadsf",
"plaintext": "====== March 2012 SLUG Meeting ======\r\n\r\n====Summary====\r\n\r\n * Date: Friday, March 30, 2012, 6 p.m.\r\n * Start: Arrive at 6pm for a 6:30pm start\r\n * Format: TBA\r\n * RSVP: http://localhost:8000/event/3\r\n * Suggest or sign up for a talk at http://localhost:8000/talks\r\n\r\n==== Details ====\r\n\r\n\r\nDetails TBA.\r\n\r\n\r\n====Location====\r\n\r\n Google Sydney\r\n Level 5, Workplace 6\r\n 48 Pirrama Road\r\n Pyrmont, NSW\r\n\r\n Map: http://localhost:8000/map\r\n\r\n-- Getting there --\r\n\r\nThe Google office is the big black building marked \"Accenture\" opposite\r\nStar City Pirrama Road facade.\r\n\r\nIf using the trains, you can go either get off at;\r\n\r\n * Town Hall station, head towards Darling Harbour, walk across the Pyrmont\r\n footbridge and then follow Pirrama Road towards Star city.\r\n * Central station, then follow the light rail instructions.\r\n\r\nIf using the buses, the route 443 stops right out front of the building.\r\n\r\nIf using the light rail, get off at Star City station and walk across the\r\nstreet.\r\n\r\nIf you drive, then you can look for parking on the suburban streets around\r\nthe office (or pay for parking at the Casino), and then walk from there.\r\n\r\n=== Afterwards ===\r\n\r\nWe'll be aiming to finish by 8pm and will be heading to the Pyrmont Bridge\r\nHotel (PBH) afterwards to socalise and eat dinner. The PBH is marked on the\r\nmap.\r\n",
"published": false,
"start": "2012-03-30 18:00:00"
},
"model": "usergroup.event",
"pk": 2
}
]
32 changes: 0 additions & 32 deletions usergroup/selenium_tests/create_and_manipulate_meetings_test.py
Expand Up @@ -32,38 +32,6 @@ def get_id_and_action_from_url(self, event_url):
event_action = event_url[2]
return event_id, event_action

def do_two_events(self):
"""Create two events; publish the first event.
TODO: this should probably be replaced with a fixture."""
self.doLogin()
#create first event
event_url = self.do_create_event()
first_event_id, _ = self.get_id_and_action_from_url(event_url)
#create second event
event_url = self.do_create_event(friday=2)
second_event_id, _ = self.get_id_and_action_from_url(event_url)
#Go to events page; publish first event
self.browser.find_element_by_id("events_link").click()
submit = self.browser.find_element_by_id("submit_%s" % first_event_id)
submit.click()
self.doLogout()

return first_event_id, second_event_id

def testPublishedEventReadyToAnnounce(self):
"""Newly created events should be in the unpublished state."""
#FIXME: Nothing being tested here is clientside, so use the test client
self.doLogin()
event_url = self.do_create_event()
event_id, _ = self.get_id_and_action_from_url(event_url)
self.browser.find_element_by_id("events_link").click()
submit = self.browser.find_element_by_id("submit_%s" % event_id)
submit.click()
submit = self.browser.find_element_by_id("submit_%s" % event_id)
submit_text = submit.get_attribute("value")
self.assertEqual(u"Announce event via email", submit_text, msg=submit)

def testUnpublishedEventInvisibleToAnonymousUsers(self):
"""Create two events; publish one; log out. Should only see one."""
#FIXME: Nothing being tested here is clientside, so use the test client
Expand Down

0 comments on commit 798e12e

Please sign in to comment.