def test_MakeExtras(self): linesMade = MakeExtras(Rows(self.cells)) linesExpected = [' <row label="r1" cs:extra="Ham" >Ham</row>', ' <row label="foo" cs:extra="Spam" >Spam</row>', ' <row label="r3" cs:extra="bar Eggs">bar Eggs</row>', ' <row label="r42" cs:extra="Bacon" >Bacon</row>'] self.assertEqual(linesMade, linesExpected)
def test_Rows(self): rowsMade = Rows(self.cells) rowsExpected = [' <row label="r1">Ham</row>', ' <row label="foo">Spam</row>', ' <row label="r3">bar Eggs</row>', ' <row label="r42">Bacon</row>', '\n'] self.assertEqual(rowsMade, rowsExpected)
def test_AddValuesHigh(self): rowsMade = AddValuesHigh(Rows(self.cells)) rowsExpected = [' <row label="r1" value="4">Ham</row>', ' <row label="foo" value="3">Spam</row>', ' <row label="r3" value="2">bar Eggs</row>', ' <row label="r42" value="1">Bacon</row>', '\n'] self.assertEqual(rowsMade, rowsExpected)
def test_MakeRating(self): vbuffer = ['Q1. What would you like to eat?'] vbuffer.extend(Rows(self.cells)) elementMade = MakeRating(vbuffer) elementExpected = [ '<radio label="Q1" averages="cols" values="order" adim="rows" type="rating">', ' <title>What would you like to eat?</title>', ' <comment>Please select one</comment>', ' <row label="r1">Ham</row>', ' <row label="foo">Spam</row>', ' <row label="r3">bar Eggs</row>', ' <row label="r42">Bacon</row>', '</radio>', '<suspend/>' ] self.assertEqual(elementMade, elementExpected)
def test_MakeTextarea(self): vbuffer = ['A. Please explain your love for the following...'] vbuffer.extend(Rows(self.cells)) elementMade = MakeTextarea(vbuffer) elementExpected = [ '<textarea label="A" optional="0">', ' <title>Please explain your love for the following...</title>', ' <comment>Please be as specific as possible</comment>', ' <row label="r1">Ham</row>', ' <row label="foo">Spam</row>', ' <row label="r3">bar Eggs</row>', ' <row label="r42">Bacon</row>', '</textarea>', '<suspend/>' ] self.assertEqual(elementMade, elementExpected)
def test_MakeFloat(self): vbuffer = ['Q1. How many of each would you like?'] vbuffer.extend(Rows(self.cells)) elementMade = MakeFloat(vbuffer) elementExpected = [ '<float label="Q1" optional="0" size="3">', ' <title>How many of each would you like?</title>', ' <comment>Please enter a number</comment>', ' <row label="r1">Ham</row>', ' <row label="foo">Spam</row>', ' <row label="r3">bar Eggs</row>', ' <row label="r42">Bacon</row>', '</float>', '<suspend/>' ] self.assertEqual(elementMade, elementExpected)
def test_MakeCheckbox(self): vbuffer = ['Q1. What would you like to eat?'] vbuffer.extend(Rows(self.cells)) elementMade = MakeCheckbox(vbuffer) elementExpected = [ '<checkbox label="Q1" atleast="1">', ' <title>What would you like to eat?</title>', ' <comment>Please select all that apply</comment>', ' <row label="r1">Ham</row>', ' <row label="foo">Spam</row>', ' <row label="r3">bar Eggs</row>', ' <row label="r42">Bacon</row>', '</checkbox>', '<suspend/>' ] self.assertEqual(elementMade, elementExpected)
def test_MakeSelect(self): vbuffer = ['Q1. What would you like to eat?'] rows = ['Course 1', 'Course 2', 'Course 3'] vbuffer.extend(Rows(rows)) vbuffer.extend(Choice(self.cells)) elementMade = MakeSelect(vbuffer) elementExpected = ['<select label="Q1" optional="0">', ' <title>What would you like to eat?</title>', ' <comment>Please select one for each selection</comment>', ' <row label="r1">Course 1</row>', ' <row label="r2">Course 2</row>', ' <row label="r3">Course 3</row>', ' <choice label="ch1">Ham</choice>', ' <choice label="foo">Spam</choice>', ' <choice label="ch3">bar Eggs</choice>', ' <choice label="ch42">Bacon</choice>', '</select>', '<suspend/>'] self.assertEqual(elementMade, elementExpected)