1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
#!/usr/bin/python2.4
#
# Copyright 2011 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Data model tests for the Organization Unit Provisioning API."""
__author__ = 'Gunjan Sharma <gunjansharma@google.com>'
import unittest
import atom.core
from gdata import test_data
import gdata.apps.organization.data
import gdata.test_config as conf
class CustomerIdEntryTest(unittest.TestCase):
def setUp(self):
self.entry = atom.core.parse(test_data.ORGANIZATION_UNIT_CUSTOMER_ID_ENTRY,
gdata.apps.organization.data.CustomerIdEntry)
def testCustomerIdEntryFromString(self):
self.assert_(isinstance(self.entry,
gdata.apps.organization.data.CustomerIdEntry))
self.assertEquals(self.entry.customer_id, 'C123A456B')
self.assertEquals(self.entry.customer_org_unit_name, 'example.com')
self.assertEquals(self.entry.customer_org_unit_description, 'example.com')
self.assertEquals(self.entry.org_unit_name, 'example.com')
self.assertEquals(self.entry.org_unit_description, 'tempdescription')
class OrgUnitEntryTest(unittest.TestCase):
def setUp(self):
self.entry = atom.core.parse(test_data.ORGANIZATION_UNIT_ORGUNIT_ENTRY,
gdata.apps.organization.data.OrgUnitEntry)
self.feed = atom.core.parse(test_data.ORGANIZATION_UNIT_ORGUNIT_FEED,
gdata.apps.organization.data.OrgUnitFeed)
def testOrgUnitEntryFromString(self):
self.assert_(isinstance(self.entry,
gdata.apps.organization.data.OrgUnitEntry))
self.assertEquals(self.entry.org_unit_description, 'New Test Org')
self.assertEquals(self.entry.org_unit_name, 'Test Organization')
self.assertEquals(self.entry.org_unit_path, 'Test/Test+Organization')
self.assertEquals(self.entry.parent_org_unit_path, 'Test')
self.assertEquals(self.entry.org_unit_block_inheritance, 'false')
def testOrgUnitFeedFromString(self):
self.assertEquals(len(self.feed.entry), 2)
self.assert_(isinstance(self.feed,
gdata.apps.organization.data.OrgUnitFeed))
self.assert_(isinstance(self.feed.entry[0],
gdata.apps.organization.data.OrgUnitEntry))
self.assert_(isinstance(self.feed.entry[1],
gdata.apps.organization.data.OrgUnitEntry))
self.assertEquals(
self.feed.entry[0].find_edit_link(),
('https://apps-apis.google.com/a/feeds/orgunit/2.0/'
'C123A456B/testOrgUnit92'))
self.assertEquals(self.feed.entry[0].org_unit_description, 'test92')
self.assertEquals(self.feed.entry[0].org_unit_name, 'testOrgUnit92')
self.assertEquals(self.feed.entry[0].org_unit_path, 'Test/testOrgUnit92')
self.assertEquals(self.feed.entry[0].parent_org_unit_path, 'Test')
self.assertEquals(self.feed.entry[0].org_unit_block_inheritance, 'false')
self.assertEquals(
self.feed.entry[1].find_edit_link(),
('https://apps-apis.google.com/a/feeds/orgunit/2.0/'
'C123A456B/testOrgUnit93'))
self.assertEquals(self.feed.entry[1].org_unit_description, 'test93')
self.assertEquals(self.feed.entry[1].org_unit_name, 'testOrgUnit93')
self.assertEquals(self.feed.entry[1].org_unit_path, 'Test/testOrgUnit93')
self.assertEquals(self.feed.entry[1].parent_org_unit_path, 'Test')
self.assertEquals(self.feed.entry[1].org_unit_block_inheritance, 'false')
class OrgUserEntryTest(unittest.TestCase):
def setUp(self):
self.entry = atom.core.parse(test_data.ORGANIZATION_UNIT_ORGUSER_ENTRY,
gdata.apps.organization.data.OrgUserEntry)
self.feed = atom.core.parse(test_data.ORGANIZATION_UNIT_ORGUSER_FEED,
gdata.apps.organization.data.OrgUserFeed)
def testOrgUserEntryFromString(self):
self.assert_(isinstance(self.entry,
gdata.apps.organization.data.OrgUserEntry))
self.assertEquals(self.entry.user_email, 'admin@example.com')
self.assertEquals(self.entry.org_unit_path, 'Test')
def testOrgUserFeedFromString(self):
self.assertEquals(len(self.feed.entry), 2)
self.assert_(isinstance(self.feed,
gdata.apps.organization.data.OrgUserFeed))
self.assert_(isinstance(self.feed.entry[0],
gdata.apps.organization.data.OrgUserEntry))
self.assert_(isinstance(self.feed.entry[1],
gdata.apps.organization.data.OrgUserEntry))
self.assertEquals(
self.feed.entry[0].find_edit_link(),
('https://apps-apis.google.com/a/feeds/orguser/2.0/'
'C123A456B/user720430%40example.com'))
self.assertEquals(self.feed.entry[0].user_email, 'user720430@example.com')
self.assertEquals(self.feed.entry[0].org_unit_path, 'Test')
self.assertEquals(
self.feed.entry[1].find_edit_link(),
('https://apps-apis.google.com/a/feeds/orguser/2.0/'
'C123A456B/user832648%40example.com'))
self.assertEquals(self.feed.entry[1].user_email, 'user832648@example.com')
self.assertEquals(self.feed.entry[1].org_unit_path, 'Test')
def suite():
return conf.build_suite([OrgUnitEntryTest, OrgUserEntryTest])
if __name__ == '__main__':
unittest.main()
|