source: tagsplugin/trunk/tractags/tests/xmlrpc.py

Last change on this file was 16943, checked in by Ryan J Ollos, 6 years ago

TracTags 0.10dev: Make compatible with Trac 1.3.3dev

Fixes #13316.

File size: 2.0 KB
Line 
1# -*- coding: utf-8 -*-
2#
3# Copyright (C) 2014 Steffen Hoffmann <hoff.st@web.de>
4#
5# This software is licensed as described in the file COPYING, which
6# you should have received as part of this distribution.
7#
8
9import shutil
10import tempfile
11import unittest
12
13from trac.perm import PermissionCache, PermissionSystem
14from trac.test import EnvironmentStub, MockRequest
15
16from tractags.api import TagSystem
17from tractags.db import TagSetup
18from tractags.xmlrpc import TagRPC
19
20
21class TagRPCTestCase(unittest.TestCase):
22
23    def setUp(self):
24        self.env = EnvironmentStub(default_data=True,
25                                   enable=['trac.*', 'tractags.*'])
26        self.env.path = tempfile.mkdtemp()
27        setup = TagSetup(self.env)
28        # Current tractags schema is partially setup with enabled component.
29        #   Revert these changes for getting a clean setup.
30        self._revert_tractags_schema_init()
31        setup.upgrade_environment()
32
33        self.perms = PermissionSystem(self.env)
34        self.tag_s = TagSystem(self.env)
35
36        # Populate table with initial test data.
37        self.env.db_transaction("""
38            INSERT INTO tags (tagspace, name, tag)
39            VALUES ('wiki', 'WikiStart', 'tag1')
40            """)
41
42        self.req = MockRequest(self.env, authname='editor')
43
44    def tearDown(self):
45        self.env.shutdown()
46        shutil.rmtree(self.env.path)
47
48    # Helpers
49
50    def _revert_tractags_schema_init(self):
51        with self.env.db_transaction as db:
52            db("DROP TABLE IF EXISTS tags")
53            db("DROP TABLE IF EXISTS tags_change")
54            db("DELETE FROM system WHERE name='tags_version'")
55            db("DELETE FROM permission WHERE action %s" % db.like(),
56               ('TAGS_%',))
57
58    # Tests
59
60    def test_init(self):
61        TagRPC(self.env)
62
63
64def test_suite():
65    suite = unittest.TestSuite()
66    suite.addTest(unittest.makeSuite(TagRPCTestCase))
67    return suite
68
69
70if __name__ == '__main__':
71    unittest.main(defaultTest='test_suite')
Note: See TracBrowser for help on using the repository browser.