Esempio n. 1
0
class DocumentTest(unittest.TestCase):
    '''Tests the `Document` class.'''
    def setUp(self):
        self.env = TestEnv()
        self.tracker = self.env.tracker

    def tearDown(self):
        self.env.cleanup()

    def test_constructor(self):
        # create a document called 'test'
        path = os.path.join(self.tracker.paths['docs'], 'test')
        with open(path, 'w') as fp:
            fp.write('test')

        # try to initialize the doc
        Document(self.tracker, 'test')

    def test_read(self):
        '''Tests the `read` method'''
        pass

    def test_write(self):
        '''Tests the `write` method'''
        pass
Esempio n. 2
0
class DocumentTest(unittest.TestCase):
    """Tests the `Document` class."""

    def setUp(self):
        self.env = TestEnv()
        self.tracker = self.env.tracker

    def tearDown(self):
        self.env.cleanup()

    def test_constructor(self):
        # create a document called 'test'
        path = os.path.join(self.tracker.paths["docs"], "test")
        with open(path, "w") as fp:
            fp.write("test")

        # try to initialize the doc
        Document(self.tracker, "test")

    def test_read(self):
        """Tests the `read` method"""
        pass

    def test_write(self):
        """Tests the `write` method"""
        pass
Esempio n. 3
0
class CommentTest(unittest.TestCase):
    def setUp(self):
        self.env = TestEnv()
        self.tracker = self.env.tracker
        self.issue = Issue(self.tracker)

    def tearDown(self):
        self.env.cleanup()

    def test_save(self):
        pass

    def test_save_issue(self):
        pass

    def test_delete(self):
        pass

    def test_rm(self):
        pass
Esempio n. 4
0
class CommentTest(unittest.TestCase):
    def setUp(self):
        self.env = TestEnv()
        self.tracker = self.env.tracker
        self.issue = Issue(self.tracker)

    def tearDown(self):
        self.env.cleanup()

    def test_save(self):
        pass

    def test_save_issue(self):
        pass

    def test_delete(self):
        pass

    def test_rm(self):
        pass
Esempio n. 5
0
class DatabaseTest(unittest.TestCase):
    '''Tests the `SQLiteIssueDatabase` class.'''
    def setUp(self):
        self.env = TestEnv()

    def tearDown(self):
        self.env.cleanup()

    def test_constructor(self):
        '''Test the __init__ method.'''
        path = os.path.join(self.env.tracker.paths['admin'], 'cache',
                            'tracker.db')

        # Init a database when one does not exist:
        db1 = Database(self.env.tracker)
        assert os.path.exists(path)
        assert db1.conn

        # Init a database when one already exists:
        db2 = Database(self.env.tracker)
        assert os.path.exists(path)
        assert db2.conn

    def test__apply_working_tree(self):
        '''Tests the `_apply_working_tree` method'''
        pass

    def test__insert_many_from_shas(self):
        '''Tests the `_insert_many_from_shas` method'''
        pass

    def test__integrity_check(self):
        '''Tests the `_integrity_check` method'''
        pass

    def test__replicate(self):
        '''Tests the `_replicate` method'''
        pass

    def test__set_update(self):
        '''Tests the `_set_update` method'''
        pass

    def test_insert(self):
        '''Tests the `insert` method'''
        db = Database(self.env.tracker)
        # make and insert the issue
        issue1 = Issue(self.env.tracker)
        issue1.content = 'test'
        issue1.title = 'Test'
        issue1.save()
        db.insert(issue1)
        rows = db.select().execute()
        issue2 = [Issue(self.env.tracker, r['id']) for r in rows][0]
        # make sure the issues are equal which triggers the __eq__ method.
        assert issue1 == issue2

    def test_insert_many(self):
        '''Tests the `insert_many` method'''
        db = Database(self.env.tracker)
        issues = []
        for i in range(20):
            issue = Issue(self.env.tracker)
            issue.save()
            issues.append(issue)
        db.insert_many(issues)
        rows = db.select().execute()
        db_issues = [Issue(self.env.tracker, r['id']) for r in rows]
        # quick check to make sure they're all there.
        assert len(db_issues) == len(issues)

    def test_select(self):
        '''Tests the `select` method'''
        db = Database(self.env.tracker)
        # should just return an sqlalchemy.sql.Select object.
        assert type(db.select()) is Select
Esempio n. 6
0
class TestIssue(unittest.TestCase):
    def setUp(self):
        self.env = TestEnv()
        self.tracker = self.env.tracker

    def tearDown(self):
        self.env.cleanup()

    def test_setattr(self):
        issue = Issue(self.tracker)
        issue.title = 'test title'
        # Does the __setattr__ method work?
        # i.e.: setting issue.title shoud set issue.fields['title']
        assert issue.title == issue.fields['title']

    def test_getattribute(self):
        issue = Issue(self.tracker)
        issue.fields['title'] = 'test title'
        # Does the __getattribute__ method work?
        # i.e.: issue.title should return issue.fields['title']
        assert issue.fields['title'] == issue.title

    def test_eq(self):
        issue1 = Issue(self.tracker)
        issue1.save()
        issue2 = Issue(self.tracker, issue1.id)
        assert issue1 == issue2

    def test_ne(self):
        issue1 = Issue(self.tracker)
        issue1.save()
        issue2 = Issue(self.tracker)
        issue2.save()
        assert issue1 != issue2

    def test_comments(self):
        issue = Issue(self.tracker)
        issue.save()
        # Make some comments
        comments = [Comment(issue) for i in range(20)]
        for c in comments:
            c.save()
        assert type(issue.comments()) is list
        assert len(issue.comments()) == 20
        assert len(issue.comments(n=15)) == 15

    def test_comment(self):
        issue = Issue(self.tracker)
        issue.save()
        c = Comment(issue)
        c.save()
        assert type(issue.comment(c.id)) is Comment
        assert issue.comment(c.id).fields == c.fields

    def test_save(self):
        issue = Issue(self.tracker)
        issue.title = 'test title'
        issue.save()

        # Get the path to the issue and assert that it's there.
        path = self.tracker.get_issue_path(issue.id)
        assert os.path.exists(path)

        # Does the issue initialized from file match the original?
        issue_clone = Issue(self.tracker, issue.id)
        assert issue_clone.fields == issue.fields

    def test_timestamps(self):
        issue = Issue(self.tracker)
        issue.title = 'test title'
        issue.save()
        assert issue.created == issue.updated
Esempio n. 7
0
class TestIssue(unittest.TestCase):
    def setUp(self):
        self.env = TestEnv()
        self.tracker = self.env.tracker

    def tearDown(self):
        self.env.cleanup()

    def test_setattr(self):
        issue = Issue(self.tracker)
        issue.title = "test title"
        # Does the __setattr__ method work?
        # i.e.: setting issue.title shoud set issue.fields['title']
        assert issue.title == issue.fields["title"]

    def test_getattribute(self):
        issue = Issue(self.tracker)
        issue.fields["title"] = "test title"
        # Does the __getattribute__ method work?
        # i.e.: issue.title should return issue.fields['title']
        assert issue.fields["title"] == issue.title

    def test_eq(self):
        issue1 = Issue(self.tracker)
        issue1.save()
        issue2 = Issue(self.tracker, issue1.id)
        assert issue1 == issue2

    def test_ne(self):
        issue1 = Issue(self.tracker)
        issue1.save()
        issue2 = Issue(self.tracker)
        issue2.save()
        assert issue1 != issue2

    def test_comments(self):
        issue = Issue(self.tracker)
        issue.save()
        # Make some comments
        comments = [Comment(issue) for i in range(20)]
        for c in comments:
            c.save()
        assert type(issue.comments()) is list
        assert len(issue.comments()) == 20
        assert len(issue.comments(n=15)) == 15

    def test_comment(self):
        issue = Issue(self.tracker)
        issue.save()
        c = Comment(issue)
        c.save()
        assert type(issue.comment(c.id)) is Comment
        assert issue.comment(c.id).fields == c.fields

    def test_save(self):
        issue = Issue(self.tracker)
        issue.title = "test title"
        issue.save()

        # Get the path to the issue and assert that it's there.
        path = self.tracker.get_issue_path(issue.id)
        assert os.path.exists(path)

        # Does the issue initialized from file match the original?
        issue_clone = Issue(self.tracker, issue.id)
        assert issue_clone.fields == issue.fields

    def test_timestamps(self):
        issue = Issue(self.tracker)
        issue.title = "test title"
        issue.save()
        assert issue.created == issue.updated
Esempio n. 8
0
class DatabaseTest(unittest.TestCase):
    '''Tests the `SQLiteIssueDatabase` class.'''

    def setUp(self):
        self.env = TestEnv()

    def tearDown(self):
        self.env.cleanup()

    def test_constructor(self):
        '''Test the __init__ method.'''
        path = os.path.join(self.env.tracker.paths['admin'],
                            'cache', 'tracker.db')

        # Init a database when one does not exist:
        db1 = Database(self.env.tracker)
        assert os.path.exists(path)
        assert db1.conn

        # Init a database when one already exists:
        db2 = Database(self.env.tracker)
        assert os.path.exists(path)
        assert db2.conn

    def test__apply_working_tree(self):
        '''Tests the `_apply_working_tree` method'''
        pass

    def test__insert_many_from_shas(self):
        '''Tests the `_insert_many_from_shas` method'''
        pass

    def test__integrity_check(self):
        '''Tests the `_integrity_check` method'''
        pass

    def test__replicate(self):
        '''Tests the `_replicate` method'''
        pass

    def test__set_update(self):
        '''Tests the `_set_update` method'''
        pass

    def test_insert(self):
        '''Tests the `insert` method'''
        db = Database(self.env.tracker)
        # make and insert the issue
        issue1 = Issue(self.env.tracker)
        issue1.content = 'test'
        issue1.title = 'Test'
        issue1.save()
        db.insert(issue1)
        rows = db.select().execute()
        issue2 = [Issue(self.env.tracker, r['id']) for r in rows][0]
        # make sure the issues are equal which triggers the __eq__ method.
        assert issue1 == issue2

    def test_insert_many(self):
        '''Tests the `insert_many` method'''
        db = Database(self.env.tracker)
        issues = []
        for i in range(20):
            issue = Issue(self.env.tracker)
            issue.save()
            issues.append(issue)
        db.insert_many(issues)
        rows = db.select().execute()
        db_issues = [Issue(self.env.tracker, r['id']) for r in rows]
        # quick check to make sure they're all there.
        assert len(db_issues) == len(issues)

    def test_select(self):
        '''Tests the `select` method'''
        db = Database(self.env.tracker)
        # should just return an sqlalchemy.sql.Select object.
        assert type(db.select()) is Select