Commit 428e1e9db0ee3243b88f38ce95188f8304b58ab3

Authored by Tássia Camões Araújo
1 parent a68a414f
Exists in master and in 1 other branch add_vagrant

Added singleton tests.

src/tests/runner.py
... ... @@ -21,6 +21,8 @@ __license__ = """
21 21  
22 22 import unittest2
23 23 import user_tests
  24 +import singleton_tests
24 25  
25 26 runner = unittest2.TextTestRunner()
26 27 runner.run(user_tests.suite())
  28 +runner.run(singleton_tests.suite())
... ...
src/tests/singleton_tests.py 0 → 100755
... ... @@ -0,0 +1,37 @@
  1 +#!/usr/bin/env python
  2 +"""
  3 + singletonTests - Singleton class test case
  4 +"""
  5 +__author__ = "Tassia Camoes Araujo <tassia@gmail.com>"
  6 +__copyright__ = "Copyright (C) 2011 Tassia Camoes Araujo"
  7 +__license__ = """
  8 + This program is free software: you can redistribute it and/or modify
  9 + it under the terms of the GNU General Public License as published by
  10 + the Free Software Foundation, either version 3 of the License, or
  11 + (at your option) any later version.
  12 +
  13 + This program is distributed in the hope that it will be useful,
  14 + but WITHOUT ANY WARRANTY; without even the implied warranty of
  15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16 + GNU General Public License for more details.
  17 +
  18 + You should have received a copy of the GNU General Public License
  19 + along with this program. If not, see <http://www.gnu.org/licenses/>.
  20 +"""
  21 +
  22 +import unittest2
  23 +import sys
  24 +sys.path.insert(0,'../')
  25 +from singleton import Singleton
  26 +
  27 +def suite():
  28 + return unittest2.TestLoader().loadTestsFromTestCase(SingletonTests)
  29 +
  30 +class SingletonTests(unittest2.TestCase):
  31 + def test_creation(self):
  32 + object_1 = Singleton()
  33 + object_2 = Singleton()
  34 + self.assertEqual(id(object_1),id(object_2))
  35 +
  36 +if __name__ == '__main__':
  37 + unittest2.main()
... ...
src/tests/user_tests.py
... ... @@ -28,7 +28,6 @@ sys.path.insert(0,&#39;../&#39;)
28 28 from user import *
29 29 from config import *
30 30 from data import *
31   -from pxi import *
32 31  
33 32 def suite():
34 33 return unittest2.TestLoader().loadTestsFromTestCase(UserTests)
... ... @@ -39,7 +38,7 @@ class UserTests(unittest2.TestCase):
39 38 cfg = Config()
40 39 #self.axi = xapian.Database(cfg.axi)
41 40 self.user = User({"gimp":1,"aaphoto":1,"eog":1,"emacs":1})
42   - self.pxi = PkgXapianIndex()
  41 + self.pxi = PkgXapianIndex("package-xapian-index")
43 42  
44 43 def test_hash(self):
45 44 new_user = User(dict())
... ...