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

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

Initial check in of code for the OAI Info Editor pylons based web app.

This includes basic controllers for viewing provider info - with the
associated repository info. Also included is the model and dal layer,
allowing the provider info to be processed and imported/exported to
XML file. Unit tests for the dal and model packages are included.
Templates for rendering provider and repository info are included.

  • 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   
34VALID_REP_INFO_FILE = TEST_DATA_DIR + 'test_repository_info.xml'
35f = open(VALID_REP_INFO_FILE, "r")
36REP_INFO_XML_STRING = f.read()
37f.close()
38
39VALID_PROV_INFO_FILE = TEST_DATA_DIR + 'test_provider_info.xml'
40f = open(VALID_PROV_INFO_FILE, "r")
41PROV_INFO_XML_STRING = f.read()
42f.close()
43
44VALID_PROV_INFO_COLLECTION_FILE = TEST_DATA_DIR + 'test_provider_info_collection.xml'
45f = open(VALID_PROV_INFO_COLLECTION_FILE, "r")
46PROV_INFO_COLLECTION_XML_STRING = f.read()
47f.close()
48
49DUMMY_PIC_FILENAME = 'potatoes.xml'
50
51EDITOR_CONFIG_FILE = TEST_DATA_DIR + 'editor.config'
52INVALID_EDITOR_CONFIG_FILE = TEST_DATA_DIR + 'invalid_editor.config'
53
54VALID_REP_NAME_0 = 'PROVIDER1 REP1'
55VALID_REP_NAME_1 = 'PROVIDER2 REP1'
56VALID_REP_NAME_2 = 'PROVIDER2 REP2'
57VALID_REP_NAME_3 = 'PROVIDER2 REP3'
58VALID_REP_URL_0 = 'http://rep1.ac.uk'
59VALID_REP_URL = 'http://rep2.ac.uk'
60VALID_DIF_DATA_FORMAT = 'DIF'
61VALID_MDIP_DATA_FORMAT = 'MDIP'
62VALID_DC_DATA_FORMAT = 'DC'
63VALID_SET_SPEC_1 = 'diffy'
64VALID_SET_SPEC_2 = 'mdipy'
65VALID_SET_SPEC_3 = 'dcy'
66VALID_MODIFICATION_DATE = '2001-02-19T17:24:33Z'
67VALID_VERSION = '2'
68VALID_HARVEST_TIME = '09:00'
69VALID_SPLIT_BY_SET = 'True'
70
71REPOSITORY_INFO_0 = createRepositoryInfoWithData(VALID_REP_NAME_0, VALID_REP_URL_0,
72                                                 VALID_DIF_DATA_FORMAT, "",
73                                                 modificationDate = VALID_MODIFICATION_DATE,
74                                                 harvestTime = VALID_HARVEST_TIME,
75                                                 splitBySet = True)
76
77REPOSITORY_INFO_1 = createRepositoryInfoWithData(VALID_REP_NAME_1, VALID_REP_URL,
78                                                 VALID_DIF_DATA_FORMAT, VALID_SET_SPEC_1,
79                                                 modificationDate = VALID_MODIFICATION_DATE,
80                                                 version = '1')
81
82REPOSITORY_INFO_2 = createRepositoryInfoWithData(VALID_REP_NAME_2, VALID_REP_URL,
83                                                 VALID_MDIP_DATA_FORMAT, VALID_SET_SPEC_2,
84                                                 modificationDate = VALID_MODIFICATION_DATE,
85                                                 version = '3')
86
87REPOSITORY_INFO_3 = createRepositoryInfoWithData(VALID_REP_NAME_3, VALID_REP_URL,
88                                                 VALID_DC_DATA_FORMAT, VALID_SET_SPEC_3,
89                                                 modificationDate = VALID_MODIFICATION_DATE,
90                                                 harvestTime = VALID_HARVEST_TIME,
91                                                 splitBySet = True, version = '2')
92VALID_PROVIDER_NAME_1 = "provider1"
93VALID_PROVIDER_NAME_2 = "provider2"
94VALID_PROVIDER_NAME_3 = "provider3"
95ALL_VALID_PROVIDER_NAMES = [VALID_PROVIDER_NAME_1, VALID_PROVIDER_NAME_2, VALID_PROVIDER_NAME_3]
96VALID_REPOSITORY_INFOS_1 = [REPOSITORY_INFO_0]
97VALID_REPOSITORY_INFOS_2 = [REPOSITORY_INFO_1, REPOSITORY_INFO_2, REPOSITORY_INFO_3]
98PROVIDER_INFO_1 = createProviderInfoWithData(VALID_PROVIDER_NAME_1, VALID_REPOSITORY_INFOS_1)
99PROVIDER_INFO_2 = createProviderInfoWithData(VALID_PROVIDER_NAME_2, VALID_REPOSITORY_INFOS_2)
100PROVIDER_INFO_3 = createProviderInfoWithData(VALID_PROVIDER_NAME_3, [])
101
102VALID_PROVIDER_INFOS = [PROVIDER_INFO_1, PROVIDER_INFO_2, PROVIDER_INFO_3]
103VALID_PIC_FILENAME = "providerInfoCollection.xml"
104VALID_HARVEST_DIR = "/tmp/harvest_me_now/"
105PROVIDER_INFO_COLLECTION = createProviderInfoCollectionWithData(VALID_PIC_FILENAME,
106                                                                VALID_HARVEST_DIR, 
107                                                                VALID_PROVIDER_INFOS)
108
109VALID_USER_ID = 'calum'
110VALID_ADMIN_USER_ID = 'super_calum'
111VALID_PROVIDER_NAMES = [VALID_PROVIDER_NAME_1, VALID_PROVIDER_NAME_3]
112VALID_USER = User(VALID_USER_ID, VALID_PROVIDER_NAMES)
113VALID_ADMIN_USER = User(VALID_USER_ID, ['admin'])
114INVALID_USER = User('frida', [])
Note: See TracBrowser for help on using the repository browser.