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

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

Add Harvester class to run the jOAI Harvester API and run repository
harvests. Add code throughout the app to allow harvests to be
ran from the UI. Add new test data and tests to exercise the new
functionality and adjust the config file to allow input of required
harvest data. Add confirmation pop up when running deletes.

  • 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_REP_INFO_FILE = TEST_DATA_DIR + 'test_repository_info.xml'
44f = open(VALID_REP_INFO_FILE, "r")
45REP_INFO_XML_STRING = f.read()
46f.close()
47
48VALID_PROV_INFO_FILE = TEST_DATA_DIR + 'test_provider_info.xml'
49f = open(VALID_PROV_INFO_FILE, "r")
50PROV_INFO_XML_STRING = f.read()
51f.close()
52
53VALID_PROV_INFO_COLLECTION_FILE = TEST_DATA_DIR + 'test_provider_info_collection.xml'
54f = open(VALID_PROV_INFO_COLLECTION_FILE, "r")
55PROV_INFO_COLLECTION_XML_STRING = f.read()
56f.close()
57
58DUMMY_PIC_FILENAME = 'potatoes.xml'
59
60EDITOR_CONFIG_FILE = TEST_DATA_DIR + 'editor.config'
61INVALID_EDITOR_CONFIG_FILE = TEST_DATA_DIR + 'invalid_editor.config'
62
63VALID_REP_NAME_0 = 'PROVIDER1 REP1'
64VALID_REP_NAME_1 = 'PROVIDER2 REP1'
65VALID_REP_NAME_2 = 'PROVIDER2 REP2'
66VALID_REP_NAME_3 = 'PROVIDER2 REP3'
67VALID_REAL_REP_NAME = 'DLESE'
68# NB, the commented out provider is a test one provided by DLESE - but it doesn't work!
69VALID_REAL_REP_URL = 'http://badc.nerc.ac.uk/badc_oai/provider'#'http://dlese.org/oai/provider'
70VALID_REAL_REP_FORMAT = 'dif'#'adn'
71VALID_REP_URL_0 = 'http://rep1.ac.uk'
72VALID_REP_URL = 'http://rep2.ac.uk'
73VALID_DIF_DATA_FORMAT = 'DIF'
74VALID_MDIP_DATA_FORMAT = 'MDIP'
75VALID_DC_DATA_FORMAT = 'DC'
76VALID_SET_SPEC_1 = 'diffy'
77VALID_SET_SPEC_2 = 'mdipy'
78VALID_SET_SPEC_3 = 'dcy'
79VALID_MODIFICATION_DATE = '2001-02-19T17:24:33Z'
80VALID_VERSION = '2'
81VALID_HARVEST_TIME = '09:00'
82VALID_SPLIT_BY_SET = 'True'
83
84VALID_REAL_REPOSITORY_INFO = createRepositoryInfoWithData(VALID_REAL_REP_NAME, 
85                                                          VALID_REAL_REP_URL,
86                                                          VALID_REAL_REP_FORMAT, "",)
87
88REPOSITORY_INFO_0 = createRepositoryInfoWithData(VALID_REP_NAME_0, VALID_REP_URL_0,
89                                                 VALID_DIF_DATA_FORMAT, "",
90                                                 modificationDate = VALID_MODIFICATION_DATE,
91                                                 harvestTime = VALID_HARVEST_TIME,
92                                                 splitBySet = True)
93
94REPOSITORY_INFO_1 = createRepositoryInfoWithData(VALID_REP_NAME_1, VALID_REP_URL,
95                                                 VALID_DIF_DATA_FORMAT, VALID_SET_SPEC_1,
96                                                 modificationDate = VALID_MODIFICATION_DATE,
97                                                 version = '1')
98
99REPOSITORY_INFO_2 = createRepositoryInfoWithData(VALID_REP_NAME_2, VALID_REP_URL,
100                                                 VALID_MDIP_DATA_FORMAT, VALID_SET_SPEC_2,
101                                                 modificationDate = VALID_MODIFICATION_DATE,
102                                                 version = '3')
103
104REPOSITORY_INFO_3 = createRepositoryInfoWithData(VALID_REP_NAME_3, VALID_REP_URL,
105                                                 VALID_DC_DATA_FORMAT, VALID_SET_SPEC_3,
106                                                 modificationDate = VALID_MODIFICATION_DATE,
107                                                 harvestTime = VALID_HARVEST_TIME,
108                                                 splitBySet = True, version = '2')
109VALID_PROVIDER_NAME_1 = "provider1"
110VALID_PROVIDER_NAME_2 = "provider2"
111VALID_PROVIDER_NAME_3 = "provider3"
112ALL_VALID_PROVIDER_NAMES = [VALID_PROVIDER_NAME_1, VALID_PROVIDER_NAME_2, VALID_PROVIDER_NAME_3]
113VALID_REPOSITORY_INFOS_1 = [REPOSITORY_INFO_0]
114VALID_REPOSITORY_INFOS_2 = [REPOSITORY_INFO_1, REPOSITORY_INFO_2, REPOSITORY_INFO_3]
115PROVIDER_INFO_1 = createProviderInfoWithData(VALID_PROVIDER_NAME_1, VALID_REPOSITORY_INFOS_1)
116PROVIDER_INFO_2 = createProviderInfoWithData(VALID_PROVIDER_NAME_2, VALID_REPOSITORY_INFOS_2)
117PROVIDER_INFO_3 = createProviderInfoWithData(VALID_PROVIDER_NAME_3, [])
118
119VALID_PROVIDER_INFOS = [PROVIDER_INFO_1, PROVIDER_INFO_2, PROVIDER_INFO_3]
120VALID_PIC_FILENAME = "providerInfoCollection.xml"
121VALID_HARVEST_DIR = "/tmp/harvest_me_now/"
122PROVIDER_INFO_COLLECTION = createProviderInfoCollectionWithData(VALID_PIC_FILENAME,
123                                                                VALID_HARVEST_DIR, 
124                                                                VALID_PROVIDER_INFOS)
125
126VALID_USER_ID = 'calum'
127VALID_ADMIN_USER_ID = 'super_calum'
128VALID_PROVIDER_NAMES = [VALID_PROVIDER_NAME_1, VALID_PROVIDER_NAME_3]
129VALID_USER = User(VALID_USER_ID, VALID_PROVIDER_NAMES)
130VALID_ADMIN_USER = User(VALID_USER_ID, ['admin'])
131INVALID_USER = User('frida', [])
132
133VALID_HARVEST_DIR = 'tmp/'
Note: See TracBrowser for help on using the repository browser.