Commit 9eac7e71 authored by Christian Ledermann's avatar Christian Ledermann

Merge pull request #11 from IanLee1521/master

Fix typo, add pip requirements file, test for kml.KML.from_string when not a kml string
Thanks 8-)
parents e6f81c5a b520997c
...@@ -9,14 +9,13 @@ python: ...@@ -9,14 +9,13 @@ python:
env: env:
- LXML=true - LXML=true
- LXML=false - LXML=false
# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
# install: PLEASE CHANGE ME # command to install dependencies, e.g. pip install -r requirements.txt
install: install:
- pip install coveralls --use-mirrors - pip install -r requirements/test.txt
- if $LXML == true; then pip install --use-mirrors lxml; fi - if $LXML == true; then pip install lxml; fi
# command to run tests, e.g. python setup.py test # command to run tests, e.g. python setup.py test
script: script:
coverage run --source=fastkml setup.py test coverage run --source=fastkml setup.py test
......
...@@ -28,6 +28,18 @@ fastkml is continually tested with *Travis CI* ...@@ -28,6 +28,18 @@ fastkml is continually tested with *Travis CI*
:target: https://www.ohloh.net/p/fastkml :target: https://www.ohloh.net/p/fastkml
Requirements
============
You can install the requirements for fastkml by using pip:
pip install -r requirements/common.txt
To install packages required for running tests:
pip install -r requirements/test.txt
Limitations Limitations
=========== ===========
......
...@@ -79,12 +79,12 @@ class Link(object): ...@@ -79,12 +79,12 @@ class Link(object):
title = None title = None
# human readable information about the link # human readable information about the link
lenght = None length = None
# the length of the resource, in bytes # the length of the resource, in bytes
def __init__(self, ns=None, href=None, rel=None, type=None, def __init__(self, ns=None, href=None, rel=None, type=None,
hreflang=None, title=None, lenght=None): hreflang=None, title=None, length=None):
if ns == None: if ns == None:
self.ns = NS self.ns = NS
else: else:
...@@ -94,7 +94,7 @@ class Link(object): ...@@ -94,7 +94,7 @@ class Link(object):
self.type = type self.type = type
self.hreflang = hreflang self.hreflang = hreflang
self.title = title self.title = title
self.lenght = lenght self.length = length
def from_string(self, xml_string): def from_string(self, xml_string):
self.from_element(etree.XML(xml_string)) self.from_element(etree.XML(xml_string))
...@@ -117,8 +117,8 @@ class Link(object): ...@@ -117,8 +117,8 @@ class Link(object):
self.hreflang = element.get('hreflang') self.hreflang = element.get('hreflang')
if element.get('title'): if element.get('title'):
self.title = element.get('title') self.title = element.get('title')
if element.get('lenght'): if element.get('length'):
self.lenght = element.get('lenght') self.length = element.get('length')
def etree_element(self): def etree_element(self):
...@@ -135,8 +135,8 @@ class Link(object): ...@@ -135,8 +135,8 @@ class Link(object):
element.set('hreflang', self.hreflang) element.set('hreflang', self.hreflang)
if self.title: if self.title:
element.set('title', self.title) element.set('title', self.title)
if self.lenght: if self.length:
element.set('lenght', self.lenght) element.set('length', self.length)
return element return element
def to_string(self, prettyprint=True): def to_string(self, prettyprint=True):
......
...@@ -685,6 +685,10 @@ class KmlFromStringTestCase( unittest.TestCase ): ...@@ -685,6 +685,10 @@ class KmlFromStringTestCase( unittest.TestCase ):
self.assertFalse('maxLines' in k.to_string()) self.assertFalse('maxLines' in k.to_string())
self.assertTrue('Diffrent Snippet' in k.to_string()) self.assertTrue('Diffrent Snippet' in k.to_string())
def test_from_wrong_string(self):
doc = kml.KML()
self.assertRaises(TypeError, doc.from_string, '<xml></xml>')
class StyleTestCase( unittest.TestCase ): class StyleTestCase( unittest.TestCase ):
...@@ -1333,13 +1337,13 @@ class AtomTestCase( unittest.TestCase ): ...@@ -1333,13 +1337,13 @@ class AtomTestCase( unittest.TestCase ):
l.title="Title" l.title="Title"
l.type="text/html" l.type="text/html"
l.hreflang ='en' l.hreflang ='en'
l.lenght="4096" l.length="4096"
self.assertTrue('href="http://localhost/"' in str(l.to_string())) self.assertTrue('href="http://localhost/"' in str(l.to_string()))
self.assertTrue('rel="alternate"' in str(l.to_string())) self.assertTrue('rel="alternate"' in str(l.to_string()))
self.assertTrue('title="Title"' in str(l.to_string())) self.assertTrue('title="Title"' in str(l.to_string()))
self.assertTrue('hreflang="en"' in str(l.to_string())) self.assertTrue('hreflang="en"' in str(l.to_string()))
self.assertTrue('type="text/html"' in str(l.to_string())) self.assertTrue('type="text/html"' in str(l.to_string()))
self.assertTrue('lenght="4096"' in str(l.to_string())) self.assertTrue('length="4096"' in str(l.to_string()))
self.assertTrue('link' in str(l.to_string())) self.assertTrue('link' in str(l.to_string()))
self.assertTrue('="http://www.w3.org/2005/Atom"' in str(l.to_string())) self.assertTrue('="http://www.w3.org/2005/Atom"' in str(l.to_string()))
l2 = atom.Link() l2 = atom.Link()
......
pygeoif
python-dateutil
-r common.txt
pytest
coveralls
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment