Skip to content

Commit

Permalink
test for enclosed-area() function
Browse files Browse the repository at this point in the history
  • Loading branch information
ukanga authored and ukanga committed Dec 24, 2015
1 parent 4474c2b commit c4745e7
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
Binary file added pyxform/tests/example_xls/area.xlsx
Binary file not shown.
19 changes: 19 additions & 0 deletions pyxform/tests/test_area.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from unittest import TestCase
from pyxform.builder import create_survey_from_path
import utils
import os
import codecs


class AreaTests(TestCase):

maxDiff = None

def test_create_from_path(self):
path = utils.path_to_text_fixture("area.xlsx")
survey = create_survey_from_path(path)
path = os.path.join(
os.path.dirname(__file__), 'test_expected_output', 'area.xml')

with codecs.open(path, encoding='utf-8') as f:
self.assertMultiLineEqual(survey.to_xml(), f.read())
26 changes: 26 additions & 0 deletions pyxform/tests/test_expected_output/area.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa" xmlns:orx="http://openrosa.org/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
<h:title>Area of a geoshape</h:title>
<model>
<instance>
<area id="area" version="2013070811">
<geoshape1>38.253094215699576 21.756382658677467;38.25021274773806 21.756382658677467;38.25007793942195 21.763892843919166;38.25290886154963 21.763935759263404;38.25146813817506 21.758421137528785</geoshape1>
<result/>
<meta>
<instanceID/>
</meta>
</area>
</instance>
<bind nodeset="/area/geoshape1" type="geoshape"/>
<bind calculate="enclosed-area( /area/geoshape1 )" nodeset="/area/result" type="string"/>
<bind calculate="concat('uuid:', uuid())" nodeset="/area/meta/instanceID" readonly="true()" type="string"/>
</model>
</h:head>
<h:body>
<input ref="/area/geoshape1">
<label>Draw your shape here...</label>
<hint>GPS coordinates can only be collected when outside.</hint>
</input>
</h:body>
</h:html>

0 comments on commit c4745e7

Please sign in to comment.