1- import unittest , re , json , datetime , StringIO
1+ import unittest , re , json , datetime , StringIO , shutil
2+
23from django .conf import settings
34from django .core .urlresolvers import reverse as urlreverse
45
@@ -185,6 +186,24 @@ def test_notify_page(self):
185186
186187
187188class RFCSyncTests (TestCase ):
189+ def setUp (self ):
190+ self .id_dir = os .path .abspath ("tmp-id-dir" )
191+ self .archive_dir = os .path .abspath ("tmp-id-archive" )
192+ if not os .path .exists (self .id_dir ):
193+ os .mkdir (self .id_dir )
194+ if not os .path .exists (self .archive_dir ):
195+ os .mkdir (self .archive_dir )
196+ settings .INTERNET_DRAFT_PATH = self .id_dir
197+ settings .INTERNET_DRAFT_ARCHIVE_DIR = self .archive_dir
198+
199+ def tearDown (self ):
200+ shutil .rmtree (self .id_dir )
201+ shutil .rmtree (self .archive_dir )
202+
203+ def write_draft_file (self , name , size ):
204+ with open (os .path .join (self .id_dir , name ), 'w' ) as f :
205+ f .write ("a" * size )
206+
188207 def test_rfc_index (self ):
189208 doc = make_test_data ()
190209 doc .set_state (State .objects .get (used = True , type = "draft-iesg" , slug = "rfcqueue" ))
@@ -285,6 +304,8 @@ def test_rfc_index(self):
285304
286305
287306 mailbox_before = len (outbox )
307+ draft_filename = "%s-%s.txt" % (doc .name , doc .rev )
308+ self .write_draft_file (draft_filename , 5000 )
288309
289310 changed = rfceditor .update_docs_from_rfc_index (data , today - datetime .timedelta (days = 30 ))
290311
@@ -305,6 +326,8 @@ def test_rfc_index(self):
305326 self .assertEqual (doc .get_state_slug ("draft-stream-ise" ), "pub" )
306327 self .assertEqual (doc .std_level_id , "ps" )
307328 self .assertEqual (doc .pages , 42 )
329+ self .assertTrue (not os .path .exists (os .path .join (self .id_dir , draft_filename )))
330+ self .assertTrue (os .path .exists (os .path .join (self .archive_dir , draft_filename )))
308331
309332 # make sure we can apply it again with no changes
310333 changed = rfceditor .update_docs_from_rfc_index (data , today - datetime .timedelta (days = 30 ))
0 commit comments