Exemplo n.º 1
0
    def test_db_deletion(self):
        os.remove(self.dbPath)
        self.assertFalse(os.path.exists(self.dbPath))

        Base(".")
        self.assertTrue(os.path.exists(self.dbPath))

        os.remove(self.dbPath)
        os.rmdir(".clsearch")
        self.assertFalse(os.path.exists(self.dbPath))

        Base(".")
        self.assertTrue(os.path.exists(self.dbPath))

        os.remove(self.dbPath)
        os.rmdir(".clsearch")
        self.assertFalse(os.path.exists(self.dbPath))
Exemplo n.º 2
0
class BaseTests(unittest.TestCase):
    def setUp(self):
        self.b = Base()
        self.dbPath = ".clsearch/clsdb.sqlite"

    def test_db_creation(self):
        self.assertRaises(OSError, Base, "/usr")
        Base(".")
        self.assertTrue(os.path.exists(self.dbPath))

    def test_db_deletion(self):
        os.remove(self.dbPath)
        self.assertFalse(os.path.exists(self.dbPath))

        Base(".")
        self.assertTrue(os.path.exists(self.dbPath))

        os.remove(self.dbPath)
        os.rmdir(".clsearch")
        self.assertFalse(os.path.exists(self.dbPath))

        Base(".")
        self.assertTrue(os.path.exists(self.dbPath))

        os.remove(self.dbPath)
        os.rmdir(".clsearch")
        self.assertFalse(os.path.exists(self.dbPath))

    def test_to_unicode(self):
        testStrings = ["", "hello!~", "\x01\x92"]
        for str_ in testStrings:
            str_ = self.b.to_unicode(str_)
            self.assertEqual(type(str_), unicode)

        self.assertRaises(AttributeError, self.b.to_unicode, 123.123)

    def test_get_split_string(self):
        testStrings = {
            u'uni\u0C80code ,,,, string': [u'uni\u0C80code', u'string'],
            'Sigur! Rós': ['Sigur', 'Rós'],
            'Sigur Rós!': ['Sigur', 'Rós', ''],
        }

        for k, v in testStrings.items():
            self.assertEqual(re.split(self.b.get_split_string(), k), v)
Exemplo n.º 3
0
class BaseTests(unittest.TestCase):
    def setUp(self):    
        self.b = Base()
        self.dbPath = ".clsearch/clsdb.sqlite"

    def test_db_creation(self):
        self.assertRaises(OSError, Base, "/usr")
        Base(".")
        self.assertTrue(os.path.exists(self.dbPath))

    def test_db_deletion(self):
        os.remove(self.dbPath)
        self.assertFalse(os.path.exists(self.dbPath))

        Base(".")
        self.assertTrue(os.path.exists(self.dbPath))

        os.remove(self.dbPath)
        os.rmdir(".clsearch")
        self.assertFalse(os.path.exists(self.dbPath))

        Base(".")
        self.assertTrue(os.path.exists(self.dbPath))
        
        os.remove(self.dbPath)
        os.rmdir(".clsearch")
        self.assertFalse(os.path.exists(self.dbPath))

    def test_to_unicode(self):    
        testStrings  = ["", "hello!~", "\x01\x92"]
        for str_ in testStrings:
            str_ = self.b.to_unicode(str_)
            self.assertEqual(type(str_), unicode)
        
        self.assertRaises(AttributeError, self.b.to_unicode, 123.123)

    def test_get_split_string(self):
        testStrings = {
                    u'uni\u0C80code ,,,, string': [u'uni\u0C80code', u'string'],
                    'Sigur! Rós': ['Sigur', 'Rós'],
                    'Sigur Rós!': ['Sigur', 'Rós', ''],
        }
                    
        for k, v in testStrings.items():
            self.assertEqual(re.split(self.b.get_split_string(), k), v)
Exemplo n.º 4
0
 def test_db_creation(self):
     self.assertRaises(OSError, Base, "/usr")
     Base(".")
     self.assertTrue(os.path.exists(self.dbPath))
Exemplo n.º 5
0
 def setUp(self):
     self.b = Base()
     self.dbPath = ".clsearch/clsdb.sqlite"
Exemplo n.º 6
0
 def setUp(self):    
     self.b = Base()
     self.dbPath = ".clsearch/clsdb.sqlite"