← Back to team overview

gtg-user team mailing list archive

Unittests for gtg

 

Hi,

Interested in GTG ('cause I'm soooo careless for things I have to do
sometimes), I'm also fond of Python so I began to read the GTG code.
I wrote some really simple unittests for now but the more I will
understand the code and GTG behaviors and the more these tests will
become complex. 
Theses tests use functions and class embedded in
GTG/backends/localfile.py. You can launch gtgunittests.py from the root
directory of the source repository. Later could be nice to have one test
series by module... later.

Tell me if it could help!
Carl Chenet
www.ohmytux.com/belier
#!/usr/bin/python
# -*- coding: utf-8 -*-

"""Unittests for GTG"""

#Standard imports
import unittest

#GTG imports
import GTG.backends.localfile

class GtgUniTests(unittest.TestCase):
    """Unittests for GTG"""

    def test_GTG_backends_localfile_get_name(self):
        """Tests for GTG/backends/localfile/get_name function"""
        res = GTG.backends.localfile.get_name()
        expectedres = "Local File"
        self.assertEqual(res, expectedres)

    def test_GTG_backends_localfile_get_description(self):
        """Tests for GTG/backends/localfile/get_description function"""
        res = GTG.backends.localfile.get_description()
        expectedres = "Your tasks are saved in an XML file located in \
your HOME folder"
        self.assertEqual(res, expectedres)

    def test_GTG_backends_localfile_get_parameters(self):
        """Tests for GTG/backends/localfile/get_parameters function"""
        res = GTG.backends.localfile.get_parameters()
        expectedres = "string"
        self.assertEqual(res['filename'], expectedres)

    def test_GTG_backends_localfile_get_features(self):
        """Tests for GTG/backends/localfile/get_features function"""
        res = GTG.backends.localfile.get_features()
        expectedres = {}
        self.assertEqual(res, expectedres)

    def test_GTG_backends_localfile_get_type(self):
        """Tests for GTG/backends/localfile/get_type function"""
        res = GTG.backends.localfile.get_type()
        expectedres = "readwrite"
        self.assertEqual(res, expectedres)

    def test_GTG_backends_localfile_Backend_get_tasks_list(self):
        """Tests for GTG/backends/localfile/Backend Class"""
        res = GTG.backends.localfile.Backend(
             GTG.backends.localfile.get_parameters())
        expectedres = []
        self.assertEqual(res.get_tasks_list(), expectedres)

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

Attachment: signature.asc
Description: Ceci est une partie de message numériquement signée


Follow ups