Skip to content

Commit

Permalink
Merge pull request SEL-Columbia#911 from modilabs/non-greedy-regex
Browse files Browse the repository at this point in the history
pyxform 0.9.9.2 and manage fix retrieving id_string from multiple instance tags in a form xml
  • Loading branch information
larryweya committed Jan 27, 2013
2 parents 4c52f13 + b2cadec commit 0f615f5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
3 changes: 2 additions & 1 deletion main/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from test_gps import TestGPS
from test_http_auth import TestBasicHttpAuthentication
from test_kml_export import TestKMLExport
from test_past_bugs import TestCSVExport, TestInputs, TestSubmissionBugs
from test_past_bugs import TestCSVExport, TestInputs, TestSubmissionBugs,\
TestCascading
from test_process import TestSite
from test_user_id_string_unique_together import TestUnique
from test_user_login import TestUserLogin
Expand Down
Binary file not shown.
14 changes: 14 additions & 0 deletions main/tests/test_past_bugs.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,17 @@ def test_submission_with_mixed_case_username(self):
self.this_directory, 'fixtures',
'transportation', 'instances', s, s + '.xml'), 'BoB')
self.assertEqual(Instance.objects.count(), count + 1)


class TestCascading(MainTestCase):

def test_correct_id_string_picked(self):
XForm.objects.all().delete()
name = 'new_cascading_select.xls'
id_string = u'cascading_select_test'
self._publish_xls_file(os.path.join(
self.this_directory, 'fixtures', 'bug_fixes', name))
self.assertEqual(XForm.objects.count(), 1)
xform_id_string = XForm.objects.all()[0].id_string
self.assertEqual(xform_id_string, id_string)

7 changes: 4 additions & 3 deletions odk_logger/models/xform.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ class XForm(models.Model):
has_start_time = models.BooleanField(default=False)
uuid = models.CharField(max_length=32, default=u'')

uuid_regex = re.compile(r'(<instance>.*id="[^"]+">)(.*</instance>)(.*)',
uuid_regex = re.compile(r'(<instance>.*?id="[^"]+">)(.*</instance>)(.*)',
re.DOTALL)
instance_id_regex = re.compile(r'<instance>.*id="([^"]+)".*</instance>',
instance_id_regex = re.compile(r'<instance>.*?id="([^"]+)".*</instance>',
re.DOTALL)
uuid_node_location = 2
uuid_bind_location = 4
Expand Down Expand Up @@ -145,4 +145,5 @@ def stats_forms_created(sender, instance, created, **kwargs):
stat_log.delay('formhub-forms-created', 1)


post_save.connect(stats_forms_created, sender=XForm)
post_save.connect(stats_forms_created, sender=XForm)

3 changes: 1 addition & 2 deletions requirements.pip
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ modilabs-python-utils==0.1.5
PIL==1.1.7
poster==0.8.1
pymongo==2.2.1
# RODO: use version number
-e git+https://github.com/modilabs/pyxform.git@master#egg=pyxform
pyxform==0.9.9.2
South==0.7.3
xlrd==0.7.1
xlwt==0.7.2
Expand Down

0 comments on commit 0f615f5

Please sign in to comment.