| |
@@ -42,13 +42,17 @@
|
| |
import flask
|
| |
import six
|
| |
|
| |
+ import fedocal_messages.messages as schema
|
| |
+ from fedora_messaging import testing
|
| |
+ from mock import ANY, patch
|
| |
+
|
| |
sys.path.insert(0, os.path.join(os.path.dirname(
|
| |
os.path.abspath(__file__)), '..'))
|
| |
|
| |
import fedocal
|
| |
import fedocal.fedocallib as fedocallib
|
| |
import fedocal.fedocallib.model as model
|
| |
- from tests import (Modeltests, FakeUser, flask10_only, user_set, TODAY,
|
| |
+ from tests import (Modeltests, FakeUser, user_set, TODAY,
|
| |
ICS_FILE, ICS_FILE_NOTOK)
|
| |
|
| |
|
| |
@@ -841,16 +845,13 @@
|
| |
self.assertFalse(
|
| |
fedocal.is_safe_url('https://fedoraproject.org/'))
|
| |
|
| |
- @flask10_only
|
| |
def test_auth_login(self):
|
| |
""" Test the auth_login function. """
|
| |
self.__setup_db()
|
| |
user = FakeUser([], username='pingou')
|
| |
with user_set(fedocal.APP, user):
|
| |
- output = self.app.get('/login/', follow_redirects=True)
|
| |
- self.assertEqual(output.status_code, 200)
|
| |
- output_text = output.get_data(as_text=True)
|
| |
- self.assertIn('<title>Home - Fedocal</title>', output_text)
|
| |
+ output = self.app.get('/login/')
|
| |
+ self.assertEqual(output.status_code, 302)
|
| |
|
| |
def test_locations(self):
|
| |
""" Test the locations function. """
|
| |
@@ -905,7 +906,6 @@
|
| |
'class="errors">No location named foobar could be found</',
|
| |
output_text)
|
| |
|
| |
- @flask10_only
|
| |
def test_admin(self):
|
| |
""" Test the admin function. """
|
| |
user = None
|
| |
@@ -973,18 +973,12 @@
|
| |
self.assertIn(
|
| |
'value="Delete">', output_text)
|
| |
|
| |
- @flask10_only
|
| |
def test_add_calendar(self):
|
| |
""" Test the add_calendar function. """
|
| |
user = None
|
| |
with user_set(fedocal.APP, user):
|
| |
- output = self.app.get('/calendar/add/', follow_redirects=True)
|
| |
- self.assertEqual(output.status_code, 200)
|
| |
- output_text = output.get_data(as_text=True)
|
| |
- # discoveryfailure happens if there is no network
|
| |
- self.assertTrue(
|
| |
- '<title>OpenID transaction in progress</title>'
|
| |
- in output_text or 'discoveryfailure' in output_text)
|
| |
+ output = self.app.get('/calendar/add/')
|
| |
+ self.assertEqual(output.status_code, 302)
|
| |
|
| |
user = FakeUser(['test'])
|
| |
with user_set(fedocal.APP, user):
|
| |
@@ -1034,12 +1028,26 @@
|
| |
'csrf_token': csrf_token,
|
| |
}
|
| |
|
| |
- output = self.app.post('/calendar/add/', data=data,
|
| |
- follow_redirects=True)
|
| |
- self.assertEqual(output.status_code, 200)
|
| |
- output_text = output.get_data(as_text=True)
|
| |
- self.assertIn(
|
| |
- '<li class="message">Calendar added</li>', output_text)
|
| |
+ with testing.mock_sends(schema.CalendarNewV1(
|
| |
+ topic="fedocal.calendar.new",
|
| |
+ body={
|
| |
+ 'agent': 'username',
|
| |
+ 'calendar': {
|
| |
+ 'calendar_name': 'election1',
|
| |
+ 'calendar_contact': 'election1',
|
| |
+ 'calendar_description': '',
|
| |
+ 'calendar_editor_group': '',
|
| |
+ 'calendar_admin_group': '',
|
| |
+ 'calendar_status': 'Enabled'
|
| |
+ }
|
| |
+ }
|
| |
+ )):
|
| |
+ output = self.app.post('/calendar/add/', data=data,
|
| |
+ follow_redirects=True)
|
| |
+ self.assertEqual(output.status_code, 200)
|
| |
+ output_text = output.get_data(as_text=True)
|
| |
+ self.assertIn(
|
| |
+ '<li class="message">Calendar added</li>', output_text)
|
| |
|
| |
# This calendar already exists
|
| |
data = {
|
| |
@@ -1057,7 +1065,6 @@
|
| |
'="errors">Could not add this calendar to the database</',
|
| |
output_text)
|
| |
|
| |
- @flask10_only
|
| |
def test_delete_calendar(self):
|
| |
""" Test the delete_calendar function. """
|
| |
self.__setup_db()
|
| |
@@ -1135,20 +1142,33 @@
|
| |
'csrf_token': csrf_token,
|
| |
}
|
| |
|
| |
- output = self.app.post('/calendar/delete/test_calendar/',
|
| |
- data=data, follow_redirects=True)
|
| |
- self.assertEqual(output.status_code, 200)
|
| |
- output_text = output.get_data(as_text=True)
|
| |
- self.assertIn(
|
| |
- '<title>Home - Fedocal</title>', output_text)
|
| |
- self.assertIn(
|
| |
- '<li class="message">Calendar deleted</li>',
|
| |
- output_text)
|
| |
- self.assertNotIn(
|
| |
- '<span class="calendar_name">test_calendar</span>',
|
| |
- output_text)
|
| |
+ with testing.mock_sends(schema.CalendarDeleteV1(
|
| |
+ topic="fedocal.calendar.delete",
|
| |
+ body={
|
| |
+ 'agent': 'kevin',
|
| |
+ 'calendar': {
|
| |
+ 'calendar_name': 'test_calendar',
|
| |
+ 'calendar_contact': 'test@example.com',
|
| |
+ 'calendar_description': 'This is a test calendar',
|
| |
+ 'calendar_editor_group': 'fi-apprentice',
|
| |
+ 'calendar_admin_group': 'infrastructure-main2',
|
| |
+ 'calendar_status': 'Enabled'
|
| |
+ }
|
| |
+ }
|
| |
+ )):
|
| |
+ output = self.app.post('/calendar/delete/test_calendar/',
|
| |
+ data=data, follow_redirects=True)
|
| |
+ self.assertEqual(output.status_code, 200)
|
| |
+ output_text = output.get_data(as_text=True)
|
| |
+ self.assertIn(
|
| |
+ '<title>Home - Fedocal</title>', output_text)
|
| |
+ self.assertIn(
|
| |
+ '<li class="message">Calendar deleted</li>',
|
| |
+ output_text)
|
| |
+ self.assertNotIn(
|
| |
+ '<span class="calendar_name">test_calendar</span>',
|
| |
+ output_text)
|
| |
|
| |
- @flask10_only
|
| |
def test_clear_calendar(self):
|
| |
""" Test the clear_calendar function. """
|
| |
self.__setup_db()
|
| |
@@ -1220,28 +1240,41 @@
|
| |
output_text = output.get_data(as_text=True)
|
| |
self.assertIn(
|
| |
'<title>test_calendar - Fedocal</title>', output_text)
|
| |
- self.assertIn(
|
| |
- '<title>test_calendar - Fedocal</title>', output_text)
|
| |
+ self.assertNotIn(
|
| |
+ '<li class="message">Calendar cleared</li>', output_text)
|
| |
|
| |
# Delete
|
| |
data = {
|
| |
+ # html booleans are: arg missing = False, arg present = True
|
| |
+ # regardless of the value of the arg passed
|
| |
'confirm_delete': False,
|
| |
'csrf_token': csrf_token,
|
| |
}
|
| |
|
| |
- output = self.app.post('/calendar/clear/test_calendar/',
|
| |
- data=data, follow_redirects=True)
|
| |
- self.assertEqual(output.status_code, 200)
|
| |
- output_text = output.get_data(as_text=True)
|
| |
- self.assertIn(
|
| |
- '<title>test_calendar - Fedocal</title>', output_text)
|
| |
- self.assertIn(
|
| |
- '<title>test_calendar - Fedocal</title>', output_text)
|
| |
- self.assertIn(
|
| |
- '<li class="message">Calendar cleared</li>',
|
| |
- output_text)
|
| |
+ with testing.mock_sends(schema.CalendarClearV1(
|
| |
+ topic="fedocal.calendar.clear",
|
| |
+ body={
|
| |
+ 'agent': 'kevin',
|
| |
+ 'calendar': {
|
| |
+ 'calendar_name': 'test_calendar',
|
| |
+ 'calendar_contact': 'test@example.com',
|
| |
+ 'calendar_description': 'This is a test calendar',
|
| |
+ 'calendar_editor_group': 'fi-apprentice',
|
| |
+ 'calendar_admin_group': 'infrastructure-main2',
|
| |
+ 'calendar_status': 'Enabled'
|
| |
+ }
|
| |
+ }
|
| |
+ )):
|
| |
+ output = self.app.post('/calendar/clear/test_calendar/',
|
| |
+ data=data, follow_redirects=True)
|
| |
+ self.assertEqual(output.status_code, 200)
|
| |
+ output_text = output.get_data(as_text=True)
|
| |
+ self.assertIn(
|
| |
+ '<title>test_calendar - Fedocal</title>', output_text)
|
| |
+ self.assertIn(
|
| |
+ '<li class="message">Calendar cleared</li>',
|
| |
+ output_text)
|
| |
|
| |
- @flask10_only
|
| |
def test_edit_calendar(self):
|
| |
""" Test the edit_calendar function. """
|
| |
self.__setup_db()
|
| |
@@ -1307,7 +1340,7 @@
|
| |
self.assertEqual(output.status_code, 200)
|
| |
output_text = output.get_data(as_text=True)
|
| |
self.assertEqual(
|
| |
- output_text.count('<td>This field is required.</td>'), 2)
|
| |
+ output_text.count('<td>This field is required.</td>'), 3)
|
| |
self.assertIn(
|
| |
'<h2>Edit calendar "test_calendar"</h2>',
|
| |
output_text)
|
| |
@@ -1323,23 +1356,36 @@
|
| |
'csrf_token': csrf_token,
|
| |
}
|
| |
|
| |
- output = self.app.post('/calendar/edit/test_calendar/',
|
| |
- data=data, follow_redirects=True)
|
| |
- self.assertEqual(output.status_code, 200)
|
| |
- output_text = output.get_data(as_text=True)
|
| |
- self.assertIn(
|
| |
- '<title>Election1 - Fedocal</title>', output_text)
|
| |
- self.assertIn(
|
| |
- '<li class="message">Calendar updated</li>',
|
| |
- output_text)
|
| |
- self.assertNotIn(
|
| |
- '<span class="calendar_name">test_calendar</span>',
|
| |
- output_text)
|
| |
- self.assertNotIn(
|
| |
- '<span class="calendar_name">election1</span>',
|
| |
- output_text)
|
| |
+ with testing.mock_sends(schema.CalendarUpdateV1(
|
| |
+ topic="fedocal.calendar.update",
|
| |
+ body={
|
| |
+ 'agent': 'kevin',
|
| |
+ 'calendar': {
|
| |
+ 'calendar_name': 'Election1',
|
| |
+ 'calendar_contact': 'election1',
|
| |
+ 'calendar_description': '',
|
| |
+ 'calendar_editor_group': '',
|
| |
+ 'calendar_admin_group': '',
|
| |
+ 'calendar_status': 'Enabled'
|
| |
+ }
|
| |
+ }
|
| |
+ )):
|
| |
+ output = self.app.post('/calendar/edit/test_calendar/',
|
| |
+ data=data, follow_redirects=True)
|
| |
+ self.assertEqual(output.status_code, 200)
|
| |
+ output_text = output.get_data(as_text=True)
|
| |
+ self.assertIn(
|
| |
+ '<title>Election1 - Fedocal</title>', output_text)
|
| |
+ self.assertIn(
|
| |
+ '<li class="message">Calendar updated</li>',
|
| |
+ output_text)
|
| |
+ self.assertNotIn(
|
| |
+ '<span class="calendar_name">test_calendar</span>',
|
| |
+ output_text)
|
| |
+ self.assertNotIn(
|
| |
+ '<span class="calendar_name">election1</span>',
|
| |
+ output_text)
|
| |
|
| |
- @flask10_only
|
| |
def test_auth_logout(self):
|
| |
""" Test the auth_logout function. """
|
| |
user = FakeUser(fedocal.APP.config['ADMIN_GROUP'])
|
| |
@@ -1362,7 +1408,6 @@
|
| |
'<li class="message">You have been logged out</li>',
|
| |
output_text)
|
| |
|
| |
- @flask10_only
|
| |
def test_my_meetings(self):
|
| |
""" Test the my_meetings function. """
|
| |
self.__setup_db()
|
| |
@@ -1397,7 +1442,6 @@
|
| |
self.assertIn(
|
| |
'<td> Test meeting with reminder </td>', output_text)
|
| |
|
| |
- @flask10_only
|
| |
def test_add_meeting(self):
|
| |
""" Test the add_meeting function. """
|
| |
self.__setup_db()
|
| |
@@ -1550,16 +1594,43 @@
|
| |
'csrf_token': csrf_token,
|
| |
}
|
| |
|
| |
- output = self.app.post('/test_calendar/add/', data=data,
|
| |
- follow_redirects=True)
|
| |
- self.assertEqual(output.status_code, 200)
|
| |
- output_text = output.get_data(as_text=True)
|
| |
- self.assertIn(
|
| |
- '<li class="message">Meeting added</li>', output_text)
|
| |
- self.assertIn(
|
| |
- 'href="/meeting/16/?from_date=', output_text)
|
| |
- self.assertNotIn(
|
| |
- 'href="/meeting/17/?from_date=', output_text)
|
| |
+ with testing.mock_sends(schema.MeetingNewV1(
|
| |
+ topic="fedocal.meeting.new",
|
| |
+ body={
|
| |
+ 'agent': 'pingou',
|
| |
+ 'meeting': {
|
| |
+ 'meeting_id': 16,
|
| |
+ 'meeting_name': 'guess what?',
|
| |
+ 'meeting_manager': ['pingou'],
|
| |
+ 'meeting_date': TODAY.strftime('%Y-%m-%d'),
|
| |
+ 'meeting_date_end': TODAY.strftime('%Y-%m-%d'),
|
| |
+ 'meeting_time_start': '13:00:00',
|
| |
+ 'meeting_time_stop': '14:00:00',
|
| |
+ 'meeting_timezone': 'Europe/Paris',
|
| |
+ 'meeting_information': '',
|
| |
+ 'meeting_location': '',
|
| |
+ 'calendar_name': 'test_calendar'
|
| |
+ },
|
| |
+ 'calendar': {
|
| |
+ 'calendar_name': 'test_calendar',
|
| |
+ 'calendar_contact': 'test@example.com',
|
| |
+ 'calendar_description': 'This is a test calendar',
|
| |
+ 'calendar_editor_group': 'fi-apprentice',
|
| |
+ 'calendar_admin_group': 'infrastructure-main2',
|
| |
+ 'calendar_status': 'Enabled'
|
| |
+ }
|
| |
+ }
|
| |
+ )):
|
| |
+ output = self.app.post('/test_calendar/add/', data=data,
|
| |
+ follow_redirects=True)
|
| |
+ self.assertEqual(output.status_code, 200)
|
| |
+ output_text = output.get_data(as_text=True)
|
| |
+ self.assertIn(
|
| |
+ '<li class="message">Meeting added</li>', output_text)
|
| |
+ self.assertIn(
|
| |
+ 'href="/meeting/16/?from_date=', output_text)
|
| |
+ self.assertNotIn(
|
| |
+ 'href="/meeting/17/?from_date=', output_text)
|
| |
|
| |
# Works - with a wiki_link
|
| |
data = {
|
| |
@@ -1573,16 +1644,17 @@
|
| |
'csrf_token': csrf_token,
|
| |
}
|
| |
|
| |
- output = self.app.post('/test_calendar/add/', data=data,
|
| |
- follow_redirects=True)
|
| |
- self.assertEqual(output.status_code, 200)
|
| |
- output_text = output.get_data(as_text=True)
|
| |
- self.assertIn(
|
| |
- '<li class="message">Meeting added</li>', output_text)
|
| |
- self.assertIn(
|
| |
- 'href="/meeting/17/?from_date=', output_text)
|
| |
- self.assertNotIn(
|
| |
- 'href="/meeting/18/?from_date=', output_text)
|
| |
+ with testing.mock_sends(schema.MeetingNewV1):
|
| |
+ output = self.app.post('/test_calendar/add/', data=data,
|
| |
+ follow_redirects=True)
|
| |
+ self.assertEqual(output.status_code, 200)
|
| |
+ output_text = output.get_data(as_text=True)
|
| |
+ self.assertIn(
|
| |
+ '<li class="message">Meeting added</li>', output_text)
|
| |
+ self.assertIn(
|
| |
+ 'href="/meeting/17/?from_date=', output_text)
|
| |
+ self.assertNotIn(
|
| |
+ 'href="/meeting/18/?from_date=', output_text)
|
| |
|
| |
# Calendar disabled
|
| |
data = {
|
| |
@@ -1615,8 +1687,8 @@
|
| |
'meeting_time_stop': time(14, 0),
|
| |
'meeting_timezone': 'Europe/Paris',
|
| |
'frequency': '',
|
| |
- 'reminder_from': 'pingou@fp.o',
|
| |
- 'reminder_who': 'pingou@fp.org',
|
| |
+ 'reminder_from': 'pingou@fp',
|
| |
+ 'remind_who': 'pingou@fp.org',
|
| |
'remind_when': 'H-12',
|
| |
'csrf_token': csrf_token,
|
| |
}
|
| |
@@ -1640,7 +1712,7 @@
|
| |
'meeting_timezone': 'Europe/Paris',
|
| |
'frequency': '',
|
| |
'reminder_from': 'pingou@fp.o',
|
| |
- 'reminder_who': 'pingou@fp.org, pingou@fp.o',
|
| |
+ 'remind_who': 'pingou@fp.org, pingou@fp',
|
| |
'remind_when': 'H-12',
|
| |
'csrf_token': csrf_token,
|
| |
}
|
| |
@@ -1652,7 +1724,8 @@
|
| |
self.assertIn(
|
| |
'<h2>New meeting</h2>', output_text)
|
| |
self.assertIn(
|
| |
- '<td>Invalid email address.</td>', output_text)
|
| |
+ '<td>The domain name fp is not valid. It should have a period.</td>',
|
| |
+ output_text)
|
| |
|
| |
# Works - with one email as recipient of the reminder
|
| |
data = {
|
| |
@@ -1663,25 +1736,26 @@
|
| |
'meeting_timezone': 'Europe/Paris',
|
| |
'frequency': '',
|
| |
'reminder_from': 'pingou@fp.org',
|
| |
- 'reminder_who': 'pingou@fp.org',
|
| |
+ 'remind_who': 'pingou@fp.org',
|
| |
'remind_when': 'H-12',
|
| |
'csrf_token': csrf_token,
|
| |
}
|
| |
|
| |
- output = self.app.post('/test_calendar/add/', data=data,
|
| |
- follow_redirects=True)
|
| |
- self.assertEqual(output.status_code, 200)
|
| |
- output_text = output.get_data(as_text=True)
|
| |
- self.assertIn(
|
| |
- '<li class="message">Meeting added</li>', output_text)
|
| |
- self.assertIn(
|
| |
- 'href="/meeting/17/?from_date=', output_text)
|
| |
- self.assertIn(
|
| |
- 'href="/meeting/18/?from_date=', output_text)
|
| |
- self.assertIn(
|
| |
- 'Reminder', output_text)
|
| |
- self.assertNotIn(
|
| |
- 'href="/meeting/19/?from_date=', output_text)
|
| |
+ with testing.mock_sends(schema.MeetingNewV1):
|
| |
+ output = self.app.post('/test_calendar/add/', data=data,
|
| |
+ follow_redirects=True)
|
| |
+ self.assertEqual(output.status_code, 200)
|
| |
+ output_text = output.get_data(as_text=True)
|
| |
+ self.assertIn(
|
| |
+ '<li class="message">Meeting added</li>', output_text)
|
| |
+ self.assertIn(
|
| |
+ 'href="/meeting/17/?from_date=', output_text)
|
| |
+ self.assertIn(
|
| |
+ 'href="/meeting/18/?from_date=', output_text)
|
| |
+ self.assertIn(
|
| |
+ 'Reminder', output_text)
|
| |
+ self.assertNotIn(
|
| |
+ 'href="/meeting/19/?from_date=', output_text)
|
| |
|
| |
# Works - with two emails as recipient of the reminder
|
| |
data = {
|
| |
@@ -1692,27 +1766,27 @@
|
| |
'meeting_timezone': 'Europe/Paris',
|
| |
'frequency': '',
|
| |
'reminder_from': 'pingou@fp.org',
|
| |
- 'reminder_who': 'pingou@fp.org,pingou@p.fr',
|
| |
+ 'remind_who': 'pingou@fp.org,pingou@p.fr',
|
| |
'remind_when': 'H-12',
|
| |
'csrf_token': csrf_token,
|
| |
}
|
| |
|
| |
- output = self.app.post('/test_calendar/add/', data=data,
|
| |
- follow_redirects=True)
|
| |
- self.assertEqual(output.status_code, 200)
|
| |
- output_text = output.get_data(as_text=True)
|
| |
- self.assertIn(
|
| |
- '<li class="message">Meeting added</li>', output_text)
|
| |
- self.assertIn(
|
| |
- 'href="/meeting/18/?from_date=', output_text)
|
| |
- self.assertIn(
|
| |
- 'href="/meeting/19/?from_date=', output_text)
|
| |
- self.assertIn(
|
| |
- 'Reminder2', output_text)
|
| |
- self.assertNotIn(
|
| |
- 'href="/meeting/20/?from_date=', output_text)
|
| |
+ with testing.mock_sends(schema.MeetingNewV1):
|
| |
+ output = self.app.post('/test_calendar/add/', data=data,
|
| |
+ follow_redirects=True)
|
| |
+ self.assertEqual(output.status_code, 200)
|
| |
+ output_text = output.get_data(as_text=True)
|
| |
+ self.assertIn(
|
| |
+ '<li class="message">Meeting added</li>', output_text)
|
| |
+ self.assertIn(
|
| |
+ 'href="/meeting/18/?from_date=', output_text)
|
| |
+ self.assertIn(
|
| |
+ 'href="/meeting/19/?from_date=', output_text)
|
| |
+ self.assertIn(
|
| |
+ 'Reminder2', output_text)
|
| |
+ self.assertNotIn(
|
| |
+ 'href="/meeting/20/?from_date=', output_text)
|
| |
|
| |
- @flask10_only
|
| |
def test_edit_meeting(self):
|
| |
""" Test the edit_meeting function. """
|
| |
self.__setup_db()
|
| |
@@ -1801,7 +1875,7 @@
|
| |
self.assertEqual(output.status_code, 200)
|
| |
output_text = output.get_data(as_text=True)
|
| |
self.assertIn(
|
| |
- '<td>Not a valid choice</td>', output_text)
|
| |
+ '<td>This field is required.</td>', output_text)
|
| |
self.assertIn(
|
| |
'<title>Edit meeting - Fedocal</title>', output_text)
|
| |
|
| |
@@ -1840,14 +1914,41 @@
|
| |
'csrf_token': csrf_token,
|
| |
}
|
| |
|
| |
- output = self.app.post('/meeting/edit/1/', data=data,
|
| |
- follow_redirects=True)
|
| |
- self.assertEqual(output.status_code, 200)
|
| |
- output_text = output.get_data(as_text=True)
|
| |
- self.assertIn(
|
| |
- '<li class="message">Meeting updated</li>', output_text)
|
| |
- self.assertIn(
|
| |
- '<title>Meeting "guess what?" - Fedocal</title>', output_text)
|
| |
+ with testing.mock_sends(schema.MeetingUpdateV1(
|
| |
+ topic="fedocal.meeting.update",
|
| |
+ body={
|
| |
+ 'agent': 'pingou',
|
| |
+ 'meeting': {
|
| |
+ 'meeting_id': 1,
|
| |
+ 'meeting_name': 'guess what?',
|
| |
+ 'meeting_manager': ['pingou'],
|
| |
+ 'meeting_date': TODAY.strftime('%Y-%m-%d'),
|
| |
+ 'meeting_date_end': TODAY.strftime('%Y-%m-%d'),
|
| |
+ 'meeting_time_start': '13:00:00',
|
| |
+ 'meeting_time_stop': '14:00:00',
|
| |
+ 'meeting_timezone': 'Europe/Paris',
|
| |
+ 'meeting_information': '',
|
| |
+ 'meeting_location': None,
|
| |
+ 'calendar_name': 'test_calendar'
|
| |
+ },
|
| |
+ 'calendar': {
|
| |
+ 'calendar_name': 'test_calendar',
|
| |
+ 'calendar_contact': 'test@example.com',
|
| |
+ 'calendar_description': 'This is a test calendar',
|
| |
+ 'calendar_editor_group': 'fi-apprentice',
|
| |
+ 'calendar_admin_group': 'infrastructure-main2',
|
| |
+ 'calendar_status': 'Enabled'
|
| |
+ }
|
| |
+ }
|
| |
+ )):
|
| |
+ output = self.app.post('/meeting/edit/1/', data=data,
|
| |
+ follow_redirects=True)
|
| |
+ self.assertEqual(output.status_code, 200)
|
| |
+ output_text = output.get_data(as_text=True)
|
| |
+ self.assertIn(
|
| |
+ '<li class="message">Meeting updated</li>', output_text)
|
| |
+ self.assertIn(
|
| |
+ '<title>Meeting "guess what?" - Fedocal</title>', output_text)
|
| |
|
| |
# Calendar disabled
|
| |
data = {
|
| |
@@ -1883,6 +1984,8 @@
|
| |
meeting_information='Full day meeting 2',
|
| |
calendar_name='test_calendar_disabled',
|
| |
full_day=True)
|
| |
+ self.session.add(obj)
|
| |
+ self.session.flush()
|
| |
obj.add_manager(self.session, ['toshio'])
|
| |
obj.save(self.session)
|
| |
self.session.commit()
|
| |
@@ -1950,7 +2053,6 @@
|
| |
self.assertEqual(
|
| |
output_text.count('<span class="required">*</span>'), 6)
|
| |
|
| |
- @flask10_only
|
| |
def test_delete_meeting(self):
|
| |
""" Test the delete_meeting function. """
|
| |
self.__setup_db()
|
| |
@@ -2047,14 +2149,41 @@
|
| |
'csrf_token': csrf_token,
|
| |
}
|
| |
|
| |
- output = self.app.post('/meeting/delete/1/', data=data,
|
| |
- follow_redirects=True)
|
| |
- self.assertEqual(output.status_code, 200)
|
| |
- output_text = output.get_data(as_text=True)
|
| |
- self.assertIn(
|
| |
- '<title>test_calendar - Fedocal</title>', output_text)
|
| |
- self.assertIn(
|
| |
- '<li class="message">Meeting deleted</li>', output_text)
|
| |
+ with testing.mock_sends(schema.MeetingDeleteV1(
|
| |
+ topic="fedocal.meeting.delete",
|
| |
+ body={
|
| |
+ 'agent': 'pingou',
|
| |
+ 'meeting': {
|
| |
+ 'meeting_id': 1,
|
| |
+ 'meeting_name': 'Fedora-fr-test-meeting',
|
| |
+ 'meeting_manager': [],
|
| |
+ 'meeting_date': TODAY.strftime('%Y-%m-%d'),
|
| |
+ 'meeting_date_end': TODAY.strftime('%Y-%m-%d'),
|
| |
+ 'meeting_time_start': '19:50:00',
|
| |
+ 'meeting_time_stop': '20:50:00',
|
| |
+ 'meeting_timezone': 'UTC',
|
| |
+ 'meeting_information': 'This is a test meeting',
|
| |
+ 'meeting_location': None,
|
| |
+ 'calendar_name': 'test_calendar'
|
| |
+ },
|
| |
+ 'calendar': {
|
| |
+ 'calendar_name': 'test_calendar',
|
| |
+ 'calendar_contact': 'test@example.com',
|
| |
+ 'calendar_description': 'This is a test calendar',
|
| |
+ 'calendar_editor_group': 'fi-apprentice',
|
| |
+ 'calendar_admin_group': 'infrastructure-main2',
|
| |
+ 'calendar_status': 'Enabled'
|
| |
+ }
|
| |
+ }
|
| |
+ )):
|
| |
+ output = self.app.post('/meeting/delete/1/', data=data,
|
| |
+ follow_redirects=True)
|
| |
+ self.assertEqual(output.status_code, 200)
|
| |
+ output_text = output.get_data(as_text=True)
|
| |
+ self.assertIn(
|
| |
+ '<title>test_calendar - Fedocal</title>', output_text)
|
| |
+ self.assertIn(
|
| |
+ '<li class="message">Meeting deleted</li>', output_text)
|
| |
|
| |
# Delete all
|
| |
data = {
|
| |
@@ -2063,14 +2192,15 @@
|
| |
'csrf_token': csrf_token,
|
| |
}
|
| |
|
| |
- output = self.app.post('/meeting/delete/8/', data=data,
|
| |
- follow_redirects=True)
|
| |
- self.assertEqual(output.status_code, 200)
|
| |
- output_text = output.get_data(as_text=True)
|
| |
- self.assertIn(
|
| |
- '<title>test_calendar - Fedocal</title>', output_text)
|
| |
- self.assertIn(
|
| |
- '<li class="message">Meeting deleted</li>', output_text)
|
| |
+ with testing.mock_sends(schema.MeetingDeleteV1):
|
| |
+ output = self.app.post('/meeting/delete/8/', data=data,
|
| |
+ follow_redirects=True)
|
| |
+ self.assertEqual(output.status_code, 200)
|
| |
+ output_text = output.get_data(as_text=True)
|
| |
+ self.assertIn(
|
| |
+ '<title>test_calendar - Fedocal</title>', output_text)
|
| |
+ self.assertIn(
|
| |
+ '<li class="message">Meeting deleted</li>', output_text)
|
| |
|
| |
# Add a meeting to the test_calendar_disabled calendar
|
| |
obj = model.Meeting( # id:16
|
| |
@@ -2082,6 +2212,8 @@
|
| |
meeting_information='Full day meeting 2',
|
| |
calendar_name='test_calendar_disabled',
|
| |
full_day=True)
|
| |
+ self.session.add(obj)
|
| |
+ self.session.flush()
|
| |
obj.add_manager(self.session, ['toshio'])
|
| |
obj.save(self.session)
|
| |
self.session.commit()
|
| |
@@ -2289,7 +2421,6 @@
|
| |
self.assertIn(
|
| |
'<p>This is a test calendar</p>', output_text)
|
| |
|
| |
- @flask10_only
|
| |
def test_upload_calendar(self):
|
| |
""" Test the upload_calendar function. """
|
| |
self.__setup_db()
|
| |
@@ -2334,24 +2465,38 @@
|
| |
'enctype': 'multipart/form-data',
|
| |
'csrf_token': csrf_token,
|
| |
}
|
| |
- output = self.app.post('/calendar/upload/test_calendar/',
|
| |
- follow_redirects=True, data=data)
|
| |
- self.assertEqual(output.status_code, 200)
|
| |
- output_text = output.get_data(as_text=True)
|
| |
- if '<li class="error">' not in output_text:
|
| |
- self.assertIn(
|
| |
- '<title>test_calendar - Fedocal</title>',
|
| |
- output_text)
|
| |
- self.assertIn(
|
| |
- '<p>This is a test calendar</p>', output_text)
|
| |
- self.assertIn(
|
| |
- 'li class="message">Calendar uploaded</li>',
|
| |
- output_text)
|
| |
- else:
|
| |
- self.assertIn(
|
| |
- '<li class="error">The submitted candidate has the '
|
| |
- 'MIME type "application/octet-stream" which '
|
| |
- 'is not an allowed MIME type</li>', output_text)
|
| |
+ with testing.mock_sends(schema.CalendarUploadV1(
|
| |
+ topic="fedocal.calendar.upload",
|
| |
+ body={
|
| |
+ 'agent': 'kevin',
|
| |
+ 'calendar': {
|
| |
+ 'calendar_name': 'test_calendar',
|
| |
+ 'calendar_contact': 'test@example.com',
|
| |
+ 'calendar_description': 'This is a test calendar',
|
| |
+ 'calendar_editor_group': 'fi-apprentice',
|
| |
+ 'calendar_admin_group': 'infrastructure-main2',
|
| |
+ 'calendar_status': 'Enabled'
|
| |
+ }
|
| |
+ }
|
| |
+ )):
|
| |
+ output = self.app.post('/calendar/upload/test_calendar/',
|
| |
+ follow_redirects=True, data=data)
|
| |
+ self.assertEqual(output.status_code, 200)
|
| |
+ output_text = output.get_data(as_text=True)
|
| |
+ if '<li class="error">' not in output_text:
|
| |
+ self.assertIn(
|
| |
+ '<title>test_calendar - Fedocal</title>',
|
| |
+ output_text)
|
| |
+ self.assertIn(
|
| |
+ '<p>This is a test calendar</p>', output_text)
|
| |
+ self.assertIn(
|
| |
+ 'li class="message">Calendar uploaded</li>',
|
| |
+ output_text)
|
| |
+ else:
|
| |
+ self.assertIn(
|
| |
+ '<li class="error">The submitted candidate has the '
|
| |
+ 'MIME type "application/octet-stream" which '
|
| |
+ 'is not an allowed MIME type</li>', output_text)
|
| |
|
| |
with open(ICS_FILE_NOTOK, 'rb') as stream:
|
| |
data = {
|
| |
@@ -2371,7 +2516,6 @@
|
| |
'extension "txt" which is not an allowed '
|
| |
'format</li>', output_text)
|
| |
|
| |
- @flask10_only
|
| |
def test_markdown_preview(self):
|
| |
""" Test the markdown_preview function. """
|
| |
user = FakeUser(['gitr2spec'], username='kevin')
|
| |