コード例 #1
0
ファイル: testSync.py プロジェクト: ITIDO/gfatm
 def test_sync_no_schemata(self):
     """ Tests synchronizing no data from self (posts all MD5s) """
     manager = XFormManager()
 
     # load data
     schema_1 = create_xsd_and_populate("pf_followup.xsd", path = DATA_DIR)
     schema_2 = create_xsd_and_populate("pf_new_reg.xsd", path = DATA_DIR)
     schema_3 = create_xsd_and_populate("pf_ref_completed.xsd", path = DATA_DIR)
     
     # get sync file from self
     schemata_file = 'schemata.tar'
     generate_schemata(serverhost, 'brian', 'test', download=True, to=schemata_file)
     
     # test that the received schemata file is empty
     self._assert_tar_count_equals(schemata_file, 0)
 
     starting_schemata_count = FormDefModel.objects.all().count()
     load_schemata(schemata_file, "127.0.0.1:8000")    
     try:
         # verify that no new schemata were loaded
         self.assertEqual( starting_schemata_count, FormDefModel.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)
コード例 #2
0
ファイル: testSync.py プロジェクト: ITIDO/gfatm
    def test_sync_all_schemata(self):
        """ Tests synchronizing all schemata from self (no xmlns posted) """
        manager = XFormManager()
    
        # load data
        schema_1 = create_xsd_and_populate("pf_followup.xsd", path = DATA_DIR)
        schema_2 = create_xsd_and_populate("pf_new_reg.xsd", path = DATA_DIR)
        schema_3 = create_xsd_and_populate("pf_ref_completed.xsd", path = DATA_DIR)
        starting_schemata_count = FormDefModel.objects.all().count()
        
        # get sync file from self
        schemata_file = "schemata.tar"
        generate_schemata(serverhost, 'brian', 'test', latest=False, download=True, to=schemata_file)
                
        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)

        # load data from sync file
        load_schemata(schemata_file, "127.0.0.1:8000")
        
        try:
            # verify that the submissions etc. count are correct
            self.assertEqual( starting_schemata_count, FormDefModel.objects.all().count())
        finally:
            # clean up
            self._delete_schema_from_filename("pf_followup.xsd", path = DATA_DIR)
            self._delete_schema_from_filename("pf_new_reg.xsd", path = DATA_DIR)
            self._delete_schema_from_filename("pf_ref_completed.xsd", path = DATA_DIR)