def test_write(self): outFile = os.path.join(self.basePath, 'write.json') runPd(os.path.join(self.basePath, 'write.pd')) fileHandle = open(outFile) out = fileHandle.read(); try: os.remove(outFile); except: pass self.assertEquals(out, '{ "key": 1 }')
def test_write(self): outFile = os.path.join(self.basePath, 'write.json') runPd(os.path.join(self.basePath, 'write.pd')) fileHandle = open(outFile) out = fileHandle.read() try: os.remove(outFile) except: pass self.assertEquals(out, '{ "key": 1 }')
def test_multiple_members(self): out = runPd(os.path.join(self.basePath, 'multiple-members.pd')) self.assertEquals(out, '''list key value; list key2 2; list key3 0.1; list bool 0; bang; ''')
def test_array(self): out = runPd(os.path.join(self.basePath, 'array.pd')) self.assertEquals(out, '''list key value; list id 1; bang; list key value 2; list id 2; bang; ''')
def test_multiple_members(self): out = runPd(os.path.join(self.basePath, 'multiple-members.pd')) self.assertEquals( out, '''list key value; list key2 2; list key3 0.1; list bool 0; bang; ''')
def test_array(self): out = runPd(os.path.join(self.basePath, 'array.pd')) self.assertEquals( out, '''list key value; list id 1; bang; list key value 2; list id 2; bang; ''')
def test_read_large(self): out = runPd(os.path.join(self.basePath, 'read-large.pd')) self.assertFalse(out == ''' ''')
def test_read(self): out = runPd(os.path.join(self.basePath, 'read.pd')) self.assertEquals(out, '''list { "key": 1 }; ''')
def test_add_two_values(self): out = runPd(os.path.join(self.basePath, 'add-two-values.pd')) self.assertEquals(out, '''list key=value&key2=value2; ''')
def test_empty_bang(self): out = runPd(os.path.join(self.basePath, 'empty-bang.pd')) self.assertEquals(out, '''list ; ''')
def test_escape_value(self): out = runPd(os.path.join(self.basePath, 'escape-value.pd')) self.assertEquals(out, '''list key=value%20with%20%23spaces%26other%2bst%c3%bcff%20incl.%20%c3%9cml%c3%a4ute; ''')
def test_replace(self): out = runPd(os.path.join(self.basePath, 'replace.pd')) self.assertEquals(out, '''list { "key": "value2" }; ''')
def test_simple_object(self): out = runPd(os.path.join(self.basePath, 'simple-object.pd')) self.assertEquals(out, '''list key value; bang; ''')
def test_add_float(self): out = runPd(os.path.join(self.basePath, 'add-float.pd')) self.assertTrue(out.startswith('''list { "key": 1.100000'''))
def test_add_string(self): out = runPd(os.path.join(self.basePath, 'add-string.pd')) self.assertEquals(out, '''list { "key": "value" }; ''')
def test_add_single_value(self): out = runPd(os.path.join(self.basePath, 'add-single-value.pd')) self.assertEquals(out, '''list key=value; ''')
def test_escape_key(self): out = runPd(os.path.join(self.basePath, 'escape-key.pd')) self.assertEquals(out, '''list key%23%24=value; ''')
def test_add_object(self): out = runPd(os.path.join(self.basePath, 'add-object.pd')) self.assertEquals(out, '''list { "key": { "id": "test"\, "name": "my name" } }; ''')
def test_replace_value(self): out = runPd(os.path.join(self.basePath, 'replace-value.pd')) self.assertEquals(out, '''list key=other; ''')
def test_add_array(self): out = runPd(os.path.join(self.basePath, 'add-array.pd')) self.assertEquals(out, '''list { "key": [ "value"\\, "value2" ] }; ''')
def test_add_object(self): out = runPd(os.path.join(self.basePath, 'add-object.pd')) self.assertEquals( out, '''list { "key": { "id": "test"\, "name": "my name" } }; ''')
def test_clear(self): out = runPd(os.path.join(self.basePath, 'clear.pd')) self.assertEquals(out, '''list ; ''')
def test_add_int(self): out = runPd(os.path.join(self.basePath, 'add-int.pd')) self.assertEquals(out, '''list { "key": 1 }; ''')