root/galaxy-central/eggs/GeneTrack-2.0.0_beta_1_dev_48da9e998f0caf01c5be731e926f4b0481f658f0-py2.6.egg/tests/authorize_tests.py

リビジョン 3, 2.2 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1import testlib
2import os, unittest, random
3from django.test import utils
4from django.db import connection
5from django.conf import settings
6from genetrack import conf, util, logger
7from genetrack.server.scripts import initializer
8from genetrack.server.web import html
9from django.contrib.auth.models import User
10from django.core.files import File
11
12class AuthorizeTest( unittest.TestCase ):
13    """
14    Tests the models
15    """
16    def setUp(self):
17        "Setting up the tests database for data insert"
18        self.old_name = settings.DATABASE_NAME
19        utils.setup_test_environment()
20        connection.creation.create_test_db(verbosity=0, autoclobber=True)
21        options = util.Params(test_mode=True, delete_everything=False, flush=False, verbosity=0)
22        fname = conf.testdata('test-users.csv')
23        initializer.load_users(fname, options)
24       
25
26    def tearDown(self):
27        "Tearing down the database after test"
28        connection.creation.destroy_test_db(self.old_name, 0)
29        utils.teardown_test_environment()
30   
31    def test_data_creation(self):
32        """
33        Create datasets
34        """
35       
36        # it seems that importing it earlier messes up the test database setup
37        from genetrack.server.web import authorize
38
39        john = User.objects.get(username='johndoe')
40        project = authorize.create_project(user=john, name="Test project")
41        stream = File( open(conf.testdata('test-users.csv')) )
42        data = authorize.create_data(user=john, pid=project.id, stream=stream, name="Test data")
43
44        # project counts update
45        project = authorize.get_project(user=john, pid=project.id)
46        self.assertEqual(project.data_count, 1)
47
48        # testing data deletion
49        authorize.delete_data(user=john, pid=project.id, dids=[data.id])
50        project = authorize.get_project(user=john, pid=project.id)
51        self.assertEqual(project.data_count, 0)
52
53    def test_two(self):
54        pass
55
56def get_suite():
57    "Returns the testsuite"
58    tests  = [
59        AuthorizeTest,
60    ]
61
62    return testlib.make_suite( tests )
63
64if __name__ == '__main__':
65    suite = get_suite()
66    logger.disable('DEBUG')
67    unittest.TextTestRunner(verbosity=2).run( suite )
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。