aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_input.py
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2012-02-23 16:44:57 +0100
committerMatěj Cepl <mcepl@redhat.com>2012-02-23 19:54:04 +0100
commit170d827e642de4980049c2ea71ebcf1852e29c9c (patch)
tree0663acce589b5a288cb2ff2ac29e8e23307e2a70 /test/test_input.py
parent91e4adcbc3e7bd459b52cd98a1cdd9239998b09f (diff)
downloadyamlish-170d827e642de4980049c2ea71ebcf1852e29c9c.tar.gz
Input/Read test succeed!
Diffstat (limited to 'test/test_input.py')
-rw-r--r--test/test_input.py157
1 files changed, 59 insertions, 98 deletions
diff --git a/test/test_input.py b/test/test_input.py
index d221830..d950f86 100644
--- a/test/test_input.py
+++ b/test/test_input.py
@@ -1,105 +1,66 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
-import logging
-import unittest
-import yamlish
-logging.basicConfig(format='%(levelname)s:%(funcName)s:%(message)s',
- level=logging.INFO)
-
-IN = """
- ---
- bill-to:
- address:
- city: "Royal Oak"
- lines: "458 Walkman Dr.\nSuite #292\n"
- postal: 48046
- state: MI
- family: Dumars
- given: Chris
- comments: "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338\n"
- date: 2001-01-23
- invoice: 34843
- product:
- -
- description: Basketball
- price: 450.00
- quantity: 4
- sku: BL394D
- -
- description: "Super Hoop"
- price: 2392.00
- quantity: 1
- sku: BL4438H
- tax: 251.42
- total: 4443.52
- ...
-"""
-
-OUT = {
- 'bill-to': {
- 'given': 'Chris',
- 'address': {
- 'city': 'Royal Oak',
- 'postal': '48046',
- 'lines': "458 Walkman Dr.\nSuite #292\n",
- 'state': 'MI'
- },
- 'family': 'Dumars'
- },
- 'invoice': '34843',
- 'date': '2001-01-23',
- 'tax': '251.42',
- 'product': [
+test_data_list = [
{
- 'sku': 'BL394D',
- 'quantity': '4',
- 'price': '450.00',
- 'description': 'Basketball'
- },
- {
- 'sku': 'BL4438H',
- 'quantity': '1',
- 'price': '2392.00',
- 'description': 'Super Hoop'
- }
- ],
- 'comments':
- "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338\n",
- 'total': '4443.52'
-}
-
-class TestInput(unittest.TestCase):
- """FIXME description of this class"""
- def test_reader(self):
- scalar = IN
- source = [
+ "name": "Input test",
+ "in": """---
+bill-to:
+ address:
+ city: "Royal Oak"
+ lines: "458 Walkman Dr.\\nSuite #292\\n"
+ postal: 48046
+ state: MI
+ family: Dumars
+ given: Chris
+comments: "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338\\n"
+date: 2001-01-23
+invoice: 34843
+product:
+ -
+ description: Basketball
+ price: 450.00
+ quantity: 4
+ sku: BL394D
+ -
+ description: "Super Hoop"
+ price: 2392.00
+ quantity: 1
+ sku: BL4438H
+tax: 251.42
+total: 4443.52
+...
+""",
+ 'out': {
+ 'bill-to': {
+ 'given': 'Chris',
+ 'address': {
+ 'city': 'Royal Oak',
+ 'postal': 48046,
+ 'lines': "458 Walkman Dr.\nSuite #292\n",
+ 'state': 'MI'
+ },
+ 'family': 'Dumars'
+ },
+ 'invoice': 34843,
+ 'date': '2001-01-23',
+ 'tax': 251.42,
+ 'product': [
{
- "name": 'Array reference',
- "source": IN.split("\n"),
+ 'sku': 'BL394D',
+ 'quantity': 4,
+ 'price': 450.00,
+ 'description': 'Basketball'
},
-# {
-# "name": 'Closure',
-# "source": sub { shift @lines },
-# },
{
- "name": 'Scalar',
- "source": IN,
+ 'sku': 'BL4438H',
+ 'quantity': 1,
+ 'price': 2392.00,
+ 'description': 'Super Hoop'
}
- ]
-
- for src in source:
- name = src['name']
- yaml = yamlish.Reader()
- self.assert_(True, "%s: Created" % name)
- self.assert_(isinstance(yaml, yamlish.Reader))
-
- #my $got = eval { $yaml -> read($src -> {source}) };
- try:
- got = yaml.read(src['source'])
- except IOError: # FIXME not sure which one
- raise
- self.assertEqual(got, OUT, """%s: Result matches
- expected = %s
-
- observed = %s
- """ % (name, OUT, got))
+ ],
+ 'comments':
+ "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338\n",
+ 'total': 4443.52
+ }
+ }
+]