While creating tests for the controller I encountered another thing which I 
don't understand. I do use 
[forge/test_tracker.py](https://forge-allura.apache.org/u/fahri/allurafork/ci/master/tree/ForgeImporters/forgeimporters/tests/forge/test_tracker.py#l349)
 as an example for writing my tests. In the "test_index"-method of the 
"TestForgeTrackerImportController" class there is this path of a URL that I 
don't really understand: '/p/test/admin/bugs/_importer/'. How is this path 
assembled and from where does the "bugs" part come from?
~~~python
    @with_tracker
    def test_index(self):
        r = self.app.get('/p/test/admin/bugs/_importer/')
        self.assertIsNotNone(r.html.find(attrs=dict(name="tickets_json")))
        self.assertIsNotNone(r.html.find(attrs=dict(name="mount_label")))
        self.assertIsNotNone(r.html.find(attrs=dict(name="mount_point")))
~~~

I have used  another path for my tests: 
"'/p/test/admin/ext/import/forge-discussion/'". When I use this path my tests 
pass. Is this also a valid solution?

[**This is my test for the 
Controller:**](https://forge-allura.apache.org/u/fahri/allurafork/ci/master/tree/ForgeImporters/forgeimporters/tests/forge/test_discussion.py#l1191)

~~~python
class TestForgeDiscussionController(TestController, TestCase):
 
     def setUp(self):
         super(TestForgeDiscussionController, self).setUp()
         from forgediscussion.forum_main import ForumAdminController
         ForumAdminController._importer = \                 
discussion.ForgeDiscussionImportController(discussion.ForgeDiscussionImporter())


     @with_discussion
     def test_index(self):
         r = self.app.get('/p/test/admin/ext/import/forge-discussion/')
         self.assertIsNotNone(r.html.find(attrs=dict(name="discussions_json")))
         self.assertIsNotNone(r.html.find(attrs=dict(name="mount_label")))
         self.assertIsNotNone(r.html.find(attrs=dict(name="mount_point")))


     @with_discussion
     @mock.patch('forgeimporters.forge.discussion.save_importer_upload')
     @mock.patch('forgeimporters.base.import_tool')
     def test_create(self, import_tool, siu):
         project = M.Project.query.get(shortname='test')
         params = {
             'discussions_json': webtest.Upload('discussions.json', b'{"key": 
"val"}'),
             'mount_label': 'mylabel',
             'mount_point': 'mymount',
         }
         r = self.app.post('/p/test/admin/ext/import/forge-discussion/create', 
params,
                           status=302)
         self.assertEqual(r.location, 'http://localhost/p/test/admin/')
         siu.assert_called_once_with(project, 'discussions.json', '{"key": 
"val"}')
         self.assertEqual(
             'mymount', import_tool.post.call_args[1]['mount_point'])
         self.assertEqual(
             'mylabel', import_tool.post.call_args[1]['mount_label'])


     @with_discussion
     @mock.patch('forgeimporters.forge.discussion.save_importer_upload')
     @mock.patch('forgeimporters.base.import_tool')
     def test_create_limit(self, import_tool, siu):
         project = M.Project.query.get(shortname='test')
         project.set_tool_data('ForgeDiscussionImporter', pending=1)
         ThreadLocalORMSession.flush_all()
         params = {
             'discussions_json': webtest.Upload('discussions.json', b'{"key": 
"val"}'),
             'mount_label': 'mylabel',
             'mount_point': 'mymount',
         }
         r = self.app.post('/p/test/admin/ext/import/forge-discussion/create', 
params,
                           status=302).follow()
         self.assertIn('Please wait and try again', r)
         self.assertEqual(import_tool.post.call_count, 0)
~~~



---

** [tickets:#7935] Forum importer for allura's own export format**

**Status:** open
**Milestone:** unreleased
**Labels:** import 
**Created:** Tue Jul 21, 2015 06:53 PM UTC by Dave Brondsema
**Last Updated:** Thu Mar 05, 2020 09:44 AM UTC
**Owner:** nobody





---

Sent from forge-allura.apache.org because dev@allura.apache.org is subscribed 
to https://forge-allura.apache.org/p/allura/tickets/

To unsubscribe from further messages, a project admin can change settings at 
https://forge-allura.apache.org/p/allura/admin/tickets/options.  Or, if this is 
a mailing list, you can unsubscribe from the mailing list.

Reply via email to