Beispiel #1
0
    def test_format_participant_list(self):
        """Test formatting an HTML list of study participants."""
        # Test URL prefix without trailing slash.
        exp = ('<ul>\n'
               '  <li><a href="http://my-microbes.qiime.org/'
               'foo1/index.html" target="_blank">foo1</a></li>\n'
               '  <li><a href="http://my-microbes.qiime.org/'
               'foo2/index.html" target="_blank">foo2</a></li>\n'
               '</ul>\n')
        obs = format_participant_list(self.recipients,
                                      'http://my-microbes.qiime.org')
        self.assertEqual(obs, exp)

        # Test URL prefix with trailing slash.
        obs = format_participant_list(self.recipients,
                                      'http://my-microbes.qiime.org/')
        self.assertEqual(obs, exp)

        # Test standard single-column format.
        obs = format_participant_list(self.participants,
                                      'http://my-microbes.qiime.org')
        self.assertEqual(obs, exp)

        # Test empty recipients file.
        exp = '<ul>\n</ul>\n'
        obs = format_participant_list(self.empty_recipients,
                                      'http://my-microbes.qiime.org')
        self.assertEqual(obs, exp)

        # Test invalid participants file.
        self.assertRaises(ValueError, format_participant_list,
                          self.duplicate_participants,
                          'http://my-microbes.qiime.org')
def main():
    option_parser, opts, args = parse_command_line_parameters(**script_info)

    participant_list = format_participant_list(open(opts.participants, "U"), opts.url_prefix)

    with open(opts.output_fp, "w") as output_f:
        output_f.write(participant_list)