diff --git a/pagure/lib/git.py b/pagure/lib/git.py index 65783c1..15a028e 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -363,10 +363,12 @@ def get_project_from_json( user = get_user_from_json(session, jsondata) name = jsondata.get('name') + namespace = jsondata.get('namespace') project_user = None if jsondata.get('parent'): project_user = user.username - project = pagure.lib.get_project(session, name, user=project_user) + project = pagure.lib.get_project( + session, name, user=project_user, namespace=namespace) if not project: parent = None @@ -391,6 +393,7 @@ def get_project_from_json( session, user=user.username, name=name, + namespace=namespace, description=jsondata.get('description'), parent_id=parent.id if parent else None, blacklist=pagure.APP.config.get('BLACKLISTED_PROJECTS', []), @@ -404,7 +407,9 @@ def get_project_from_json( ) session.commit() - project = pagure.lib.get_project(session, name, user=user.username) + project = pagure.lib.get_project( + session, name, user=user.username, namespace=namespace) + tags = jsondata.get('tags', None) if tags: pagure.lib.add_tag_obj( diff --git a/tests/__init__.py b/tests/__init__.py index ad24c94..ab95d7d 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -272,13 +272,24 @@ def create_projects(session): item.close_status = ['Invalid', 'Insufficient data', 'Fixed', 'Duplicate'] session.add(item) + item = pagure.lib.model.Project( + user_id=1, # pingou + name='test3', + description='namespaced test project', + hook_token='aaabbbeee', + namespace='somenamespace', + ) + item.close_status = ['Invalid', 'Insufficient data', 'Fixed', 'Duplicate'] + session.add(item) + session.commit() def create_projects_git(folder, bare=False): """ Create some projects in the database. """ repos = [] - for project in ['test.git', 'test2.git']: + for project in ['test.git', 'test2.git', + os.path.join('somenamespace', 'test3.git')]: repo_path = os.path.join(folder, project) repos.append(repo_path) if not os.path.exists(repo_path): diff --git a/tests/test_pagure_flask_api_issue.py b/tests/test_pagure_flask_api_issue.py index 85f1c72..8be5d27 100644 --- a/tests/test_pagure_flask_api_issue.py +++ b/tests/test_pagure_flask_api_issue.py @@ -712,7 +712,7 @@ class PagureFlaskApiIssuetests(tests.Modeltests): item = pagure.lib.model.Token( id='pingou_foo', user_id=1, - project_id=3, + project_id=4, expiration=datetime.datetime.utcnow() + datetime.timedelta( days=30) ) @@ -932,7 +932,7 @@ class PagureFlaskApiIssuetests(tests.Modeltests): item = pagure.lib.model.Token( id='pingou_foo', user_id=1, - project_id=3, + project_id=4, expiration=datetime.datetime.utcnow() + datetime.timedelta( days=30) ) @@ -991,7 +991,7 @@ class PagureFlaskApiIssuetests(tests.Modeltests): item = pagure.lib.model.Token( id='foo_token2', user_id=2, - project_id=3, + project_id=4, expiration=datetime.datetime.utcnow() + datetime.timedelta(days=30) ) self.session.add(item) @@ -1248,7 +1248,7 @@ class PagureFlaskApiIssuetests(tests.Modeltests): item = pagure.lib.model.Token( id='pingou_foo', user_id=1, - project_id=3, + project_id=4, expiration=datetime.datetime.utcnow() + datetime.timedelta( days=30) ) @@ -1307,7 +1307,7 @@ class PagureFlaskApiIssuetests(tests.Modeltests): item = pagure.lib.model.Token( id='foo_token2', user_id=2, - project_id=3, + project_id=4, expiration=datetime.datetime.utcnow() + datetime.timedelta(days=30) ) self.session.add(item) diff --git a/tests/test_pagure_flask_api_project.py b/tests/test_pagure_flask_api_project.py index 2604813..be97a62 100644 --- a/tests/test_pagure_flask_api_project.py +++ b/tests/test_pagure_flask_api_project.py @@ -178,10 +178,11 @@ class PagureFlaskApiProjecttests(tests.Modeltests): data = json.loads(output.data) data['projects'][0]['date_created'] = "1436527638" data['projects'][1]['date_created'] = "1436527638" + data['projects'][2]['date_created'] = "1436527638" self.assertDictEqual( data, { - "total_projects": 2, + "total_projects": 3, "projects": [ { "close_status": [ @@ -226,6 +227,28 @@ class PagureFlaskApiProjecttests(tests.Modeltests): "fullname": "PY C", "name": "pingou" } + }, + { + "close_status": [ + "Invalid", + "Insufficient data", + "Fixed", + "Duplicate" + ], + "custom_keys": [], + "date_created": "1436527638", + "description": "namespaced test project", + "id": 3, + "milestones": {}, + "name": "test3", + "namespace": "somenamespace", + "parent": None, + "priorities": {}, + "tags": [], + "user": { + "fullname": "PY C", + "name": "pingou" + } } ] } diff --git a/tests/test_pagure_flask_ui_app.py b/tests/test_pagure_flask_ui_app.py index c6abf9b..744dc24 100644 --- a/tests/test_pagure_flask_ui_app.py +++ b/tests/test_pagure_flask_ui_app.py @@ -67,14 +67,14 @@ class PagureFlaskApptests(tests.Modeltests): self.assertEqual(output.status_code, 200) self.assertIn( '