Permalink
Browse files

Test would be passing but for line endingin issues.

  • Loading branch information...
axiomsofchoice committed Apr 13, 2012
1 parent 4094651 commit 065c5ab38b655a79c52d30c01becc9dc0478cf38
Showing with 9 additions and 9 deletions.
  1. +5 −5 qrcodeGen.py
  2. +4 −4 testqrcodeGen.py
View
@@ -29,7 +29,7 @@
import StringIO
import Image
-badOrgRegex = re.compile(r"ORG:(((\\)?.;)+(.)?)")
+badOrgRegex = re.compile(r"ORG:(((\\)?.;)+.?)")
def formatAsvCard(a):
"""Return the supplied record in vCard format.
@@ -67,16 +67,15 @@ def formatAsvCard(a):
j.x_twitter.value = teststr
vCardTest = j.serialize()
- print vCardTest
# The following is a hack to fix a bug with the serialization of the org part
vCardFixed = ''
if len(a["Company"]):
badOrg = badOrgRegex.findall(vCardTest)[0][0]
- betterOrg = re.sub(r";", "", badOrg)
- evenbetterOrg = re.sub(r"\\", "", betterOrg)
- vCardFixed = re.sub(r"ORG:(((\\)?.;)+(.)?)", "ORG:%s" % evenbetterOrg, vCardTest)
+ vCardFixed = re.sub(r"ORG:.*", "ORG:%s" % a["Company"], vCardTest)
else:
vCardFixed = vCardTest
+ # Remove trailing semi-colons in name parts
+ vCardFixed = re.sub(r';;;', "", vCardFixed)
return vCardFixed
@@ -86,6 +85,7 @@ def gen_qrcode(a, qrcodeHeight, qrcodeWidth, outdir):
print "Processing: %s %s" % (a["First Name"], a["Last Name"])
vCardFixed = formatAsvCard(a)
+ print vCardFixed
# Request a QRcode from the Google Charts API using the vCard data
# (Assume an encoding of UTF-8)
View
@@ -33,13 +33,13 @@ def test_formatAsvCard(self):
"Company": "Digital Science",
"Blog": ""}
vCardTest = formatAsvCard(a)
- vCardExpected = """
-BEGIN:VCARD
+ vCardExpected = r"""BEGIN:VCARD
VERSION:3.0
EMAIL;TYPE=INTERNET:axiomsofchoice@gmail.com
FN:Dan Hagon
N:Hagon;Dan
ORG:Digital Science
X-TWITTER:@axiomsofchoice
-END:VCARD"""
- self.assertEqual(vCardTest, vCardExpected, 'vCard formatting problem')
+END:VCARD
+"""
+ self.assertEqual(vCardTest, vCardExpected)

0 comments on commit 065c5ab

Please sign in to comment.