Example #1
0
 def test_cohi_two_types_in_param(self):
     """
     Test if cohi() accepts 2 types of html id.
     """
     # Params
     types = [settings.SLUG_PLUGIN, settings.SLUG_APP]
     # Accept a valid html id plugin
     html_id_plugin = '%s%d' % (settings.HTML_ID_PLUGIN, 1)
     items_returned = cohi(html_id_plugin, types)
     self.assertEqual(items_returned, [settings.SLUG_PLUGIN, '1'])
     # Accept a valid html id app
     html_id_app = '%s%d' % (settings.HTML_ID_APP, 1)
     items_returned = cohi(html_id_app, types)
     self.assertEqual(items_returned, [settings.SLUG_APP, '1'])
     # Reject other html id
     html_id_wrong = 'truc-machin-4'
     self.assertRaises(ErrorResponse, cohi, html_id_wrong, types)
Example #2
0
 def test_cohi_two_types_in_param(self):
     """
     Test if cohi() accepts 2 types of html id.
     """
     # Params
     types = [settings.SLUG_PLUGIN, settings.SLUG_APP]
     # Accept a valid html id plugin
     html_id_plugin = '%s%d' % (settings.HTML_ID_PLUGIN, 1)
     items_returned = cohi(html_id_plugin, types)
     self.assertEqual(items_returned, [settings.SLUG_PLUGIN, '1'])
     # Accept a valid html id app
     html_id_app = '%s%d' % (settings.HTML_ID_APP, 1)
     items_returned = cohi(html_id_app, types)
     self.assertEqual(items_returned, [settings.SLUG_APP, '1'])
     # Reject other html id
     html_id_wrong = 'truc-machin-4'
     self.assertRaises(ErrorResponse, cohi, html_id_wrong, types)
Example #3
0
 def test_cohi_default_param_type(self):
     """
     By default, COHI() has to accept only plugin relation html id.
     """
     # Accept a valid html id plugin
     html_id_plugin = '%s%d' % (settings.HTML_ID_PLUGIN, 1)
     items_returned = cohi(html_id_plugin)
     self.assertEqual(items_returned, [settings.SLUG_PLUGIN, '1'])
     # Reject a valid html id App
     html_id_app = '%s%d' % (settings.HTML_ID_APP, 1)
     self.assertRaises(ErrorResponse, cohi, html_id_app)
Example #4
0
 def test_cohi_default_param_type(self):
     """
     By default, COHI() has to accept only plugin relation html id.
     """
     # Accept a valid html id plugin
     html_id_plugin = '%s%d' % (settings.HTML_ID_PLUGIN, 1)
     items_returned = cohi(html_id_plugin)
     self.assertEqual(items_returned, [settings.SLUG_PLUGIN, '1'])
     # Reject a valid html id App
     html_id_app = '%s%d' % (settings.HTML_ID_APP, 1)
     self.assertRaises(ErrorResponse, cohi, html_id_app)
Example #5
0
 def test_cohi_one_type_in_param(self):
     """
     Test if cohi() with App type accept only App html id.
     """
     # Params
     types = [settings.SLUG_APP]
     # Accept a valid app html id
     html_id_app = '%s%d' % (settings.HTML_ID_APP, 1)
     items_returned = cohi(html_id_app, types)
     self.assertEqual(items_returned, [settings.SLUG_APP, '1'])
     # Reject a valid plugin html id
     html_id_plugin = '%s%d' % (settings.HTML_ID_PLUGIN, 1)
     self.assertRaises(ErrorResponse, cohi, html_id_plugin, types)
Example #6
0
 def test_cohi_one_type_in_param(self):
     """
     Test if cohi() with App type accept only App html id.
     """
     # Params
     types = [settings.SLUG_APP]
     # Accept a valid app html id
     html_id_app = '%s%d' % (settings.HTML_ID_APP, 1)
     items_returned = cohi(html_id_app, types)
     self.assertEqual(items_returned, [settings.SLUG_APP, '1'])
     # Reject a valid plugin html id
     html_id_plugin = '%s%d' % (settings.HTML_ID_PLUGIN, 1)
     self.assertRaises(ErrorResponse, cohi, html_id_plugin, types)