Skip to content

Commit

Permalink
Remove PackageVersion test.
Browse files Browse the repository at this point in the history
  • Loading branch information
sdhutchins committed Jan 6, 2024
1 parent 7b7a8c5 commit 54a72f8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 46 deletions.
78 changes: 42 additions & 36 deletions OrthoEvol/Manager/db_mana_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,49 @@
import getpass
from datetime import datetime as d
import os
_jobname = "jobname"

# Set up project management
pm_config_file = resource_filename(yml.__name__, "initialize_new.yml")
with open(pm_config_file, 'r') as f:
pm_config = yaml.load(f, Loader=yaml.FullLoader)
pm = ProjectManagement(**pm_config["Management_config"])
# Define job name
job_name = "jobname"

# Set up database management
db_config_file = resource_filename(yml.__name__, "databases.yml")
with open(db_config_file, 'r') as f:
db_config = yaml.load(f, Loader=yaml.FullLoader)
# Function to load configuration from YAML file
def load_config(file_name):
file_path = resource_filename(yml.__name__, file_name)
with open(file_path, 'r') as file:
return yaml.load(file, Loader=yaml.FullLoader)

# Load project management configuration
pm_config = load_config("initialize_new.yml")
project_manager = ProjectManagement(**pm_config["Management_config"])

# Load and update database management configuration
db_config = load_config("databases.yml")
db_config.update(pm_config)
db_config['Database_config']['Full']['NCBI']['NCBI_refseq_release']['upload_number'] = 12
db_config['Database_config']['Full']['NCBI']['NCBI_refseq_release']['pbs_dict'] = {
'author': getpass.getuser(),
'description': 'This is a default pbs job.',
'date': d.now().strftime('%a %b %d %I:%M:%S %p %Y'),
'proj_name': 'OrthoEvol',
'select': '1',
'memgb': '6gb',
'cput': '72:00:00',
'wt': '2000:00:00',
'job_name': _jobname,
'outfile': _jobname + '.o',
'errfile': _jobname + '.e',
'script': _jobname,
'log_name': _jobname,
'pbsworkdir': os.getcwd(),
'cmd': 'python3.6 ' + os.path.join(os.getcwd(), _jobname + '.py'),
'email': 'n/a'
}
# Generate main config file for this job
config_file = pm.user_log / Path("upload_config.yml")
with open(str(config_file), 'w') as cf:
yaml.dump(db_config, cf, default_flow_style=False)
ncbi_config = db_config['Database_config']['Full']['NCBI']['NCBI_refseq_release']
ncbi_config['upload_number'] = 12
ncbi_config['pbs_dict'] = {
'author': getpass.getuser(),
'description': 'This is a default pbs job.',
'date': d.now().strftime('%a %b %d %I:%M:%S %p %Y'),
'proj_name': 'OrthoEvol',
'select': '1',
'memgb': '6gb',
'cput': '72:00:00',
'wt': '2000:00:00',
'job_name': job_name,
'outfile': job_name + '.o',
'errfile': job_name + '.e',
'script': job_name,
'log_name': job_name,
'pbsworkdir': os.getcwd(),
'cmd': f'python3.6 {os.path.join(os.getcwd(), job_name + ".py")}',
'email': 'n/a'
}

# Save the updated configuration to a YAML file
config_file_path = project_manager.user_log / Path("upload_config.yml")
with open(str(config_file_path), 'w') as config_file:
yaml.dump(db_config, config_file, default_flow_style=False)

# Set up database dispatcher and dispatch the functions
dd = DatabaseDispatcher(config_file, pm)
dd.dispatch(dd.strategies, dd.dispatcher, dd.configuration)
# Initialize database dispatcher and execute dispatch functions
db_dispatcher = DatabaseDispatcher(config_file_path, project_manager)
db_dispatcher.dispatch(db_dispatcher.strategies, db_dispatcher.dispatcher, db_dispatcher.configuration)
11 changes: 1 addition & 10 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import unittest
from unittest.mock import patch
from pathlib import Path
import os
import shutil

from OrthoEvol.utilities import CookieUtils, PackageVersion, FunctionRepeater
from OrthoEvol.utilities import CookieUtils, FunctionRepeater


class TestCookieUtils(unittest.TestCase):
Expand Down Expand Up @@ -41,14 +40,6 @@ def test_get_size(self):
size = self.utils.get_size(start_path=str(test_file))
self.assertIsInstance(size, str)

class TestPackageVersion(unittest.TestCase):

@patch('OrthoEvol.Cookies.utils.pkg_resources.get_distribution')
def test_package_version(self, mock_get_distribution):
mock_get_distribution.return_value.version = '1.0.0'
version = PackageVersion('example_package')
self.assertEqual(version.packagename, 'example_package')

class TestFunctionRepeater(unittest.TestCase):

def setUp(self):
Expand Down

0 comments on commit 54a72f8

Please sign in to comment.