Skip to content

Commit

Permalink
remove redundant tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiangs18 committed Aug 28, 2024
1 parent 35030a0 commit 4b1b88b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 45 deletions.
15 changes: 6 additions & 9 deletions lib/GenomeFileUtil/core/GenomeInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
from installed_clients.AssemblySequenceAPIServiceClient import AssemblySequenceAPI
from installed_clients.DataFileUtilClient import DataFileUtil
from installed_clients.WSLargeDataIOClient import WsLargeDataIO
from GenomeFileUtil.core.GenomeUtils import (
set_taxon_data, set_default_taxon_data, sort_dict,
set_up_single_params, validate_mass_params
)
from GenomeFileUtil.core import GenomeUtils

MAX_GENOME_SIZE = 2**30

Expand All @@ -40,14 +37,14 @@ def __init__(self, config):
self.ws_large_data = WsLargeDataIO(self.callback_url)

def save_one_genome(self, params):
mass_params = set_up_single_params(
mass_params = GenomeUtils.set_up_single_params(
params, _WS, self._validate_genome_input_params, self.dfu.ws_name_to_id
)
return self._save_genome_mass(mass_params)[0]

# NOTE If there is more than 1GB of data or more than 10,000 genomes to upload, the workspace will fail.
def save_genome_mass(self, params):
validate_mass_params(params, self._validate_genome_input_params)
GenomeUtils.validate_mass_params(params, self._validate_genome_input_params)
return self._save_genome_mass(params)

def _validate_genome_input_params(self, genome_input):
Expand Down Expand Up @@ -212,7 +209,7 @@ def _save_genome_mass(self, params):
data['warnings'] = self.validate_genome(data)

# sort data
data = sort_dict(data)
data = GenomeUtils.sort_dict(data)
# dump genome to scratch for upload
data_path = os.path.join(self.scratch, name + ".json")
json.dump(data, open(data_path, 'w'))
Expand Down Expand Up @@ -287,9 +284,9 @@ def _update_genome(self, genome):
# NOTE: Metagenome object does not have a 'taxon_assignments' field
if 'taxon_assignments' in genome and genome['taxon_assignments'].get('ncbi'):
tax_id = int(genome['taxon_assignments']['ncbi'])
set_taxon_data(tax_id, self.re_api_url, genome)
GenomeUtils.set_taxon_data(tax_id, self.re_api_url, genome)
else:
set_default_taxon_data(genome)
GenomeUtils.set_default_taxon_data(genome)

if any([x not in genome for x in ('dna_size', 'md5', 'gc_content', 'num_contigs')]):
if 'assembly_ref' in genome:
Expand Down
44 changes: 8 additions & 36 deletions test/problematic_tests/save_genome_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,42 +234,14 @@ def test_genomes_with_hidden(self):
ret = self.genome_interface.save_genome_mass(params)[0]
self.check_save_one_genome_output(ret, genome_name)

# def test_bad_genomes_params_missing_wsid(self):
# self.start_test()
# invalidate_params = {
# 'missing_workspace_id': 'workspace_id',
# 'name': 'name',
# 'data': 'data',
# }
# error_msg = "workspace_id is required"
# self.fail_save_genome(invalidate_params, error_msg, mass=True)

# def test_bad_genomes_params_empty_inputs(self):
# self.start_test()
# invalidate_params = {
# 'workspace_id': self.wsID,
# 'inputs': []
# }
# error_msg = "inputs field is required and must be a non-empty list"
# self.fail_save_genome(invalidate_params, error_msg, mass=True)

# def test_bad_genomes_params_invalidate_entry_type(self):
# self.start_test()
# invalidate_params = {
# 'workspace_id': self.wsID,
# 'inputs': [['name', 'data']],
# }
# error_msg = "Entry #1 in inputs field is not a mapping as required"
# self.fail_save_genome(invalidate_params, error_msg, mass=True)

# def test_bad_genomes_params_missing_parameter(self):
# self.start_test()
# invalidate_params = {
# 'workspace_id': self.wsID,
# 'inputs': [{'data': 'data'}],
# }
# error_msg = "Entry #1 in inputs field has invalid params: name parameter is required, but missing"
# self.fail_save_genome(invalidate_params, error_msg, mass=True)
def test_bad_genomes_params_missing_parameter(self):
self.start_test()
invalidate_params = {
'workspace_id': self.wsID,
'inputs': [{'data': 'data'}],
}
error_msg = "Entry #1 in inputs field has invalid params: name parameter is required, but missing"
self.fail_save_genome(invalidate_params, error_msg, mass=True)

def test_GenomeInterface_check_dna_sequence_in_features(self):
# no feature in genome
Expand Down

0 comments on commit 4b1b88b

Please sign in to comment.