@@ -260,7 +260,6 @@ def test_proceedings(self):
260260 self .write_materials_files (meeting , session )
261261
262262 url = urlreverse ("ietf.meeting.views.proceedings" , kwargs = dict (num = meeting .number ))
263- login_testing_unauthorized (self ,"secretary" ,url )
264263 r = self .client .get (url )
265264 self .assertEqual (r .status_code , 200 )
266265
@@ -1271,7 +1270,7 @@ def test_finalize_proceedings(self):
12711270 self .assertEqual (meeting .proceedings_final ,True )
12721271 self .assertEqual (meeting .session_set .filter (group__acronym = "mars" ).first ().sessionpresentation_set .filter (document__type = "draft" ).first ().rev ,'00' )
12731272
1274- class BluesheetsTests (TestCase ):
1273+ class MaterialsTests (TestCase ):
12751274
12761275 def setUp (self ):
12771276 self .materials_dir = os .path .abspath (settings .TEST_MATERIALS_DIR )
@@ -1284,14 +1283,14 @@ def tearDown(self):
12841283 settings .AGENDA_PATH = self .saved_agenda_path
12851284 shutil .rmtree (self .materials_dir )
12861285
1287- def test_upload_blusheets (self ):
1286+ def test_upload_bluesheets (self ):
12881287 session = SessionFactory (meeting__type_id = 'ietf' )
12891288 url = urlreverse ('ietf.meeting.views.upload_session_bluesheets' ,kwargs = {'num' :session .meeting .number ,'session_id' :session .id })
12901289 login_testing_unauthorized (self ,"secretary" ,url )
12911290 r = self .client .get (url )
12921291 self .assertEqual (r .status_code , 200 )
12931292 q = PyQuery (r .content )
1294- self .assertFalse ( q ("div.alert" ))
1293+ self .assertTrue ( 'Upload' in unicode ( q ("title" ) ))
12951294 self .assertFalse (session .sessionpresentation_set .exists ())
12961295 test_file = StringIO ('this is some text for a test' )
12971296 test_file .name = "not_really.pdf"
@@ -1302,7 +1301,7 @@ def test_upload_blusheets(self):
13021301 r = self .client .get (url )
13031302 self .assertEqual (r .status_code , 200 )
13041303 q = PyQuery (r .content )
1305- self .assertTrue (q ("div.alert" ))
1304+ self .assertTrue ('Revise' in unicode ( q ("title" ) ))
13061305 test_file = StringIO ('this is some different text for a test' )
13071306 test_file .name = "also_not_really.pdf"
13081307 r = self .client .post (url ,dict (file = test_file ))
@@ -1317,11 +1316,160 @@ def test_upload_bluesheets_interim(self):
13171316 r = self .client .get (url )
13181317 self .assertEqual (r .status_code , 200 )
13191318 q = PyQuery (r .content )
1320- self .assertFalse ( q ("div.alert" ))
1319+ self .assertTrue ( 'Upload' in unicode ( q ("title" ) ))
13211320 self .assertFalse (session .sessionpresentation_set .exists ())
13221321 test_file = StringIO ('this is some text for a test' )
13231322 test_file .name = "not_really.pdf"
13241323 r = self .client .post (url ,dict (file = test_file ))
13251324 self .assertEqual (r .status_code , 302 )
13261325 bs_doc = session .sessionpresentation_set .filter (document__type_id = 'bluesheets' ).first ().document
13271326 self .assertEqual (bs_doc .rev ,'00' )
1327+
1328+ def test_upload_minutes_agenda (self ):
1329+ for doctype in ('minutes' ,'agenda' ):
1330+ session = SessionFactory (meeting__type_id = 'ietf' )
1331+ if doctype == 'minutes' :
1332+ url = urlreverse ('ietf.meeting.views.upload_session_minutes' ,kwargs = {'num' :session .meeting .number ,'session_id' :session .id })
1333+ else :
1334+ url = urlreverse ('ietf.meeting.views.upload_session_agenda' ,kwargs = {'num' :session .meeting .number ,'session_id' :session .id })
1335+ self .client .logout ()
1336+ login_testing_unauthorized (self ,"secretary" ,url )
1337+ r = self .client .get (url )
1338+ self .assertEqual (r .status_code , 200 )
1339+ q = PyQuery (r .content )
1340+ self .assertTrue ('Upload' in unicode (q ("Title" )))
1341+ self .assertFalse (session .sessionpresentation_set .exists ())
1342+ self .assertFalse (q ('form input[type="checkbox"]' ))
1343+
1344+ session2 = SessionFactory (meeting = session .meeting ,group = session .group )
1345+ r = self .client .get (url )
1346+ self .assertEqual (r .status_code , 200 )
1347+ q = PyQuery (r .content )
1348+ self .assertTrue (q ('form input[type="checkbox"]' ))
1349+
1350+ test_file = StringIO ('this is some text for a test' )
1351+ test_file .name = "not_really.json"
1352+ r = self .client .post (url ,dict (file = test_file ))
1353+ self .assertEqual (r .status_code , 200 )
1354+ q = PyQuery (r .content )
1355+ self .assertTrue (q ('form .has-error' ))
1356+
1357+ test_file = StringIO ('this is some text for a test' * 1510000 )
1358+ test_file .name = "not_really.pdf"
1359+ r = self .client .post (url ,dict (file = test_file ))
1360+ self .assertEqual (r .status_code , 200 )
1361+ q = PyQuery (r .content )
1362+ self .assertTrue (q ('form .has-error' ))
1363+
1364+ test_file = StringIO ('this is some text for a test' )
1365+ test_file .name = "not_really.txt"
1366+ r = self .client .post (url ,dict (file = test_file ,apply_to_all = False ))
1367+ self .assertEqual (r .status_code , 302 )
1368+ doc = session .sessionpresentation_set .filter (document__type_id = doctype ).first ().document
1369+ self .assertEqual (doc .rev ,'00' )
1370+ self .assertFalse (session2 .sessionpresentation_set .filter (document__type_id = doctype ))
1371+
1372+ r = self .client .get (url )
1373+ self .assertEqual (r .status_code , 200 )
1374+ q = PyQuery (r .content )
1375+ self .assertTrue ('Revise' in unicode (q ("Title" )))
1376+ test_file = StringIO ('this is some different text for a test' )
1377+ test_file .name = "also_not_really.txt"
1378+ r = self .client .post (url ,dict (file = test_file ,apply_to_all = True ))
1379+ self .assertEqual (r .status_code , 302 )
1380+ doc = Document .objects .get (pk = doc .pk )
1381+ self .assertEqual (doc .rev ,'01' )
1382+ self .assertTrue (session2 .sessionpresentation_set .filter (document__type_id = doctype ))
1383+
1384+ def test_upload_minutes_agenda_interim (self ):
1385+ session = SessionFactory (meeting__type_id = 'interim' )
1386+ for doctype in ('minutes' ,'agenda' ):
1387+ if doctype == 'minutes' :
1388+ url = urlreverse ('ietf.meeting.views.upload_session_minutes' ,kwargs = {'num' :session .meeting .number ,'session_id' :session .id })
1389+ else :
1390+ url = urlreverse ('ietf.meeting.views.upload_session_agenda' ,kwargs = {'num' :session .meeting .number ,'session_id' :session .id })
1391+ self .client .logout ()
1392+ login_testing_unauthorized (self ,"secretary" ,url )
1393+ r = self .client .get (url )
1394+ self .assertEqual (r .status_code , 200 )
1395+ q = PyQuery (r .content )
1396+ self .assertTrue ('Upload' in unicode (q ("title" )))
1397+ self .assertFalse (session .sessionpresentation_set .filter (document__type_id = doctype ))
1398+ test_file = StringIO ('this is some text for a test' )
1399+ test_file .name = "not_really.txt"
1400+ r = self .client .post (url ,dict (file = test_file ))
1401+ self .assertEqual (r .status_code , 302 )
1402+ doc = session .sessionpresentation_set .filter (document__type_id = doctype ).first ().document
1403+ self .assertEqual (doc .rev ,'00' )
1404+
1405+ def test_upload_slides (self ):
1406+
1407+ session1 = SessionFactory (meeting__type_id = 'ietf' )
1408+ session2 = SessionFactory (meeting = session1 .meeting ,group = session1 .group )
1409+ url = urlreverse ('ietf.meeting.views.upload_session_slides' ,kwargs = {'num' :session1 .meeting .number ,'session_id' :session1 .id })
1410+ login_testing_unauthorized (self ,"secretary" ,url )
1411+ r = self .client .get (url )
1412+ self .assertEqual (r .status_code , 200 )
1413+ q = PyQuery (r .content )
1414+ self .assertTrue ('Upload' in unicode (q ("title" )))
1415+ self .assertFalse (session1 .sessionpresentation_set .filter (document__type_id = 'slides' ))
1416+ test_file = StringIO ('this is not really a slide' )
1417+ test_file .name = 'not_really.txt'
1418+ r = self .client .post (url ,dict (file = test_file ,title = 'a test slide file' ,apply_to_all = True ))
1419+ self .assertEqual (r .status_code , 302 )
1420+ self .assertEqual (session1 .sessionpresentation_set .count (),1 )
1421+ self .assertEqual (session2 .sessionpresentation_set .count (),1 )
1422+ sp = session2 .sessionpresentation_set .first ()
1423+ self .assertEqual (sp .document .name , 'slides-%s-%s-a-test-slide-file' % (session1 .meeting .number ,session1 .group .acronym ) )
1424+ self .assertEqual (sp .order ,1 )
1425+
1426+ url = urlreverse ('ietf.meeting.views.upload_session_slides' ,kwargs = {'num' :session2 .meeting .number ,'session_id' :session2 .id })
1427+ test_file = StringIO ('some other thing still not slidelike' )
1428+ test_file .name = 'also_not_really.txt'
1429+ r = self .client .post (url ,dict (file = test_file ,title = 'a different slide file' ,apply_to_all = False ))
1430+ self .assertEqual (r .status_code , 302 )
1431+ self .assertEqual (session1 .sessionpresentation_set .count (),1 )
1432+ self .assertEqual (session2 .sessionpresentation_set .count (),2 )
1433+ sp = session2 .sessionpresentation_set .get (document__name__endswith = '-a-different-slide-file' )
1434+ self .assertEqual (sp .order ,2 )
1435+ self .assertEqual (sp .rev ,u'00' )
1436+ self .assertEqual (sp .document .rev ,u'00' )
1437+
1438+ url = urlreverse ('ietf.meeting.views.upload_session_slides' ,kwargs = {'num' :session2 .meeting .number ,'session_id' :session2 .id ,'name' :session2 .sessionpresentation_set .get (order = 2 ).document .name })
1439+ r = self .client .get (url )
1440+ self .assertTrue (r .status_code , 200 )
1441+ q = PyQuery (r .content )
1442+ self .assertTrue ('Revise' in unicode (q ("title" )))
1443+ test_file = StringIO ('new content for the second slide deck' )
1444+ test_file .name = 'doesnotmatter.txt'
1445+ r = self .client .post (url ,dict (file = test_file ,title = 'rename the presentation' ,apply_to_all = False ))
1446+ self .assertEqual (r .status_code , 302 )
1447+ self .assertEqual (session1 .sessionpresentation_set .count (),1 )
1448+ self .assertEqual (session2 .sessionpresentation_set .count (),2 )
1449+ sp = session2 .sessionpresentation_set .get (order = 2 )
1450+ self .assertEqual (sp .rev ,u'01' )
1451+ self .assertEqual (sp .document .rev ,u'01' )
1452+
1453+ def test_remove_sessionpresentation (self ):
1454+ session = SessionFactory (meeting__type_id = 'ietf' )
1455+ doc = DocumentFactory (type_id = 'slides' )
1456+ session .sessionpresentation_set .create (document = doc )
1457+
1458+ url = urlreverse ('ietf.meeting.views.remove_sessionpresentation' ,kwargs = {'num' :session .meeting .number ,'session_id' :session .id ,'name' :'no-such-doc' })
1459+ response = self .client .get (url )
1460+ self .assertEqual (response .status_code , 404 )
1461+
1462+ url = urlreverse ('ietf.meeting.views.remove_sessionpresentation' ,kwargs = {'num' :session .meeting .number ,'session_id' :0 ,'name' :doc .name })
1463+ response = self .client .get (url )
1464+ self .assertEqual (response .status_code , 404 )
1465+
1466+ url = urlreverse ('ietf.meeting.views.remove_sessionpresentation' ,kwargs = {'num' :session .meeting .number ,'session_id' :session .id ,'name' :doc .name })
1467+ login_testing_unauthorized (self ,"secretary" ,url )
1468+ response = self .client .get (url )
1469+ self .assertEqual (response .status_code , 200 )
1470+
1471+ self .assertEqual (1 ,session .sessionpresentation_set .count ())
1472+ response = self .client .post (url ,{'remove_session' :'' })
1473+ self .assertEqual (response .status_code , 302 )
1474+ self .assertEqual (0 ,session .sessionpresentation_set .count ())
1475+ self .assertEqual (2 ,doc .docevent_set .count ())
0 commit comments