source: TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/tests/testdata/testconstants.py @ 5255

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/tests/testdata/testconstants.py@5255
Revision 5255, 6.1 KB checked in by cbyrom, 10 years ago (diff)

Extend OAI Info editor documentation and help pages + improve the
setup config + extend test suite and fix problem with setting
email addresses in providerinfo.

  • Property svn:executable set to *
Line 
1'''
2Common data shared across the test classes.
3
4@author C Byrom, Tessella Apr 2009
5'''
6import os, time
7from oai_info_editor.model.repositoryinfo import RepositoryInfo, createRepositoryInfoWithData
8from oai_info_editor.model.providerinfo import ProviderInfo, createProviderInfoWithData
9from oai_info_editor.model.providerinfocollection import ProviderInfoCollection, createProviderInfoCollectionWithData
10from oai_info_editor.model.user import *
11from xml.etree import cElementTree as ET
12
13def getTestDataDir(dir):
14    if os.path.exists(dir):
15        return dir
16
17    # avoid infinite recursions
18    if dir.count(parentDir) > 10:
19        raise SystemError("Could not find 'testdata' directory - with test config data \
20    - will not run tests until this has been set up correctly")
21   
22    return getTestDataDir(parentDir + dir)
23   
24# NB, directories depend on whether we're running on unix/windows or
25# whether we use nose to run the tests of python unit tests
26parentDir = '..' + os.sep
27
28TEST_DATA_DIR = ""
29try:
30    TEST_DATA_DIR = getTestDataDir('tests' + os.sep + 'testdata' + os.sep)
31except:
32    TEST_DATA_DIR = "C:/Users/byrc/5509/NewEclipseWorkspace/OAIInfoEditor/oai_info_editor/tests/testdata/"
33
34LIB_DATA_DIR = ""
35try:
36    LIB_DATA_DIR = getTestDataDir('oai_info_editor' + os.sep + 'lib' + os.sep)
37except:
38    LIB_DATA_DIR = "C:/Users/byrc/5509/NewEclipseWorkspace/OAIInfoEditor/oai_info_editor/lib/"
39
40HARVEST_COMMAND = 'java %s -cp %sDLESETools.jar:%sjdom-b7.jar:%sxercesImpl.jar:%sxml-apis.jar org.dlese.dpc.oai.harvester.Harvester %s %s %s'\
41    %('%s', LIB_DATA_DIR, LIB_DATA_DIR, LIB_DATA_DIR, LIB_DATA_DIR, '%s', '%s', '%s')
42
43VALID_MAIL_SERVER = 'outbox.rl.ac.uk'
44
45VALID_REP_INFO_FILE = TEST_DATA_DIR + 'test_repository_info.xml'
46f = open(VALID_REP_INFO_FILE, "r")
47REP_INFO_XML_STRING = f.read()
48f.close()
49
50VALID_PROV_INFO_FILE = TEST_DATA_DIR + 'test_provider_info.xml'
51f = open(VALID_PROV_INFO_FILE, "r")
52PROV_INFO_XML_STRING = f.read()
53f.close()
54
55VALID_PROV_INFO_COLLECTION_FILE = TEST_DATA_DIR + 'test_provider_info_collection.xml'
56f = open(VALID_PROV_INFO_COLLECTION_FILE, "r")
57PROV_INFO_COLLECTION_XML_STRING = f.read()
58f.close()
59
60DUMMY_PIC_FILENAME = 'potatoes.xml'
61
62EDITOR_CONFIG_FILE = TEST_DATA_DIR + 'editor.config'
63INVALID_EDITOR_CONFIG_FILE = TEST_DATA_DIR + 'invalid_editor.config'
64
65VALID_REP_NAME_0 = 'PROVIDER1 REP1'
66VALID_REP_NAME_1 = 'PROVIDER2 REP1'
67VALID_REP_NAME_2 = 'PROVIDER2 REP2'
68VALID_REP_NAME_3 = 'PROVIDER2 REP3'
69VALID_REAL_REP_NAME = 'DLESE'
70# NB, the commented out provider is a test one provided by DLESE - but it doesn't work!
71VALID_REAL_REP_URL = 'http://badc.nerc.ac.uk/badc_oai/provider'#'http://dlese.org/oai/provider'
72VALID_REAL_REP_FORMAT = 'dif'#'adn'
73VALID_REP_URL_0 = 'http://rep1.ac.uk'
74VALID_REP_URL = 'http://rep2.ac.uk'
75VALID_DIF_DATA_FORMAT = 'DIF'
76VALID_MDIP_DATA_FORMAT = 'MDIP'
77VALID_DC_DATA_FORMAT = 'DC'
78VALID_SET_SPEC_1 = 'diffy'
79VALID_SET_SPEC_2 = 'mdipy'
80VALID_SET_SPEC_3 = 'dcy'
81VALID_MODIFICATION_DATE = '2001-02-19T17:24:33Z'
82VALID_VERSION = '2'
83VALID_HARVEST_TIME = '09:00'
84VALID_SPLIT_BY_SET = 'True'
85
86VALID_REAL_REPOSITORY_INFO = createRepositoryInfoWithData(VALID_REAL_REP_NAME, 
87                                                          VALID_REAL_REP_URL,
88                                                          VALID_REAL_REP_FORMAT, "",)
89
90REPOSITORY_INFO_0 = createRepositoryInfoWithData(VALID_REP_NAME_0, VALID_REP_URL_0,
91                                                 VALID_DIF_DATA_FORMAT, "",
92                                                 modificationDate = VALID_MODIFICATION_DATE,
93                                                 harvestTime = VALID_HARVEST_TIME,
94                                                 splitBySet = True)
95
96REPOSITORY_INFO_1 = createRepositoryInfoWithData(VALID_REP_NAME_1, VALID_REP_URL,
97                                                 VALID_DIF_DATA_FORMAT, VALID_SET_SPEC_1,
98                                                 modificationDate = VALID_MODIFICATION_DATE,
99                                                 version = '1')
100
101REPOSITORY_INFO_2 = createRepositoryInfoWithData(VALID_REP_NAME_2, VALID_REP_URL,
102                                                 VALID_MDIP_DATA_FORMAT, VALID_SET_SPEC_2,
103                                                 modificationDate = VALID_MODIFICATION_DATE,
104                                                 version = '3')
105
106REPOSITORY_INFO_3 = createRepositoryInfoWithData(VALID_REP_NAME_3, VALID_REP_URL,
107                                                 VALID_DC_DATA_FORMAT, VALID_SET_SPEC_3,
108                                                 modificationDate = VALID_MODIFICATION_DATE,
109                                                 harvestTime = VALID_HARVEST_TIME,
110                                                 splitBySet = True, version = '2')
111VALID_PROVIDER_NAME_1 = "provider1"
112VALID_PROVIDER_NAME_2 = "provider2"
113VALID_PROVIDER_NAME_3 = "provider3"
114VALID_PROVIDER_EMAIL = "BOB@Bob.com"
115ALL_VALID_PROVIDER_NAMES = [VALID_PROVIDER_NAME_1, VALID_PROVIDER_NAME_2, VALID_PROVIDER_NAME_3]
116VALID_REPOSITORY_INFOS_1 = [REPOSITORY_INFO_0]
117VALID_REPOSITORY_INFOS_2 = [REPOSITORY_INFO_1, REPOSITORY_INFO_2, REPOSITORY_INFO_3]
118PROVIDER_INFO_1 = createProviderInfoWithData(VALID_PROVIDER_NAME_1, VALID_REPOSITORY_INFOS_1,
119                                             providerEmail = VALID_PROVIDER_EMAIL)
120PROVIDER_INFO_2 = createProviderInfoWithData(VALID_PROVIDER_NAME_2, VALID_REPOSITORY_INFOS_2)
121PROVIDER_INFO_3 = createProviderInfoWithData(VALID_PROVIDER_NAME_3, [])
122
123VALID_PROVIDER_INFOS = [PROVIDER_INFO_1, PROVIDER_INFO_2, PROVIDER_INFO_3]
124VALID_PIC_FILENAME = "providerInfoCollection.xml"
125VALID_HARVEST_DIR = "tmp_harvest_dir"
126PROVIDER_INFO_COLLECTION = createProviderInfoCollectionWithData(VALID_PIC_FILENAME,
127                                                                VALID_HARVEST_DIR, 
128                                                                VALID_PROVIDER_INFOS)
129
130VALID_USER_ID = 'calum'
131VALID_ADMIN_USER_ID = 'super_calum'
132VALID_PROVIDER_NAMES = [VALID_PROVIDER_NAME_1, VALID_PROVIDER_NAME_3]
133VALID_USER = User(VALID_USER_ID, VALID_PROVIDER_NAMES)
134VALID_ADMIN_USER = User(VALID_USER_ID, ['admin'])
135INVALID_USER = User('frida', [])
136
137#VALID_HARVEST_DIR = 'tmp'
Note: See TracBrowser for help on using the repository browser.