def test_append(self): space = Space('hello world') space.append('foo', 'bar') space.set('foo2', 'bar') space.append('foo', 'two') self.assertEqual(space.get('foo'), 'bar') self.assertEqual(space.length(), 4)
def testClearWithSpaceArgument(self): space = Space("Hellow world") space.clear("hey there") self.assertEqual(space.length(), 1) self.assertEqual(space.get('hey'), 'there', 'Clear with a Space argument should deep copy the argument Space')
def testClear(self): space = Space('Hello world') self.assertEqual(space.length(), 1) self.assertTrue(isinstance(space.clear(), Space), 'clear returns Space so chainable') self.assertEqual(space.length(), 0)
def testLength(self): space = Space('list\nsingle value') self.assertEqual(space.length(), 2, 'space should have 2 names') # 'name' here means 'key' self.assertTrue(isinstance(space.get('list'), Space), 'name without a trailing space should be name')
def testIndexOf(self): space = Space("Hello World") self.assertEqual(space.length(), 1) self.assertEqual(space.indexOf('Hello'), 0, 'indexOf should be correct')