@@ -1271,7 +1271,7 @@ def test_finalize_proceedings(self):
12711271 self .assertEqual (meeting .proceedings_final ,True )
12721272 self .assertEqual (meeting .session_set .filter (group__acronym = "mars" ).first ().sessionpresentation_set .filter (document__type = "draft" ).first ().rev ,'00' )
12731273
1274- class BluesheetsTests (TestCase ):
1274+ class MaterialsTests (TestCase ):
12751275
12761276 def setUp (self ):
12771277 self .materials_dir = os .path .abspath (settings .TEST_MATERIALS_DIR )
@@ -1284,14 +1284,14 @@ def tearDown(self):
12841284 settings .AGENDA_PATH = self .saved_agenda_path
12851285 shutil .rmtree (self .materials_dir )
12861286
1287- def test_upload_blusheets (self ):
1287+ def test_upload_bluesheets (self ):
12881288 session = SessionFactory (meeting__type_id = 'ietf' )
12891289 url = urlreverse ('ietf.meeting.views.upload_session_bluesheets' ,kwargs = {'num' :session .meeting .number ,'session_id' :session .id })
12901290 login_testing_unauthorized (self ,"secretary" ,url )
12911291 r = self .client .get (url )
12921292 self .assertEqual (r .status_code , 200 )
12931293 q = PyQuery (r .content )
1294- self .assertFalse ( q ("div.alert" ))
1294+ self .assertTrue ( 'Upload' in unicode ( q ("title" ) ))
12951295 self .assertFalse (session .sessionpresentation_set .exists ())
12961296 test_file = StringIO ('this is some text for a test' )
12971297 test_file .name = "not_really.pdf"
@@ -1302,7 +1302,7 @@ def test_upload_blusheets(self):
13021302 r = self .client .get (url )
13031303 self .assertEqual (r .status_code , 200 )
13041304 q = PyQuery (r .content )
1305- self .assertTrue (q ("div.alert" ))
1305+ self .assertTrue ('Revise' in unicode ( q ("title" ) ))
13061306 test_file = StringIO ('this is some different text for a test' )
13071307 test_file .name = "also_not_really.pdf"
13081308 r = self .client .post (url ,dict (file = test_file ))
@@ -1317,11 +1317,137 @@ def test_upload_bluesheets_interim(self):
13171317 r = self .client .get (url )
13181318 self .assertEqual (r .status_code , 200 )
13191319 q = PyQuery (r .content )
1320- self .assertFalse ( q ("div.alert" ))
1320+ self .assertTrue ( 'Upload' in unicode ( q ("title" ) ))
13211321 self .assertFalse (session .sessionpresentation_set .exists ())
13221322 test_file = StringIO ('this is some text for a test' )
13231323 test_file .name = "not_really.pdf"
13241324 r = self .client .post (url ,dict (file = test_file ))
13251325 self .assertEqual (r .status_code , 302 )
13261326 bs_doc = session .sessionpresentation_set .filter (document__type_id = 'bluesheets' ).first ().document
13271327 self .assertEqual (bs_doc .rev ,'00' )
1328+
1329+ def test_upload_minutes_agenda (self ):
1330+ for doctype in ('minutes' ,'agenda' ):
1331+ session = SessionFactory (meeting__type_id = 'ietf' )
1332+ if doctype == 'minutes' :
1333+ url = urlreverse ('ietf.meeting.views.upload_session_minutes' ,kwargs = {'num' :session .meeting .number ,'session_id' :session .id })
1334+ else :
1335+ url = urlreverse ('ietf.meeting.views.upload_session_agenda' ,kwargs = {'num' :session .meeting .number ,'session_id' :session .id })
1336+ self .client .logout ()
1337+ login_testing_unauthorized (self ,"secretary" ,url )
1338+ r = self .client .get (url )
1339+ self .assertEqual (r .status_code , 200 )
1340+ q = PyQuery (r .content )
1341+ self .assertTrue ('Upload' in unicode (q ("Title" )))
1342+ self .assertFalse (session .sessionpresentation_set .exists ())
1343+ self .assertFalse (q ('form input[type="checkbox"]' ))
1344+
1345+ session2 = SessionFactory (meeting = session .meeting ,group = session .group )
1346+ r = self .client .get (url )
1347+ self .assertEqual (r .status_code , 200 )
1348+ q = PyQuery (r .content )
1349+ self .assertTrue (q ('form input[type="checkbox"]' ))
1350+
1351+ test_file = StringIO ('this is some text for a test' )
1352+ test_file .name = "not_really.json"
1353+ r = self .client .post (url ,dict (file = test_file ))
1354+ self .assertEqual (r .status_code , 200 )
1355+ q = PyQuery (r .content )
1356+ self .assertTrue (q ('form .has-error' ))
1357+
1358+ test_file = StringIO ('this is some text for a test' * 1510000 )
1359+ test_file .name = "not_really.pdf"
1360+ r = self .client .post (url ,dict (file = test_file ))
1361+ self .assertEqual (r .status_code , 200 )
1362+ q = PyQuery (r .content )
1363+ self .assertTrue (q ('form .has-error' ))
1364+
1365+ test_file = StringIO ('this is some text for a test' )
1366+ test_file .name = "not_really.txt"
1367+ r = self .client .post (url ,dict (file = test_file ,apply_to_all = False ))
1368+ self .assertEqual (r .status_code , 302 )
1369+ doc = session .sessionpresentation_set .filter (document__type_id = doctype ).first ().document
1370+ self .assertEqual (doc .rev ,'00' )
1371+ self .assertFalse (session2 .sessionpresentation_set .filter (document__type_id = doctype ))
1372+
1373+ r = self .client .get (url )
1374+ self .assertEqual (r .status_code , 200 )
1375+ q = PyQuery (r .content )
1376+ self .assertTrue ('Revise' in unicode (q ("Title" )))
1377+ test_file = StringIO ('this is some different text for a test' )
1378+ test_file .name = "also_not_really.txt"
1379+ r = self .client .post (url ,dict (file = test_file ,apply_to_all = True ))
1380+ self .assertEqual (r .status_code , 302 )
1381+ doc = Document .objects .get (pk = doc .pk )
1382+ self .assertEqual (doc .rev ,'01' )
1383+ self .assertTrue (session2 .sessionpresentation_set .filter (document__type_id = doctype ))
1384+
1385+ def test_upload_minutes_agenda_interim (self ):
1386+ session = SessionFactory (meeting__type_id = 'interim' )
1387+ for doctype in ('minutes' ,'agenda' ):
1388+ if doctype == 'minutes' :
1389+ url = urlreverse ('ietf.meeting.views.upload_session_minutes' ,kwargs = {'num' :session .meeting .number ,'session_id' :session .id })
1390+ else :
1391+ url = urlreverse ('ietf.meeting.views.upload_session_agenda' ,kwargs = {'num' :session .meeting .number ,'session_id' :session .id })
1392+ self .client .logout ()
1393+ login_testing_unauthorized (self ,"secretary" ,url )
1394+ r = self .client .get (url )
1395+ self .assertEqual (r .status_code , 200 )
1396+ q = PyQuery (r .content )
1397+ self .assertTrue ('Upload' in unicode (q ("title" )))
1398+ self .assertFalse (session .sessionpresentation_set .filter (document__type_id = doctype ))
1399+ test_file = StringIO ('this is some text for a test' )
1400+ test_file .name = "not_really.txt"
1401+ r = self .client .post (url ,dict (file = test_file ))
1402+ self .assertEqual (r .status_code , 302 )
1403+ doc = session .sessionpresentation_set .filter (document__type_id = doctype ).first ().document
1404+ self .assertEqual (doc .rev ,'00' )
1405+
1406+ def test_upload_slides (self ):
1407+
1408+ session1 = SessionFactory (meeting__type_id = 'ietf' )
1409+ session2 = SessionFactory (meeting = session1 .meeting ,group = session1 .group )
1410+ url = urlreverse ('ietf.meeting.views.upload_session_slides' ,kwargs = {'num' :session1 .meeting .number ,'session_id' :session1 .id })
1411+ login_testing_unauthorized (self ,"secretary" ,url )
1412+ r = self .client .get (url )
1413+ self .assertEqual (r .status_code , 200 )
1414+ q = PyQuery (r .content )
1415+ self .assertTrue ('Upload' in unicode (q ("title" )))
1416+ self .assertFalse (session1 .sessionpresentation_set .filter (document__type_id = 'slides' ))
1417+ test_file = StringIO ('this is not really a slide' )
1418+ test_file .name = 'not_really.txt'
1419+ r = self .client .post (url ,dict (file = test_file ,title = 'a test slide file' ,apply_to_all = True ))
1420+ self .assertEqual (r .status_code , 302 )
1421+ self .assertEqual (session1 .sessionpresentation_set .count (),1 )
1422+ self .assertEqual (session2 .sessionpresentation_set .count (),1 )
1423+ sp = session2 .sessionpresentation_set .first ()
1424+ self .assertEqual (sp .document .name , 'slides-%s-%s-a-test-slide-file' % (session1 .meeting .number ,session1 .group .acronym ) )
1425+ self .assertEqual (sp .order ,1 )
1426+
1427+ url = urlreverse ('ietf.meeting.views.upload_session_slides' ,kwargs = {'num' :session2 .meeting .number ,'session_id' :session2 .id })
1428+ test_file = StringIO ('some other thing still not slidelike' )
1429+ test_file .name = 'also_not_really.txt'
1430+ r = self .client .post (url ,dict (file = test_file ,title = 'a different slide file' ,apply_to_all = False ))
1431+ self .assertEqual (r .status_code , 302 )
1432+ self .assertEqual (session1 .sessionpresentation_set .count (),1 )
1433+ self .assertEqual (session2 .sessionpresentation_set .count (),2 )
1434+ sp = session2 .sessionpresentation_set .get (document__name__endswith = '-a-different-slide-file' )
1435+ self .assertEqual (sp .order ,2 )
1436+ self .assertEqual (sp .rev ,u'00' )
1437+ self .assertEqual (sp .document .rev ,u'00' )
1438+
1439+ 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 })
1440+ r = self .client .get (url )
1441+ self .assertTrue (r .status_code , 200 )
1442+ q = PyQuery (r .content )
1443+ self .assertTrue ('Revise' in unicode (q ("title" )))
1444+ test_file = StringIO ('new content for the second slide deck' )
1445+ test_file .name = 'doesnotmatter.txt'
1446+ r = self .client .post (url ,dict (file = test_file ,title = 'rename the presentation' ,apply_to_all = False ))
1447+ self .assertEqual (r .status_code , 302 )
1448+ self .assertEqual (session1 .sessionpresentation_set .count (),1 )
1449+ self .assertEqual (session2 .sessionpresentation_set .count (),2 )
1450+ sp = session2 .sessionpresentation_set .get (order = 2 )
1451+ self .assertEqual (sp .rev ,u'01' )
1452+ self .assertEqual (sp .document .rev ,u'01' )
1453+
0 commit comments