Mercurial > p > roundup > code
comparison roundup/test/memorydb.py @ 6361:58817c3bf471
Fix roundup/test
Move the test-detectors in tx_Source_detector.py to roundup/test for two
reasons: It's used in the memorydb convenience functions and it may be
useful in other tests. Make the prefix a paramter of the convenience
functions to be usable in other tests.
| author | Ralf Schlatterbeck <rsc@runtux.com> |
|---|---|
| date | Tue, 30 Mar 2021 14:16:28 +0200 |
| parents | a77a7d04ed23 |
| children | 7f00fc5958ca |
comparison
equal
deleted
inserted
replaced
| 6360:a77a7d04ed23 | 6361:58817c3bf471 |
|---|---|
| 14 from roundup.backends import indexer_dbm | 14 from roundup.backends import indexer_dbm |
| 15 from roundup.backends import sessions_dbm | 15 from roundup.backends import sessions_dbm |
| 16 from roundup.backends import indexer_common | 16 from roundup.backends import indexer_common |
| 17 from roundup.support import ensureParentsExist | 17 from roundup.support import ensureParentsExist |
| 18 from roundup.anypy.strings import s2b | 18 from roundup.anypy.strings import s2b |
| 19 | 19 from roundup.test.tx_Source_detector import init as tx_Source_init |
| 20 def new_config(debug=False): | 20 |
| 21 default_prefix = '../../share/roundup/templates/classic' | |
| 22 | |
| 23 def new_config(debug=False, prefix=default_prefix): | |
| 24 if not prefix.startswith('/'): | |
| 25 prefix = os.path.join (os.path.dirname(__file__), prefix) | |
| 21 config = configuration.CoreConfig() | 26 config = configuration.CoreConfig() |
| 22 config.detectors = configuration.UserConfig("share/roundup/templates/classic/detectors/config.ini") | 27 config.detectors = configuration.UserConfig( |
| 23 config.ext = configuration.UserConfig("share/roundup/templates/classic/extensions/config.ini") | 28 os.path.join(prefix, "detectors/config.ini")) |
| 29 config.ext = configuration.UserConfig( | |
| 30 os.path.join(prefix, "extensions/config.ini")) | |
| 24 config.DATABASE = "db" | 31 config.DATABASE = "db" |
| 25 #config.logging = MockNull() | 32 #config.logging = MockNull() |
| 26 # these TRACKER_WEB and MAIL_DOMAIN values are used in mailgw tests | 33 # these TRACKER_WEB and MAIL_DOMAIN values are used in mailgw tests |
| 27 if debug: | 34 if debug: |
| 28 config.LOGGING_LEVEL = "DEBUG" | 35 config.LOGGING_LEVEL = "DEBUG" |
| 29 config.MAIL_DOMAIN = "your.tracker.email.domain.example" | 36 config.MAIL_DOMAIN = "your.tracker.email.domain.example" |
| 30 config.TRACKER_WEB = "http://tracker.example/cgi-bin/roundup.cgi/bugs/" | 37 config.TRACKER_WEB = "http://tracker.example/cgi-bin/roundup.cgi/bugs/" |
| 31 return config | 38 return config |
| 32 | 39 |
| 33 def create(journaltag, create=True, debug=False): | 40 def create(journaltag, create=True, debug=False, prefix=default_prefix): |
| 34 db = Database(new_config(debug), journaltag) | 41 db = Database(new_config(debug), journaltag) |
| 35 | 42 |
| 36 # load standard schema | 43 # load standard schema |
| 37 schema = os.path.join(os.path.dirname(__file__), | 44 if not prefix.startswith('/'): |
| 38 '../share/roundup/templates/classic/schema.py') | 45 prefix = os.path.join (os.path.dirname(__file__), prefix) |
| 46 schema = os.path.join(prefix, 'schema.py') | |
| 39 vars = hyperdb.__dict__ | 47 vars = hyperdb.__dict__ |
| 40 vars['Class'] = Class | 48 vars['Class'] = Class |
| 41 vars['FileClass'] = FileClass | 49 vars['FileClass'] = FileClass |
| 42 vars['IssueClass'] = IssueClass | 50 vars['IssueClass'] = IssueClass |
| 43 vars['db'] = db | 51 vars['db'] = db |
| 44 exec(compile(open(schema).read(), schema, 'exec'), vars) | 52 exec(compile(open(schema).read(), schema, 'exec'), vars) |
| 45 initial_data = os.path.join(os.path.dirname(__file__), | 53 initial_data = os.path.join(prefix, 'initial_data.py') |
| 46 '../share/roundup/templates/classic/initial_data.py') | |
| 47 vars = dict(db=db, admin_email='admin@test.com', | 54 vars = dict(db=db, admin_email='admin@test.com', |
| 48 adminpw=password.Password('sekrit')) | 55 adminpw=password.Password('sekrit')) |
| 49 exec(compile(open(initial_data).read(), initial_data, 'exec'), vars) | 56 exec(compile(open(initial_data).read(), initial_data, 'exec'), vars) |
| 50 | 57 |
| 51 # load standard detectors | 58 # load standard detectors |
| 52 thisdir = os.path.dirname(__file__) | 59 dirname = os.path.join(prefix, 'detectors') |
| 53 dirname = os.path.join(thisdir, | |
| 54 '../share/roundup/templates/classic/detectors') | |
| 55 for fn in os.listdir(dirname): | 60 for fn in os.listdir(dirname): |
| 56 if not fn.endswith('.py'): continue | 61 if not fn.endswith('.py'): continue |
| 57 vars = {} | 62 vars = {} |
| 58 exec(compile(open(os.path.join(dirname, fn)).read(), | 63 exec(compile(open(os.path.join(dirname, fn)).read(), |
| 59 os.path.join(dirname, fn), 'exec'), vars) | 64 os.path.join(dirname, fn), 'exec'), vars) |
| 60 vars['init'](db) | 65 vars['init'](db) |
| 61 | 66 |
| 62 vars = {} | 67 tx_Source_init(db) |
| 63 exec(compile(open(os.path.join(thisdir, "tx_Source_detector.py")).read(), | |
| 64 os.path.join(thisdir, "tx_Source_detector.py"), 'exec'), vars) | |
| 65 vars['init'](db) | |
| 66 | 68 |
| 67 ''' | 69 ''' |
| 68 status = Class(db, "status", name=String()) | 70 status = Class(db, "status", name=String()) |
| 69 status.setkey("name") | 71 status.setkey("name") |
| 70 priority = Class(db, "priority", name=String(), order=String()) | 72 priority = Class(db, "priority", name=String(), order=String()) |
