File: data_test.py

package info (click to toggle)
python-gdata 2.0.8-1.1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 17,816 kB
  • ctags: 29,744
  • sloc: python: 50,599; ansic: 150; makefile: 5
file content (83 lines) | stat: -rw-r--r-- 3,306 bytes parent folder | download
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
#!/usr/bin/env python
#
# Copyright (C) 2009 Google Inc.
#
# 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.


__author__ = 'api.roman.public@gmail.com (Roman Nurik)'


import unittest
from gdata import test_data
import gdata.maps.data
import atom.core
import gdata.test_config as conf


class MapsDataTest(unittest.TestCase):

  def testMapEntryFromString(self):
    entry = atom.core.parse(test_data.MAP_ENTRY, gdata.maps.data.Map)
    self.assertEquals(entry.GetUserId(), '208825816854482607313')
    self.assertEquals(entry.GetMapId(), '00046fb45f88fa910bcea')
    self.assertEquals(entry.title.text, 'Untitled')

  def testMapFeedFromString(self):
    feed = atom.core.parse(test_data.MAP_FEED, gdata.maps.data.MapFeed)
    self.assertEquals(len(feed.entry), 1)
    self.assert_(isinstance(feed, gdata.maps.data.MapFeed))
    self.assert_(isinstance(feed.entry[0], gdata.maps.data.Map))
    self.assertEquals(feed.entry[0].GetUserId(), '208825816854482607313')
    self.assertEquals(feed.entry[0].GetMapId(), '00046fb45f88fa910bcea')
    self.assertEquals(feed.entry[0].title.text, 'Untitled')

  def testFeatureEntryFromString(self):
    entry = atom.core.parse(test_data.MAP_FEATURE_ENTRY,
                            gdata.maps.data.Feature)
    self.assertEquals(entry.GetUserId(), '208825816854482607313')
    self.assertEquals(entry.GetMapId(), '00046fb45f88fa910bcea')
    self.assertEquals(entry.GetFeatureId(), '00046fb4632573b19e0b7')
    self.assertEquals(entry.title.text, 'Some feature title')
    self.assertEquals(entry.content.type,
                      'application/vnd.google-earth.kml+xml')
  
  def testFeatureFeedFromString(self):
    feed = atom.core.parse(test_data.MAP_FEATURE_FEED,
                           gdata.maps.data.FeatureFeed)
    self.assertEquals(len(feed.entry), 3)
    self.assert_(isinstance(feed, gdata.maps.data.FeatureFeed))
    self.assert_(isinstance(feed.entry[0], gdata.maps.data.Feature))
    self.assertEquals(feed.entry[0].GetUserId(), '208825816854482607313')
    self.assertEquals(feed.entry[0].GetMapId(), '00046fb45f88fa910bcea')
    self.assertEquals(feed.entry[0].GetFeatureId(), '00046fb4632573b19e0b7')
    self.assertEquals(feed.entry[0].title.text, 'Some feature title')
    self.assertEquals(feed.entry[0].content.type,
                      'application/vnd.google-earth.kml+xml')
    self.assertEquals(type(feed.entry[0].content), gdata.maps.data.KmlContent)


class KmlContentTest(unittest.TestCase):

  def testKmlContentFromString(self):
    content = gdata.maps.data.KmlContent(kml=test_data.MAP_FEATURE_KML)
    self.assertEquals(len(content.children), 1)
    self.assertEquals(content.children[0].tag, 'Placemark')


def suite():
  return conf.build_suite([MapsDataTest, KmlContentTest])


if __name__ == '__main__':
  unittest.main()