Esempio n. 1
0
 def test_generate_debug_submissions(self):
     """ Tests downloading some submissions from self 
         This is only useful to make sure that the test_load_diff_submissions test
         below is working properly.
     """
     #setup
     schema_1 = create_xsd_and_populate("pf_followup.xsd", \
                             "pf_followup_1.xml", path = DATA_DIR)
     populate("pf_followup_2.xml", path = DATA_DIR)
     schema_2 = create_xsd_and_populate("pf_new_reg.xsd", \
                             "pf_new_reg_1.xml", path = DATA_DIR)
     populate("pf_new_reg_2.xml", path = DATA_DIR)
     schema_3 = create_xsd_and_populate("pf_ref_completed.xsd", \
                             "pf_ref_completed_1.xml", path = DATA_DIR)
     populate("pf_ref_completed_2.xml", path = DATA_DIR)
     
     # the 'debug' flag limits the generated MD5s to a count of 5
     submissions_file = "submissions.tar"
     # debug means we only post 5 submissions (instead of all)
     generate_submissions(serverhost, 'brian', 'test', debug=True, download=True, to=submissions_file)
     try:
         self._assert_tar_count_equals(submissions_file, Submission.objects.all().count()-5)
         
     # cleanup
     finally:    
         # delete all data on self
         manager = XFormManager()
         manager.remove_schema(schema_1.id, remove_submissions = True)
         manager.remove_schema(schema_2.id, remove_submissions = True)
         manager.remove_schema(schema_3.id, remove_submissions = True)
Esempio n. 2
0
 def test_sync_no_submissions(self):
     """ Tests synchronizing no data from self (posts all MD5s) """
     manager = XFormManager()
 
     # load data
     schema_1 = create_xsd_and_populate("pf_followup.xsd", \
                             "pf_followup_1.xml", path = DATA_DIR)
     populate("pf_followup_2.xml", path = DATA_DIR)
     schema_2 = create_xsd_and_populate("pf_new_reg.xsd", \
                             "pf_new_reg_1.xml", path = DATA_DIR)
     populate("pf_new_reg_2.xml", path = DATA_DIR)
     schema_3 = create_xsd_and_populate("pf_ref_completed.xsd", \
                             "pf_ref_completed_1.xml", path = DATA_DIR)
     populate("pf_ref_completed_2.xml", path = DATA_DIR)
     populate("pf_ref_completed_3.xml", path = DATA_DIR)
     starting_submissions_count = Submission.objects.all().count()
     
     # get sync file from self
     submissions_file = "submissions.tar"
     generate_submissions(serverhost, 'brian', 'test', download=True, to=submissions_file)
     
     # test that the received submissions file is empty
     self._assert_tar_count_equals(submissions_file, 0)
 
     load_submissions(submissions_file, "127.0.0.1:8000")    
     try:
         # verify that no new submissions were loaded
         self.assertEqual( starting_submissions_count, Submission.objects.all().count())
     finally:            
         # clean up
         manager.remove_schema(schema_1.id, remove_submissions = True)
         manager.remove_schema(schema_2.id, remove_submissions = True)
         manager.remove_schema(schema_3.id, remove_submissions = True)
Esempio n. 3
0
 def test_generate_all_submissions(self):
     """ Tests downloading all submissions from self """
     # setup
     schema_1 = create_xsd_and_populate("pf_followup.xsd", path = DATA_DIR)
     submit_1 = populate("pf_followup_1.xml", path = DATA_DIR)
     submit_2 = populate("pf_followup_2.xml", path = DATA_DIR)
     schema_2 = create_xsd_and_populate("pf_new_reg.xsd", path = DATA_DIR)
     submit_3 = populate("pf_new_reg_1.xml", path = DATA_DIR)
     submit_4 = populate("pf_new_reg_2.xml", path = DATA_DIR)
     schema_3 = create_xsd_and_populate("pf_ref_completed.xsd", path = DATA_DIR)
     submit_5 = populate("pf_ref_completed_1.xml", path = DATA_DIR)
     submit_6 = populate("pf_ref_completed_2.xml", path = DATA_DIR)
     
     # download and check
     submissions_file = "submissions.tar"
     generate_submissions(serverhost, 'brian', 'test', latest=False, download=True, to=submissions_file)
     try:
         self._assert_tar_count_equals(submissions_file, Submission.objects.all().count())
         
     # cleanup
     finally:
         # delete all data on self
         manager = XFormManager()
         submit_1.delete()
         submit_2.delete()
         submit_3.delete()
         submit_4.delete()
         submit_5.delete()
         submit_6.delete()
         manager.remove_schema(schema_1.id, remove_submissions = True)
         manager.remove_schema(schema_2.id, remove_submissions = True)
         manager.remove_schema(schema_3.id, remove_submissions = True)
def synchronize_submissions(remote_ip, username, password, local_server="127.0.0.1:8000"):
    file = 'submissions.tar'
    generate_submissions(remote_ip, username, password, \
                         download=True, to=file)
    load_submissions(file, local_server)