datasnakes / OrthoEvolution

An easy to use and comprehensive python package which aids in the analysis and visualization of orthologous genes. 🐵
https://orthoevolution.readthedocs.io/en/master/
29 stars 4 forks source link

Cookie module not functioning properly. #156

Closed grabear closed 5 years ago

grabear commented 5 years ago

I'm having trouble getting my branch to work properly (db_mana_update). It's not creating the proper directories for me, which is unusual:

image

After looking at it the self.user_log does not exists, which it should after being set up via cookiecutter. So I started digging.

I think the issue is with the new function in the cookie_jar.py file.

This is what is added: image

And this is the type of code it is replacing: image

I still need to look at it closer after lunch, but I think the logic is broken at the first if statement in the added function.

146

148

sdhutchins commented 5 years ago

Yeah, it could be that function although it is working okay with the test and blast. It could be wherever the database structure is being created.

sdhutchins commented 5 years ago

Partly why I wrote the function is because the cookie class was breaking with blast so I cleaned up the code a little while debugging that... In the process, the database stuff could have been broken - particularly in management.py

sdhutchins commented 5 years ago

"""This is the test suite for Manager."""
import unittest
from shutil import rmtree

from OrthoEvol.Manager.management import ProjectManagement

class TestManager(unittest.TestCase):
    """Test the Manager module."""

    def setUp(self, project='test-project', repository=None):
        self.project = project
        self.repo = repository

    def delete_project(self):
        rmtree(self.project)

    def test_projectmanagement(self):
        """Test the ProjectManagement class."""
        ProjectManagement(repo=self.repo, user=None,
                          project=self.project,
                          research=None,
                          research_type='comparative_genetics',
                          new_repo=False, new_user=False, new_project=True,
                          new_research=False)
        self.assertEqual(str(self.project), 'test-project')
        self.delete_project()

if __name__ == '__main__':
    unittest.main()

This current test is working. May help shed light on what's causing the ProjectMangement class to break.

grabear commented 5 years ago

These tests should work fine because it does not require the directory to exist or to be created to "pass". I looked at it again at lunch, and I think the issue is with the first if statement. It should be checking whether or not the directory (self.cookie_jar) exists vs. testing whether or not the directory (self.cookie_jar) is a value other than False, None, 0, or ''.

# It should be this:
if self.exists(self.cookie_jar):
...
# Not this:
if self.cookie_jar:
...

I will commit this and then test it out to see if it works.

sdhutchins commented 5 years ago

@grabear That makes sense. I noticed that when I came back from lunch.

sdhutchins commented 5 years ago

I think I misunderstood what self.exists was doing initially.

grabear commented 5 years ago

Yea that makes it less readable. I'm going to change that up a bit, so it's more explicit. Thanks for taking a look. I thought I was going to have to troubleshoot for a while lol.