#2554 Add a new branch API
Merged by pingou. Opened by mprahl.
Unknown source master

Download 2554.patch

This is to be used by fedrepo-req-admin after a branch is created in PDC.

Since we're not sending json data I don't think we should rely on this, we're sending regular POST arguments, so we can just do flask.request.form.get() that one less step to do and more coherent with what is happening.

rebased

rebased

With the following changes the test is failing but not crashing:

--- a/ tests/test_pagure_flask_api_project.py   
+++ b/ tests/test_pagure_flask_api_project.py   
@@ -2190,22 +2190,20 @@ class PagureFlaskApiProjecttests(tests.Modeltests):
     def test_api_new_git_branch(self):
         """ Test the api_new_branch method of the flask api """
         tests.create_projects(self.session)
+        tests.create_projects_git(os.path.join(self.path, 'repos'))
         tests.create_tokens(self.session, project_id=None)
         tests.create_tokens_acl(
             self.session, 'aaabbbcccddd', 'modify_project')
         headers = {'Authorization': 'token aaabbbcccddd'}
-        user = pagure.lib.get_user(self.session, 'pingou')
-        user.cla_done = True
-        with tests.user_set(pagure.APP, user):
-            output = self.app.post('/api/0/test/git/branch', headers=headers,
-                                   data=json.dumps({'branch': 'test123'}))
-            self.assertEqual(output.status_code, 200)
-            data = json.loads(output.data)
-            expected_output = {
-                'message': 'Project branch was created',
-            }
-            self.assertEqual(data, expected_output)
+        output = self.app.post('/api/0/test/git/branch', headers=headers,
+                                   data={'branch': 'test123'})
+        self.assertEqual(output.status_code, 400)
+        data = json.loads(output.data)
+        expected_output = {
+            'message': 'Project branch was created',
+        }
+        self.assertEqual(data, expected_output)

Do you want to look into fixing it and the others?

rebased

@pingou should be ready for a review.

rebased

Looks good and tests are passing :)

Pull-Request has been merged by pingou

Metadata