from testify import *
from dynochemy import utils

class SimpleParseTestCase(TestCase):
    def test_string(self):
        value = {'S': 'Rhett'}
        res = utils.parse_value(value)
        assert_equal(res, "Rhett")

    def test_int(self):
        value = {'N': '123'}
        res = utils.parse_value(value)
        assert_equal(res, 123)
        assert_equal(type(res), int)

    def test_float(self):
        value = {'N': '10.5'}
        res = utils.parse_value(value)
        assert_equal(res, 10.5)
        assert_equal(type(res), float)

    def test_multistring(self):
        value = {'SS': ['Rhett', 'Ziggy']}
        res = utils.parse_value(value)
        assert_equal(res, ['Rhett', 'Ziggy'])

class BuildKeyTestCase(TestCase):
    def test_single_string(self):
        key = utils.build_key(('user',), 'Rhett')
        assert_equal(key, {'user': {'S': 'Rhett'}})

    def test_multi_string(self):
        key = utils.build_key(('user', 'id'), ('Rhett', 'foo'))
        assert_equal(key, {'user': {'S': 'Rhett'}, 'id': {'S': 'foo'}})

    def test_multi_number(self):
        key = utils.build_key(('user', 'id'), ('Rhett', 123))
        assert_equal(key, {'user': {'S': 'Rhett'}, 'id': {'N': '123'}})

class ParseItemTestCase(TestCase):
    def test(self):
        item = utils.parse_item({'id': {'S': 'Rhett'}, 'value': {'N': '10.5'}})
        assert_equal(item['id'], 'Rhett')
        assert_equal(item['value'], 10.5)

@@ -713,13 +713,14 @@
 ass 
-Build
+Format
 KeyT
@@ -784,37 +784,38 @@
     key = utils.
-build
+format
 _key(('user',), 
@@ -921,37 +921,38 @@
     key = utils.
-build
+format
 _key(('user', 'i
@@ -1104,13 +1104,14 @@
 ils.
-build
+format
 _key

Fix for name change