Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typo, add pip requirements file, test for kml.KML.from_string when not a kml string #11

Merged
merged 6 commits into from Jul 17, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 4 additions & 5 deletions .travis.yml
Expand Up @@ -9,14 +9,13 @@ python:
env:
- LXML=true
- 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:
- pip install coveralls --use-mirrors
- if $LXML == true; then pip install --use-mirrors lxml; fi
- pip install -r requirements/test.txt
- if $LXML == true; then pip install lxml; fi

# command to run tests, e.g. python setup.py test

script:
coverage run --source=fastkml setup.py test

Expand Down
12 changes: 12 additions & 0 deletions README.rst
Expand Up @@ -28,6 +28,18 @@ fastkml is continually tested with *Travis CI*
: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
===========

Expand Down
14 changes: 7 additions & 7 deletions fastkml/atom.py
Expand Up @@ -79,12 +79,12 @@ class Link(object):
title = None
# human readable information about the link

lenght = None
length = None
# the length of the resource, in bytes


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:
self.ns = NS
else:
Expand All @@ -94,7 +94,7 @@ def __init__(self, ns=None, href=None, rel=None, type=None,
self.type = type
self.hreflang = hreflang
self.title = title
self.lenght = lenght
self.length = length

def from_string(self, xml_string):
self.from_element(etree.XML(xml_string))
Expand All @@ -117,8 +117,8 @@ def from_element(self, element):
self.hreflang = element.get('hreflang')
if element.get('title'):
self.title = element.get('title')
if element.get('lenght'):
self.lenght = element.get('lenght')
if element.get('length'):
self.length = element.get('length')


def etree_element(self):
Expand All @@ -135,8 +135,8 @@ def etree_element(self):
element.set('hreflang', self.hreflang)
if self.title:
element.set('title', self.title)
if self.lenght:
element.set('lenght', self.lenght)
if self.length:
element.set('length', self.length)
return element

def to_string(self, prettyprint=True):
Expand Down
8 changes: 6 additions & 2 deletions fastkml/test_main.py
Expand Up @@ -685,6 +685,10 @@ def test_snippet(self):
self.assertFalse('maxLines' 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 ):

Expand Down Expand Up @@ -1333,13 +1337,13 @@ def test_link(self):
l.title="Title"
l.type="text/html"
l.hreflang ='en'
l.lenght="4096"
l.length="4096"
self.assertTrue('href="http://localhost/"' 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('hreflang="en"' 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('="http://www.w3.org/2005/Atom"' in str(l.to_string()))
l2 = atom.Link()
Expand Down
2 changes: 2 additions & 0 deletions requirements/common.txt
@@ -0,0 +1,2 @@
pygeoif
python-dateutil
4 changes: 4 additions & 0 deletions requirements/test.txt
@@ -0,0 +1,4 @@
-r common.txt

pytest
coveralls