Skip to content

Commit

Permalink
unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
tongzhouxu committed Mar 26, 2024
1 parent 11d62c5 commit 26777b2
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 56 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,12 @@ jobs:
mkdir -p $HOME/.local/bin
mv datasets $HOME/.local/bin
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Check datasets location
run: ls -l $HOME/.local/bin/datasets
- name: Check PATH
run: echo $PATH
- name: Run datasets
run: datasets --version
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
- name: Install pytest
run: |
pip install pytest
Expand Down
2 changes: 1 addition & 1 deletion mashpit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__author__ = 'Tongzhou Xu'
__email__ = '[email protected]'
__version__ = '0.9.32'
__version__ = '0.9.4'
45 changes: 1 addition & 44 deletions mashpit/test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sqlite3
import shutil

from unittest.mock import MagicMock, patch
from mashpit.build import create_connection
from mashpit.build import create_database
from mashpit.build import download_metadata
Expand Down Expand Up @@ -156,49 +157,5 @@ def test_compare_tables(self):
self.assertEqual(pds_to_add, ['PDS_002', 'PDS_004'])
self.assertEqual(asm_acc_add, ['asm2', 'asm4'])

class TestBuildAccession(unittest.TestCase):
def setUp(self):
class Args:
def __init__(self):
self.type = 'accession'
self.name = 'test_database'
self.quiet = True
self.number = 1000
self.ksize = 31
self.email = '[email protected]'
self.list = 'test_list'
self.key = None
self.args = Args()
def tearDown(self):
shutil.rmtree('test_database')
def test_build_accession(self):
build_accession(self.args)
self.assertTrue(os.path.isfile('test_database/test_database.db'))
self.assertTrue(os.path.isfile('test_database/test_database.sig'))
# check the database structure
conn = sqlite3.connect('test_database/test_database.db')
c = conn.cursor()
# check the number if lines in the METADATA table
c.execute("SELECT COUNT(*) FROM METADATA;")
result = c.fetchone()
self.assertEqual(result[0], 3)
c.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='DESC';")
result = c.fetchone()
self.assertIsNotNone(result)
c.execute("PRAGMA table_info(METADATA);")
columns = [row[1] for row in c.fetchall()]
expected_columns = [
'biosample_acc', 'taxid', 'strain', 'collected_by', 'collection_date', 'geo_loc_name',
'isolation_source', 'lat_lon', 'serovar', 'sub_species', 'species', 'genus', 'host',
'host_disease', 'outbreak', 'srr', 'PDT_acc', 'PDS_acc', 'asm_acc'
]
self.assertListEqual(columns, expected_columns)
c.execute("PRAGMA table_info(DESC);")
columns = [row[1] for row in c.fetchall()]
expected_columns = ['name', 'value']
self.assertListEqual(columns, expected_columns)
conn.close()


if __name__ == '__main__':
unittest.main()
3 changes: 0 additions & 3 deletions mashpit/test/test_list

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='mashpit',
version='0.9.32',
version='0.9.4',
url='https://github.com/tongzhouxu/mashpit',
author='Tongzhou Xu',
author_email='[email protected]',
Expand Down

0 comments on commit 26777b2

Please sign in to comment.