def move_file_to_staging(self): dir_name = self.gcst sumstats_file_name = self.gcst + '_build' + str(self.assembly) ssf = fh.SumStatFile(file_path=self.file_path, callback_id=self.callback_id, study_id=self.study_id, readme=self.readme, entryUUID=self.entryUUID, staging_dir_name=dir_name, staging_file_name=sumstats_file_name, raw_ss=self.raw_ss) return ssf.move_file_to_staging()
def validate_study(self, minrows=None, forcevalid=False): # Step through the validation if self.mandatory_metadata_check() is True: ssf = fh.SumStatFile(file_path=self.file_path, callback_id=self.callback_id, study_id=self.study_id, md5exp=self.md5, readme=self.readme, entryUUID=self.entryUUID, minrows=minrows, raw_ss=self.raw_ss) if ssf.retrieve() is True: self.set_retrieved_status(1) if not ssf.md5_ok(): self.set_data_valid_status(0) self.set_error_code(2) else: if ssf.check_raw_ss(): validation_status = ssf.validate_file() if forcevalid is False else True if validation_status is True: self.set_data_valid_status(1) ssf.write_readme_file() ssf.tidy_files() else: self.set_data_valid_status(0) self.set_error_code(ssf.validation_error) else: self.set_data_valid_status(0) self.set_error_code(11) else: self.set_retrieved_status(0) self.set_error_code(1)
def test_validate_false_when_invalid(self): ssf = fh.SumStatFile(file_path=self.invalid_url, callback_id=self.cid, study_id=self.sid, md5exp=self.valid_url_md5, minrows=10) ssf.retrieve() result = ssf.validate_file() self.assertFalse(result) self.assertTrue(os.path.exists(os.path.join(ssf.parent_path, str(self.sid + ".log"))))
def test_md5(self): ssf = fh.SumStatFile(file_path=self.valid_url, callback_id=self.cid, study_id=self.sid, md5exp=self.valid_url_md5) ssf.retrieve() self.assertEqual(fh.md5_check(os.path.join(ssf.store_path)),self.valid_url_md5) md5_ok = ssf.md5_ok() self.assertTrue(md5_ok)
def test_remove_parent_dir(self): ssf = fh.SumStatFile(callback_id=self.cid, study_id=self.sid) ssf.set_parent_path() self.assertFalse(os.path.exists(ssf.parent_path)) ssf.make_parent_dir() self.assertTrue(os.path.exists(ssf.parent_path)) fh.remove_payload(self.cid) self.assertFalse(os.path.exists(ssf.parent_path))
def test_retrieve(self): ssf = fh.SumStatFile(file_path=self.valid_url, callback_id=self.cid, study_id=self.sid) retrieved = ssf.retrieve() self.assertTrue(retrieved)