PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/tests/gdata_tests/apps/organization/data_test.py

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