refactoring
This commit is contained in:
@@ -3,15 +3,15 @@ from bs4 import BeautifulSoup
|
||||
|
||||
class OptionsSetter:
|
||||
|
||||
def setOptions(self, html, options):
|
||||
soup = self._setBatchcodeOptions(self._parse(html), self._parseOptions(options))
|
||||
def setOptions(self, html, selectElementId, options):
|
||||
soup = self._setOptions(self._parse(html), selectElementId, self._parseOptions(options))
|
||||
return str(soup)
|
||||
|
||||
def _setBatchcodeOptions(self, soup, options):
|
||||
batchcodeSelect = soup.find(id = "vaccineSelect")
|
||||
batchcodeSelect.clear()
|
||||
def _setOptions(self, soup, selectElementId, options):
|
||||
selectElement = soup.find(id = selectElementId)
|
||||
selectElement.clear()
|
||||
for option in options:
|
||||
batchcodeSelect.append(option)
|
||||
selectElement.append(option)
|
||||
return soup
|
||||
|
||||
def _parseOptions(self, options):
|
||||
|
||||
@@ -21,6 +21,7 @@ class OptionsSetterTest(unittest.TestCase):
|
||||
</body>
|
||||
</html>
|
||||
''',
|
||||
selectElementId = 'vaccineSelect',
|
||||
options=[
|
||||
'<option value="6VAX-F">6VAX-F</option>',
|
||||
'<option value="ADEN">ADEN</option>'])
|
||||
|
||||
Reference in New Issue
Block a user