|
Pierre-Yves Chibon |
d88010 |
#-*- coding: utf-8 -*-
|
|
Pierre-Yves Chibon |
d88010 |
|
|
Pierre-Yves Chibon |
d88010 |
"""
|
|
Pierre-Yves Chibon |
d88010 |
(c) 2015 - Copyright Red Hat Inc
|
|
Pierre-Yves Chibon |
d88010 |
|
|
Pierre-Yves Chibon |
d88010 |
Authors:
|
|
Pierre-Yves Chibon |
d88010 |
Pierre-Yves Chibon <pingou@pingoured.fr></pingou@pingoured.fr>
|
|
Pierre-Yves Chibon |
d88010 |
|
|
Pierre-Yves Chibon |
d88010 |
"""
|
|
Pierre-Yves Chibon |
d88010 |
|
|
Pierre-Yves Chibon |
d88010 |
__requires__ = ['SQLAlchemy >= 0.8']
|
|
Pierre-Yves Chibon |
d88010 |
import pkg_resources
|
|
Pierre-Yves Chibon |
d88010 |
|
|
Pierre-Yves Chibon |
d88010 |
import unittest
|
|
Pierre-Yves Chibon |
4fbc78 |
import shutil
|
|
Pierre-Yves Chibon |
d88010 |
import sys
|
|
Pierre-Yves Chibon |
d88010 |
import os
|
|
Pierre-Yves Chibon |
d88010 |
|
|
Pierre-Yves Chibon |
a42f77 |
from mock import patch
|
|
Pierre-Yves Chibon |
a42f77 |
|
|
Pierre-Yves Chibon |
d88010 |
sys.path.insert(0, os.path.join(os.path.dirname(
|
|
Pierre-Yves Chibon |
d88010 |
os.path.abspath(__file__)), '..'))
|
|
Pierre-Yves Chibon |
d88010 |
|
|
Pierre-Yves Chibon |
d88010 |
import progit.lib
|
|
Pierre-Yves Chibon |
538301 |
import tests
|
|
Pierre-Yves Chibon |
d88010 |
|
|
Pierre-Yves Chibon |
d88010 |
|
|
Pierre-Yves Chibon |
538301 |
class ProgitLibtests(tests.Modeltests):
|
|
Pierre-Yves Chibon |
d88010 |
""" Tests for progit.lib """
|
|
Pierre-Yves Chibon |
d88010 |
|
|
Pierre-Yves Chibon |
d88010 |
def test_get_next_id(self):
|
|
Pierre-Yves Chibon |
d88010 |
""" Test the get_next_id function of progit.lib. """
|
|
Pierre-Yves Chibon |
538301 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
d88010 |
self.assertEqual(1, progit.lib.get_next_id(self.session, 1))
|
|
Pierre-Yves Chibon |
d88010 |
|
|
Pierre-Yves Chibon |
f74336 |
def test_search_user_all(self):
|
|
Pierre-Yves Chibon |
f74336 |
""" Test the search_user of progit.lib. """
|
|
Pierre-Yves Chibon |
f74336 |
|
|
Pierre-Yves Chibon |
f74336 |
# Retrieve all users
|
|
Pierre-Yves Chibon |
f74336 |
items = progit.lib.search_user(self.session)
|
|
Pierre-Yves Chibon |
f74336 |
self.assertEqual(2, len(items))
|
|
Pierre-Yves Chibon |
f74336 |
self.assertEqual(1, items[0].id)
|
|
Pierre-Yves Chibon |
f74336 |
self.assertEqual('pingou', items[0].user)
|
|
Pierre-Yves Chibon |
f74336 |
self.assertEqual('pingou', items[0].username)
|
|
Pierre-Yves Chibon |
f74336 |
self.assertEqual([], items[0].groups)
|
|
Pierre-Yves Chibon |
f74336 |
self.assertEqual(2, items[1].id)
|
|
Pierre-Yves Chibon |
f74336 |
self.assertEqual('foo', items[1].user)
|
|
Pierre-Yves Chibon |
f74336 |
self.assertEqual('foo', items[1].username)
|
|
Pierre-Yves Chibon |
f74336 |
self.assertEqual([], items[1].groups)
|
|
Pierre-Yves Chibon |
f74336 |
|
|
Pierre-Yves Chibon |
c7ee0c |
def test_search_user_username(self):
|
|
Pierre-Yves Chibon |
c7ee0c |
""" Test the search_user of progit.lib. """
|
|
Pierre-Yves Chibon |
c7ee0c |
|
|
Pierre-Yves Chibon |
c7ee0c |
# Retrieve user by username
|
|
Pierre-Yves Chibon |
c7ee0c |
item = progit.lib.search_user(self.session, username='foo')
|
|
Pierre-Yves Chibon |
c7ee0c |
self.assertEqual('foo', item.user)
|
|
Pierre-Yves Chibon |
c7ee0c |
self.assertEqual('foo', item.username)
|
|
Pierre-Yves Chibon |
c7ee0c |
self.assertEqual([], item.groups)
|
|
Pierre-Yves Chibon |
c7ee0c |
|
|
Pierre-Yves Chibon |
c7ee0c |
item = progit.lib.search_user(self.session, username='bar')
|
|
Pierre-Yves Chibon |
c7ee0c |
self.assertEqual(None, item)
|
|
Pierre-Yves Chibon |
c7ee0c |
|
|
Pierre-Yves Chibon |
f5cf0f |
def test_search_user_email(self):
|
|
Pierre-Yves Chibon |
f5cf0f |
""" Test the search_user of progit.lib. """
|
|
Pierre-Yves Chibon |
f5cf0f |
|
|
Pierre-Yves Chibon |
f5cf0f |
# Retrieve user by email
|
|
Pierre-Yves Chibon |
f5cf0f |
item = progit.lib.search_user(self.session, email='foo@foo.com')
|
|
Pierre-Yves Chibon |
f5cf0f |
self.assertEqual(None, item)
|
|
Pierre-Yves Chibon |
f5cf0f |
|
|
Pierre-Yves Chibon |
f5cf0f |
item = progit.lib.search_user(self.session, email='foo@bar.com')
|
|
Pierre-Yves Chibon |
f5cf0f |
self.assertEqual('foo', item.user)
|
|
Pierre-Yves Chibon |
f5cf0f |
self.assertEqual('foo', item.username)
|
|
Pierre-Yves Chibon |
f5cf0f |
self.assertEqual([], item.groups)
|
|
Pierre-Yves Chibon |
f5cf0f |
self.assertEqual(
|
|
Pierre-Yves Chibon |
f5cf0f |
['foo@bar.com'], [email.email for email in item.emails])
|
|
Pierre-Yves Chibon |
f5cf0f |
|
|
Pierre-Yves Chibon |
f5cf0f |
item = progit.lib.search_user(self.session, email='foo@pingou.com')
|
|
Pierre-Yves Chibon |
f5cf0f |
self.assertEqual('pingou', item.user)
|
|
Pierre-Yves Chibon |
f5cf0f |
self.assertEqual(
|
|
Pierre-Yves Chibon |
f5cf0f |
['bar@pingou.com', 'foo@pingou.com'],
|
|
Pierre-Yves Chibon |
f5cf0f |
[email.email for email in item.emails])
|
|
Pierre-Yves Chibon |
f5cf0f |
|
|
Pierre-Yves Chibon |
fe688c |
def test_search_user_token(self):
|
|
Pierre-Yves Chibon |
fe688c |
""" Test the search_user of progit.lib. """
|
|
Pierre-Yves Chibon |
fe688c |
|
|
Pierre-Yves Chibon |
fe688c |
# Retrieve user by token
|
|
Pierre-Yves Chibon |
fe688c |
item = progit.lib.search_user(self.session, token='aaa')
|
|
Pierre-Yves Chibon |
fe688c |
self.assertEqual(None, item)
|
|
Pierre-Yves Chibon |
fe688c |
|
|
Pierre-Yves Chibon |
fe688c |
item = progit.lib.model.User(
|
|
Pierre-Yves Chibon |
fe688c |
user='pingou2',
|
|
Pierre-Yves Chibon |
fe688c |
fullname='PY C',
|
|
Pierre-Yves Chibon |
fe688c |
token='aaabbb',
|
|
Pierre-Yves Chibon |
fe688c |
)
|
|
Pierre-Yves Chibon |
fe688c |
self.session.add(item)
|
|
Pierre-Yves Chibon |
fe688c |
self.session.commit()
|
|
Pierre-Yves Chibon |
fe688c |
|
|
Pierre-Yves Chibon |
fe688c |
item = progit.lib.search_user(self.session, token='aaabbb')
|
|
Pierre-Yves Chibon |
fe688c |
self.assertEqual('pingou2', item.user)
|
|
Pierre-Yves Chibon |
fe688c |
self.assertEqual('PY C', item.fullname)
|
|
Pierre-Yves Chibon |
fe688c |
|
|
Pierre-Yves Chibon |
04a157 |
def test_search_user_pattern(self):
|
|
Pierre-Yves Chibon |
04a157 |
""" Test the search_user of progit.lib. """
|
|
Pierre-Yves Chibon |
04a157 |
|
|
Pierre-Yves Chibon |
04a157 |
# Retrieve user by pattern
|
|
Pierre-Yves Chibon |
04a157 |
item = progit.lib.search_user(self.session, pattern='a*')
|
|
Pierre-Yves Chibon |
04a157 |
self.assertEqual([], item)
|
|
Pierre-Yves Chibon |
04a157 |
|
|
Pierre-Yves Chibon |
04a157 |
item = progit.lib.model.User(
|
|
Pierre-Yves Chibon |
04a157 |
user='pingou2',
|
|
Pierre-Yves Chibon |
04a157 |
fullname='PY C',
|
|
Pierre-Yves Chibon |
04a157 |
token='aaabbb',
|
|
Pierre-Yves Chibon |
04a157 |
)
|
|
Pierre-Yves Chibon |
04a157 |
self.session.add(item)
|
|
Pierre-Yves Chibon |
04a157 |
self.session.commit()
|
|
Pierre-Yves Chibon |
04a157 |
|
|
Pierre-Yves Chibon |
04a157 |
items = progit.lib.search_user(self.session, pattern='p*')
|
|
Pierre-Yves Chibon |
04a157 |
self.assertEqual(2, len(items))
|
|
Pierre-Yves Chibon |
04a157 |
self.assertEqual(1, items[0].id)
|
|
Pierre-Yves Chibon |
04a157 |
self.assertEqual('pingou', items[0].user)
|
|
Pierre-Yves Chibon |
04a157 |
self.assertEqual('pingou', items[0].username)
|
|
Pierre-Yves Chibon |
04a157 |
self.assertEqual([], items[0].groups)
|
|
Pierre-Yves Chibon |
04a157 |
self.assertEqual(
|
|
Pierre-Yves Chibon |
04a157 |
['bar@pingou.com', 'foo@pingou.com'],
|
|
Pierre-Yves Chibon |
04a157 |
[email.email for email in items[0].emails])
|
|
Pierre-Yves Chibon |
04a157 |
self.assertEqual(3, items[1].id)
|
|
Pierre-Yves Chibon |
04a157 |
self.assertEqual('pingou2', items[1].user)
|
|
Pierre-Yves Chibon |
04a157 |
self.assertEqual('pingou2', items[1].username)
|
|
Pierre-Yves Chibon |
04a157 |
self.assertEqual([], items[1].groups)
|
|
Pierre-Yves Chibon |
04a157 |
self.assertEqual(
|
|
Pierre-Yves Chibon |
04a157 |
[], [email.email for email in items[1].emails])
|
|
Pierre-Yves Chibon |
04a157 |
|
|
Pierre-Yves Chibon |
a42f77 |
@patch('progit.lib.git.update_git_ticket')
|
|
Pierre-Yves Chibon |
f2c72b |
@patch('progit.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
a42f77 |
def test_new_issue(self, p_send_email, p_ugt):
|
|
Pierre-Yves Chibon |
a42f77 |
""" Test the new_issue of progit.lib. """
|
|
Pierre-Yves Chibon |
a42f77 |
p_send_email.return_value = True
|
|
Pierre-Yves Chibon |
a42f77 |
p_ugt.return_value = True
|
|
Pierre-Yves Chibon |
a42f77 |
|
|
Pierre-Yves Chibon |
a42f77 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
a42f77 |
repo = progit.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
a42f77 |
|
|
Pierre-Yves Chibon |
a42f77 |
# Before
|
|
Pierre-Yves Chibon |
a42f77 |
issues = progit.lib.search_issues(self.session, repo)
|
|
Pierre-Yves Chibon |
a42f77 |
self.assertEqual(len(issues), 0)
|
|
Pierre-Yves Chibon |
a42f77 |
|
|
Pierre-Yves Chibon |
91556a |
# See where it fails
|
|
Pierre-Yves Chibon |
91556a |
self.assertRaises(
|
|
Pierre-Yves Chibon |
91556a |
progit.exceptions.ProgitException,
|
|
Pierre-Yves Chibon |
91556a |
progit.lib.new_issue,
|
|
Pierre-Yves Chibon |
91556a |
session=self.session,
|
|
Pierre-Yves Chibon |
91556a |
repo=repo,
|
|
Pierre-Yves Chibon |
91556a |
title='Test issue',
|
|
Pierre-Yves Chibon |
91556a |
content='We should work on this',
|
|
Pierre-Yves Chibon |
91556a |
user='blah',
|
|
Pierre-Yves Chibon |
91556a |
ticketfolder=None
|
|
Pierre-Yves Chibon |
91556a |
)
|
|
Pierre-Yves Chibon |
91556a |
|
|
Pierre-Yves Chibon |
91556a |
# Create issues to play with
|
|
Pierre-Yves Chibon |
a42f77 |
msg = progit.lib.new_issue(
|
|
Pierre-Yves Chibon |
a42f77 |
session=self.session,
|
|
Pierre-Yves Chibon |
a42f77 |
repo=repo,
|
|
Pierre-Yves Chibon |
a42f77 |
title='Test issue',
|
|
Pierre-Yves Chibon |
a42f77 |
content='We should work on this',
|
|
Pierre-Yves Chibon |
a42f77 |
user='pingou',
|
|
Pierre-Yves Chibon |
a42f77 |
ticketfolder=None
|
|
Pierre-Yves Chibon |
a42f77 |
)
|
|
Pierre-Yves Chibon |
91556a |
self.session.commit()
|
|
Pierre-Yves Chibon |
91556a |
self.assertEqual(msg, 'Issue created')
|
|
Pierre-Yves Chibon |
91556a |
|
|
Pierre-Yves Chibon |
91556a |
msg = progit.lib.new_issue(
|
|
Pierre-Yves Chibon |
91556a |
session=self.session,
|
|
Pierre-Yves Chibon |
91556a |
repo=repo,
|
|
Pierre-Yves Chibon |
7e6046 |
title='Test issue #2',
|
|
Pierre-Yves Chibon |
7e6046 |
content='We should work on this for the second time',
|
|
Pierre-Yves Chibon |
91556a |
user='foo',
|
|
Pierre-Yves Chibon |
91556a |
ticketfolder=None
|
|
Pierre-Yves Chibon |
91556a |
)
|
|
Pierre-Yves Chibon |
91556a |
self.session.commit()
|
|
Pierre-Yves Chibon |
a42f77 |
self.assertEqual(msg, 'Issue created')
|
|
Pierre-Yves Chibon |
a42f77 |
|
|
Pierre-Yves Chibon |
a42f77 |
# After
|
|
Pierre-Yves Chibon |
a42f77 |
issues = progit.lib.search_issues(self.session, repo)
|
|
Pierre-Yves Chibon |
91556a |
self.assertEqual(len(issues), 2)
|
|
Pierre-Yves Chibon |
a42f77 |
|
|
Pierre-Yves Chibon |
a5099b |
@patch('progit.lib.git.update_git_ticket')
|
|
Pierre-Yves Chibon |
a5099b |
@patch('progit.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
a5099b |
def test_edit_issue(self, p_send_email, p_ugt):
|
|
Pierre-Yves Chibon |
a5099b |
""" Test the edit_issue of progit.lib. """
|
|
Pierre-Yves Chibon |
a5099b |
p_send_email.return_value = True
|
|
Pierre-Yves Chibon |
a5099b |
p_ugt.return_value = True
|
|
Pierre-Yves Chibon |
a5099b |
|
|
Pierre-Yves Chibon |
a5099b |
self.test_new_issue()
|
|
Pierre-Yves Chibon |
a5099b |
repo = progit.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
a5099b |
issue = progit.lib.search_issues(self.session, repo, issueid=2)
|
|
Pierre-Yves Chibon |
a5099b |
|
|
Pierre-Yves Chibon |
a5099b |
# Edit the issue
|
|
Pierre-Yves Chibon |
a5099b |
msg = progit.lib.edit_issue(
|
|
Pierre-Yves Chibon |
a5099b |
session=self.session,
|
|
Pierre-Yves Chibon |
a5099b |
issue=issue,
|
|
Pierre-Yves Chibon |
7e6046 |
ticketfolder=None)
|
|
Pierre-Yves Chibon |
7e6046 |
self.session.commit()
|
|
Pierre-Yves Chibon |
7e6046 |
self.assertEqual(msg, 'No changes to edit')
|
|
Pierre-Yves Chibon |
7e6046 |
|
|
Pierre-Yves Chibon |
7e6046 |
msg = progit.lib.edit_issue(
|
|
Pierre-Yves Chibon |
7e6046 |
session=self.session,
|
|
Pierre-Yves Chibon |
7e6046 |
issue=issue,
|
|
Pierre-Yves Chibon |
7e6046 |
ticketfolder=None,
|
|
Pierre-Yves Chibon |
7e6046 |
title='Test issue #2',
|
|
Pierre-Yves Chibon |
7e6046 |
content='We should work on this for the second time',
|
|
Pierre-Yves Chibon |
7e6046 |
status='Open',
|
|
Pierre-Yves Chibon |
7e6046 |
)
|
|
Pierre-Yves Chibon |
7e6046 |
self.session.commit()
|
|
Pierre-Yves Chibon |
7e6046 |
self.assertEqual(msg, 'No changes to edit')
|
|
Pierre-Yves Chibon |
7e6046 |
|
|
Pierre-Yves Chibon |
7e6046 |
msg = progit.lib.edit_issue(
|
|
Pierre-Yves Chibon |
7e6046 |
session=self.session,
|
|
Pierre-Yves Chibon |
7e6046 |
issue=issue,
|
|
Pierre-Yves Chibon |
a5099b |
ticketfolder=None,
|
|
Pierre-Yves Chibon |
7e6046 |
title='Foo issue #2',
|
|
Pierre-Yves Chibon |
7e6046 |
content='We should work on this period',
|
|
Pierre-Yves Chibon |
a5099b |
status='Invalid')
|
|
Pierre-Yves Chibon |
a5099b |
self.session.commit()
|
|
Pierre-Yves Chibon |
a5099b |
self.assertEqual(msg, 'Edited successfully issue #2')
|
|
Pierre-Yves Chibon |
a5099b |
|
|
Pierre-Yves Chibon |
663645 |
@patch('progit.lib.git.update_git_ticket')
|
|
Pierre-Yves Chibon |
663645 |
@patch('progit.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
8393f9 |
def test_add_issue_tag(self, p_send_email, p_ugt):
|
|
Pierre-Yves Chibon |
8393f9 |
""" Test the add_issue_tag of progit.lib. """
|
|
Pierre-Yves Chibon |
8393f9 |
p_send_email.return_value = True
|
|
Pierre-Yves Chibon |
8393f9 |
p_ugt.return_value = True
|
|
Pierre-Yves Chibon |
8393f9 |
|
|
Pierre-Yves Chibon |
8393f9 |
self.test_edit_issue()
|
|
Pierre-Yves Chibon |
8393f9 |
repo = progit.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
8393f9 |
issue = progit.lib.search_issues(self.session, repo, issueid=1)
|
|
Pierre-Yves Chibon |
8393f9 |
|
|
Pierre-Yves Chibon |
8393f9 |
# Add a tag to the issue
|
|
Pierre-Yves Chibon |
8393f9 |
msg = progit.lib.add_issue_tag(
|
|
Pierre-Yves Chibon |
8393f9 |
session=self.session,
|
|
Pierre-Yves Chibon |
8393f9 |
issue=issue,
|
|
Pierre-Yves Chibon |
8393f9 |
tag='tag1',
|
|
Pierre-Yves Chibon |
8393f9 |
user='pingou',
|
|
Pierre-Yves Chibon |
8393f9 |
ticketfolder=None)
|
|
Pierre-Yves Chibon |
8393f9 |
self.session.commit()
|
|
Pierre-Yves Chibon |
8393f9 |
self.assertEqual(msg, 'Tag added')
|
|
Pierre-Yves Chibon |
8393f9 |
|
|
Pierre-Yves Chibon |
b4f437 |
# Try a second time
|
|
Pierre-Yves Chibon |
731160 |
self.assertRaises(
|
|
Pierre-Yves Chibon |
731160 |
progit.exceptions.ProgitException,
|
|
Pierre-Yves Chibon |
731160 |
progit.lib.add_issue_tag,
|
|
Pierre-Yves Chibon |
b4f437 |
session=self.session,
|
|
Pierre-Yves Chibon |
b4f437 |
issue=issue,
|
|
Pierre-Yves Chibon |
b4f437 |
tag='tag1',
|
|
Pierre-Yves Chibon |
b4f437 |
user='pingou',
|
|
Pierre-Yves Chibon |
b4f437 |
ticketfolder=None)
|
|
Pierre-Yves Chibon |
b4f437 |
|
|
Pierre-Yves Chibon |
8393f9 |
issues = progit.lib.search_issues(self.session, repo, tags='tag1')
|
|
Pierre-Yves Chibon |
8393f9 |
self.assertEqual(len(issues), 1)
|
|
Pierre-Yves Chibon |
8393f9 |
self.assertEqual(issues[0].id, 1)
|
|
Pierre-Yves Chibon |
8393f9 |
self.assertEqual(issues[0].project_id, 1)
|
|
Pierre-Yves Chibon |
8393f9 |
self.assertEqual(issues[0].status, 'Open')
|
|
Pierre-Yves Chibon |
8393f9 |
self.assertEqual([tag.tag for tag in issues[0].tags], ['tag1'])
|
|
Pierre-Yves Chibon |
8393f9 |
|
|
Pierre-Yves Chibon |
8393f9 |
@patch('progit.lib.git.update_git_ticket')
|
|
Pierre-Yves Chibon |
8393f9 |
@patch('progit.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
07093f |
def test_remove_issue_tags(self, p_send_email, p_ugt):
|
|
Pierre-Yves Chibon |
07093f |
""" Test the remove_issue_tags of progit.lib. """
|
|
Pierre-Yves Chibon |
07093f |
p_send_email.return_value = True
|
|
Pierre-Yves Chibon |
07093f |
p_ugt.return_value = True
|
|
Pierre-Yves Chibon |
07093f |
|
|
Pierre-Yves Chibon |
07093f |
self.test_add_issue_tag()
|
|
Pierre-Yves Chibon |
07093f |
repo = progit.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
07093f |
issue = progit.lib.search_issues(self.session, repo, issueid=1)
|
|
Pierre-Yves Chibon |
07093f |
|
|
Pierre-Yves Chibon |
07093f |
self.assertRaises(
|
|
Pierre-Yves Chibon |
07093f |
progit.exceptions.ProgitException,
|
|
Pierre-Yves Chibon |
07093f |
progit.lib.remove_issue_tags,
|
|
Pierre-Yves Chibon |
07093f |
session=self.session,
|
|
Pierre-Yves Chibon |
07093f |
project=repo,
|
|
Pierre-Yves Chibon |
07093f |
tags='foo')
|
|
Pierre-Yves Chibon |
07093f |
|
|
Pierre-Yves Chibon |
07093f |
msgs = progit.lib.remove_issue_tags(
|
|
Pierre-Yves Chibon |
07093f |
session=self.session,
|
|
Pierre-Yves Chibon |
07093f |
project=repo,
|
|
Pierre-Yves Chibon |
07093f |
tags='tag1')
|
|
Pierre-Yves Chibon |
07093f |
|
|
Pierre-Yves Chibon |
07093f |
self.assertEqual(msgs, [u'Removed tag: tag1'])
|
|
Pierre-Yves Chibon |
07093f |
|
|
Pierre-Yves Chibon |
e1fce0 |
@patch('progit.lib.git.update_git_ticket')
|
|
Pierre-Yves Chibon |
e1fce0 |
@patch('progit.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
e1fce0 |
def test_edit_issue_tags(self, p_send_email, p_ugt):
|
|
Pierre-Yves Chibon |
e1fce0 |
""" Test the edit_issue_tags of progit.lib. """
|
|
Pierre-Yves Chibon |
e1fce0 |
p_send_email.return_value = True
|
|
Pierre-Yves Chibon |
e1fce0 |
p_ugt.return_value = True
|
|
Pierre-Yves Chibon |
e1fce0 |
|
|
Pierre-Yves Chibon |
e1fce0 |
self.test_add_issue_tag()
|
|
Pierre-Yves Chibon |
e1fce0 |
repo = progit.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
e1fce0 |
issue = progit.lib.search_issues(self.session, repo, issueid=1)
|
|
Pierre-Yves Chibon |
e1fce0 |
|
|
Pierre-Yves Chibon |
e1fce0 |
self.assertRaises(
|
|
Pierre-Yves Chibon |
e1fce0 |
progit.exceptions.ProgitException,
|
|
Pierre-Yves Chibon |
e1fce0 |
progit.lib.edit_issue_tags,
|
|
Pierre-Yves Chibon |
e1fce0 |
session=self.session,
|
|
Pierre-Yves Chibon |
e1fce0 |
project=repo,
|
|
Pierre-Yves Chibon |
e1fce0 |
old_tag='foo',
|
|
Pierre-Yves Chibon |
e1fce0 |
new_tag='bar')
|
|
Pierre-Yves Chibon |
e1fce0 |
|
|
Pierre-Yves Chibon |
e1fce0 |
msgs = progit.lib.edit_issue_tags(
|
|
Pierre-Yves Chibon |
e1fce0 |
session=self.session,
|
|
Pierre-Yves Chibon |
e1fce0 |
project=repo,
|
|
Pierre-Yves Chibon |
e1fce0 |
old_tag='tag1',
|
|
Pierre-Yves Chibon |
e1fce0 |
new_tag='tag2')
|
|
Pierre-Yves Chibon |
e1fce0 |
self.session.commit()
|
|
Pierre-Yves Chibon |
e1fce0 |
self.assertEqual(msgs, ['Edited tag: tag1 to tag2'])
|
|
Pierre-Yves Chibon |
e1fce0 |
|
|
Pierre-Yves Chibon |
e1fce0 |
self.assertRaises(
|
|
Pierre-Yves Chibon |
e1fce0 |
progit.exceptions.ProgitException,
|
|
Pierre-Yves Chibon |
e1fce0 |
progit.lib.edit_issue_tags,
|
|
Pierre-Yves Chibon |
e1fce0 |
session=self.session,
|
|
Pierre-Yves Chibon |
e1fce0 |
project=repo,
|
|
Pierre-Yves Chibon |
e1fce0 |
old_tag='tag2',
|
|
Pierre-Yves Chibon |
e1fce0 |
new_tag='tag2')
|
|
Pierre-Yves Chibon |
07093f |
|
|
Pierre-Yves Chibon |
07093f |
@patch('progit.lib.git.update_git_ticket')
|
|
Pierre-Yves Chibon |
07093f |
@patch('progit.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
663645 |
def test_search_issues(self, p_send_email, p_ugt):
|
|
Pierre-Yves Chibon |
663645 |
""" Test the search_issues of progit.lib. """
|
|
Pierre-Yves Chibon |
663645 |
p_send_email.return_value = True
|
|
Pierre-Yves Chibon |
663645 |
p_ugt.return_value = True
|
|
Pierre-Yves Chibon |
663645 |
|
|
Pierre-Yves Chibon |
663645 |
self.test_edit_issue()
|
|
Pierre-Yves Chibon |
663645 |
repo = progit.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
663645 |
|
|
Pierre-Yves Chibon |
663645 |
# All issues
|
|
Pierre-Yves Chibon |
663645 |
issues = progit.lib.search_issues(self.session, repo)
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(len(issues), 2)
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(issues[0].id, 1)
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(issues[0].project_id, 1)
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(issues[0].status, 'Open')
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(issues[0].tags, [])
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(issues[1].id, 2)
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(issues[1].project_id, 1)
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(issues[1].status, 'Invalid')
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(issues[1].tags, [])
|
|
Pierre-Yves Chibon |
663645 |
|
|
Pierre-Yves Chibon |
663645 |
# Issues by status
|
|
Pierre-Yves Chibon |
663645 |
issues = progit.lib.search_issues(
|
|
Pierre-Yves Chibon |
663645 |
self.session, repo, status='Invalid')
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(len(issues), 1)
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(issues[0].id, 2)
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(issues[0].project_id, 1)
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(issues[0].status, 'Invalid')
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(issues[0].tags, [])
|
|
Pierre-Yves Chibon |
663645 |
|
|
Pierre-Yves Chibon |
663645 |
# Issues closed
|
|
Pierre-Yves Chibon |
663645 |
issues = progit.lib.search_issues(
|
|
Pierre-Yves Chibon |
663645 |
self.session, repo, closed=True)
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(len(issues), 1)
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(issues[0].id, 2)
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(issues[0].project_id, 1)
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(issues[0].status, 'Invalid')
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(issues[0].tags, [])
|
|
Pierre-Yves Chibon |
663645 |
|
|
Pierre-Yves Chibon |
663645 |
# Issues by tag
|
|
Pierre-Yves Chibon |
663645 |
issues = progit.lib.search_issues(self.session, repo, tags='foo')
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(len(issues), 0)
|
|
Pierre-Yves Chibon |
663645 |
|
|
Pierre-Yves Chibon |
663645 |
# Issue by id
|
|
Pierre-Yves Chibon |
663645 |
issue = progit.lib.search_issues(self.session, repo, issueid=1)
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(issue.title, 'Test issue')
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(issue.user.user, 'pingou')
|
|
Pierre-Yves Chibon |
663645 |
self.assertEqual(issue.tags, [])
|
|
Pierre-Yves Chibon |
663645 |
|
|
Pierre-Yves Chibon |
4b6666 |
# Issues by authors
|
|
Pierre-Yves Chibon |
4b6666 |
issues = progit.lib.search_issues(self.session, repo, author='foo')
|
|
Pierre-Yves Chibon |
4b6666 |
self.assertEqual(len(issues), 1)
|
|
Pierre-Yves Chibon |
4b6666 |
self.assertEqual(issues[0].id, 2)
|
|
Pierre-Yves Chibon |
4b6666 |
self.assertEqual(issues[0].project_id, 1)
|
|
Pierre-Yves Chibon |
4b6666 |
self.assertEqual(issues[0].status, 'Invalid')
|
|
Pierre-Yves Chibon |
4b6666 |
self.assertEqual(issues[0].tags, [])
|
|
Pierre-Yves Chibon |
4b6666 |
|
|
Pierre-Yves Chibon |
a96644 |
@patch('progit.lib.git.update_git_ticket')
|
|
Pierre-Yves Chibon |
a96644 |
@patch('progit.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
a96644 |
def test_add_issue_assignee(self, p_send_email, p_ugt):
|
|
Pierre-Yves Chibon |
a96644 |
""" Test the add_issue_assignee of progit.lib. """
|
|
Pierre-Yves Chibon |
a96644 |
p_send_email.return_value = True
|
|
Pierre-Yves Chibon |
a96644 |
p_ugt.return_value = True
|
|
Pierre-Yves Chibon |
a96644 |
|
|
Pierre-Yves Chibon |
a96644 |
self.test_new_issue()
|
|
Pierre-Yves Chibon |
a96644 |
repo = progit.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
a96644 |
issue = progit.lib.search_issues(self.session, repo, issueid=2)
|
|
Pierre-Yves Chibon |
a96644 |
|
|
Pierre-Yves Chibon |
a96644 |
# Before
|
|
Pierre-Yves Chibon |
a96644 |
issues = progit.lib.search_issues(
|
|
Pierre-Yves Chibon |
a96644 |
self.session, repo, assignee='pingou')
|
|
Pierre-Yves Chibon |
a96644 |
self.assertEqual(len(issues), 0)
|
|
Pierre-Yves Chibon |
a96644 |
|
|
Pierre-Yves Chibon |
13b9f7 |
# Test when it fails
|
|
Pierre-Yves Chibon |
13b9f7 |
self.assertRaises(
|
|
Pierre-Yves Chibon |
13b9f7 |
progit.exceptions.ProgitException,
|
|
Pierre-Yves Chibon |
13b9f7 |
progit.lib.add_issue_assignee,
|
|
Pierre-Yves Chibon |
13b9f7 |
session=self.session,
|
|
Pierre-Yves Chibon |
13b9f7 |
issue=issue,
|
|
Pierre-Yves Chibon |
13b9f7 |
assignee='foo@foobar.com',
|
|
Pierre-Yves Chibon |
13b9f7 |
user='foo@pingou.com',
|
|
Pierre-Yves Chibon |
13b9f7 |
ticketfolder=None
|
|
Pierre-Yves Chibon |
13b9f7 |
)
|
|
Pierre-Yves Chibon |
13b9f7 |
|
|
Pierre-Yves Chibon |
13b9f7 |
self.assertRaises(
|
|
Pierre-Yves Chibon |
13b9f7 |
progit.exceptions.ProgitException,
|
|
Pierre-Yves Chibon |
13b9f7 |
progit.lib.add_issue_assignee,
|
|
Pierre-Yves Chibon |
13b9f7 |
session=self.session,
|
|
Pierre-Yves Chibon |
13b9f7 |
issue=issue,
|
|
Pierre-Yves Chibon |
13b9f7 |
assignee='foo@bar.com',
|
|
Pierre-Yves Chibon |
13b9f7 |
user='foo@foopingou.com',
|
|
Pierre-Yves Chibon |
13b9f7 |
ticketfolder=None
|
|
Pierre-Yves Chibon |
13b9f7 |
)
|
|
Pierre-Yves Chibon |
13b9f7 |
|
|
Pierre-Yves Chibon |
d14691 |
# Set the assignee by its email
|
|
Pierre-Yves Chibon |
d14691 |
msg = progit.lib.add_issue_assignee(
|
|
Pierre-Yves Chibon |
d14691 |
session=self.session,
|
|
Pierre-Yves Chibon |
d14691 |
issue=issue,
|
|
Pierre-Yves Chibon |
d14691 |
assignee='foo@bar.com',
|
|
Pierre-Yves Chibon |
13b9f7 |
user='foo@pingou.com',
|
|
Pierre-Yves Chibon |
d14691 |
ticketfolder=None)
|
|
Pierre-Yves Chibon |
d14691 |
self.session.commit()
|
|
Pierre-Yves Chibon |
d14691 |
self.assertEqual(msg, 'Issue assigned')
|
|
Pierre-Yves Chibon |
d14691 |
|
|
Pierre-Yves Chibon |
d14691 |
# Change the assignee to someone else by its username
|
|
Pierre-Yves Chibon |
a96644 |
msg = progit.lib.add_issue_assignee(
|
|
Pierre-Yves Chibon |
a96644 |
session=self.session,
|
|
Pierre-Yves Chibon |
a96644 |
issue=issue,
|
|
Pierre-Yves Chibon |
a96644 |
assignee='pingou',
|
|
Pierre-Yves Chibon |
a96644 |
user='pingou',
|
|
Pierre-Yves Chibon |
a96644 |
ticketfolder=None)
|
|
Pierre-Yves Chibon |
a96644 |
self.session.commit()
|
|
Pierre-Yves Chibon |
a96644 |
self.assertEqual(msg, 'Issue assigned')
|
|
Pierre-Yves Chibon |
a96644 |
|
|
Pierre-Yves Chibon |
a96644 |
# After -- Searches by assignee
|
|
Pierre-Yves Chibon |
a96644 |
issues = progit.lib.search_issues(
|
|
Pierre-Yves Chibon |
a96644 |
self.session, repo, assignee='pingou')
|
|
Pierre-Yves Chibon |
a96644 |
self.assertEqual(len(issues), 1)
|
|
Pierre-Yves Chibon |
a96644 |
self.assertEqual(issues[0].id, 2)
|
|
Pierre-Yves Chibon |
a96644 |
self.assertEqual(issues[0].project_id, 1)
|
|
Pierre-Yves Chibon |
a96644 |
self.assertEqual(issues[0].status, 'Open')
|
|
Pierre-Yves Chibon |
a96644 |
self.assertEqual(issues[0].tags, [])
|
|
Pierre-Yves Chibon |
a96644 |
|
|
Pierre-Yves Chibon |
a96644 |
issues = progit.lib.search_issues(
|
|
Pierre-Yves Chibon |
a96644 |
self.session, repo, assignee=True)
|
|
Pierre-Yves Chibon |
a96644 |
self.assertEqual(len(issues), 1)
|
|
Pierre-Yves Chibon |
a96644 |
self.assertEqual(issues[0].id, 2)
|
|
Pierre-Yves Chibon |
a96644 |
self.assertEqual(issues[0].title, 'Test issue #2')
|
|
Pierre-Yves Chibon |
a96644 |
self.assertEqual(issues[0].project_id, 1)
|
|
Pierre-Yves Chibon |
a96644 |
self.assertEqual(issues[0].status, 'Open')
|
|
Pierre-Yves Chibon |
a96644 |
self.assertEqual(issues[0].tags, [])
|
|
Pierre-Yves Chibon |
a96644 |
|
|
Pierre-Yves Chibon |
a96644 |
issues = progit.lib.search_issues(
|
|
Pierre-Yves Chibon |
a96644 |
self.session, repo, assignee=False)
|
|
Pierre-Yves Chibon |
a96644 |
self.assertEqual(len(issues), 1)
|
|
Pierre-Yves Chibon |
a96644 |
self.assertEqual(issues[0].id, 1)
|
|
Pierre-Yves Chibon |
a96644 |
self.assertEqual(issues[0].title, 'Test issue')
|
|
Pierre-Yves Chibon |
a96644 |
self.assertEqual(issues[0].project_id, 1)
|
|
Pierre-Yves Chibon |
a96644 |
self.assertEqual(issues[0].status, 'Open')
|
|
Pierre-Yves Chibon |
a96644 |
self.assertEqual(issues[0].tags, [])
|
|
Pierre-Yves Chibon |
a96644 |
|
|
Pierre-Yves Chibon |
d14691 |
# Reset the assignee to no-one
|
|
Pierre-Yves Chibon |
d14691 |
msg = progit.lib.add_issue_assignee(
|
|
Pierre-Yves Chibon |
d14691 |
session=self.session,
|
|
Pierre-Yves Chibon |
d14691 |
issue=issue,
|
|
Pierre-Yves Chibon |
d14691 |
assignee=None,
|
|
Pierre-Yves Chibon |
d14691 |
user='pingou',
|
|
Pierre-Yves Chibon |
d14691 |
ticketfolder=None)
|
|
Pierre-Yves Chibon |
d14691 |
self.session.commit()
|
|
Pierre-Yves Chibon |
d14691 |
self.assertEqual(msg, 'Assignee reset')
|
|
Pierre-Yves Chibon |
d14691 |
|
|
Pierre-Yves Chibon |
d14691 |
issues = progit.lib.search_issues(
|
|
Pierre-Yves Chibon |
d14691 |
self.session, repo, assignee=False)
|
|
Pierre-Yves Chibon |
d14691 |
self.assertEqual(len(issues), 2)
|
|
Pierre-Yves Chibon |
d14691 |
self.assertEqual(issues[0].id, 1)
|
|
Pierre-Yves Chibon |
d14691 |
self.assertEqual(issues[1].id, 2)
|
|
Pierre-Yves Chibon |
d14691 |
|
|
Pierre-Yves Chibon |
d14691 |
issues = progit.lib.search_issues(
|
|
Pierre-Yves Chibon |
d14691 |
self.session, repo, assignee=True)
|
|
Pierre-Yves Chibon |
d14691 |
self.assertEqual(len(issues), 0)
|
|
Pierre-Yves Chibon |
d14691 |
|
|
Pierre-Yves Chibon |
e30eee |
@patch('progit.lib.git.update_git_ticket')
|
|
Pierre-Yves Chibon |
e30eee |
@patch('progit.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
e30eee |
def test_add_issue_comment(self, p_send_email, p_ugt):
|
|
Pierre-Yves Chibon |
e30eee |
""" Test the add_issue_comment of progit.lib. """
|
|
Pierre-Yves Chibon |
e30eee |
p_send_email.return_value = True
|
|
Pierre-Yves Chibon |
e30eee |
p_ugt.return_value = True
|
|
Pierre-Yves Chibon |
e30eee |
|
|
Pierre-Yves Chibon |
e30eee |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
e30eee |
self.test_new_issue()
|
|
Pierre-Yves Chibon |
e30eee |
repo = progit.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
e30eee |
|
|
Pierre-Yves Chibon |
e30eee |
# Before
|
|
Pierre-Yves Chibon |
e30eee |
issue = progit.lib.search_issues(self.session, repo, issueid=1)
|
|
Pierre-Yves Chibon |
e30eee |
self.assertEqual(len(issue.comments), 0)
|
|
Pierre-Yves Chibon |
e30eee |
|
|
Pierre-Yves Chibon |
e30eee |
# Add a comment to that issue
|
|
Pierre-Yves Chibon |
e30eee |
msg = progit.lib.add_issue_comment(
|
|
Pierre-Yves Chibon |
e30eee |
session=self.session,
|
|
Pierre-Yves Chibon |
e30eee |
issue=issue,
|
|
Pierre-Yves Chibon |
e30eee |
comment='Hey look a comment!',
|
|
Pierre-Yves Chibon |
e30eee |
user='foo',
|
|
Pierre-Yves Chibon |
e30eee |
ticketfolder=None
|
|
Pierre-Yves Chibon |
e30eee |
)
|
|
Pierre-Yves Chibon |
e30eee |
self.session.commit()
|
|
Pierre-Yves Chibon |
e30eee |
self.assertEqual(msg, 'Comment added')
|
|
Pierre-Yves Chibon |
e30eee |
|
|
Pierre-Yves Chibon |
e30eee |
# After
|
|
Pierre-Yves Chibon |
e30eee |
issue = progit.lib.search_issues(self.session, repo, issueid=1)
|
|
Pierre-Yves Chibon |
e30eee |
self.assertEqual(len(issue.comments), 1)
|
|
Pierre-Yves Chibon |
e30eee |
self.assertEqual(issue.comments[0].comment, 'Hey look a comment!')
|
|
Pierre-Yves Chibon |
e30eee |
self.assertEqual(issue.comments[0].user.user, 'foo')
|
|
Pierre-Yves Chibon |
e30eee |
|
|
Pierre-Yves Chibon |
228df2 |
@patch('progit.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
228df2 |
def test_add_user_to_project(self, p_send_email):
|
|
Pierre-Yves Chibon |
228df2 |
""" Test the add_user_to_project of progit.lib. """
|
|
Pierre-Yves Chibon |
228df2 |
p_send_email.return_value = True
|
|
Pierre-Yves Chibon |
228df2 |
|
|
Pierre-Yves Chibon |
228df2 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
228df2 |
|
|
Pierre-Yves Chibon |
228df2 |
# Before
|
|
Pierre-Yves Chibon |
228df2 |
repo = progit.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
228df2 |
self.assertEqual(len(repo.users), 0)
|
|
Pierre-Yves Chibon |
228df2 |
|
|
Pierre-Yves Chibon |
228df2 |
# Add an user to a project
|
|
Pierre-Yves Chibon |
228df2 |
self.assertRaises(
|
|
Pierre-Yves Chibon |
228df2 |
progit.exceptions.ProgitException,
|
|
Pierre-Yves Chibon |
228df2 |
progit.lib.add_user_to_project,
|
|
Pierre-Yves Chibon |
228df2 |
session=self.session,
|
|
Pierre-Yves Chibon |
228df2 |
project=repo,
|
|
Pierre-Yves Chibon |
228df2 |
user='foobar',
|
|
Pierre-Yves Chibon |
228df2 |
)
|
|
Pierre-Yves Chibon |
228df2 |
|
|
Pierre-Yves Chibon |
228df2 |
msg = progit.lib.add_user_to_project(
|
|
Pierre-Yves Chibon |
228df2 |
session=self.session,
|
|
Pierre-Yves Chibon |
228df2 |
project=repo,
|
|
Pierre-Yves Chibon |
228df2 |
user='foo',
|
|
Pierre-Yves Chibon |
228df2 |
)
|
|
Pierre-Yves Chibon |
228df2 |
self.session.commit()
|
|
Pierre-Yves Chibon |
228df2 |
self.assertEqual(msg, 'User added')
|
|
Pierre-Yves Chibon |
228df2 |
|
|
Pierre-Yves Chibon |
228df2 |
# After
|
|
Pierre-Yves Chibon |
228df2 |
repo = progit.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
228df2 |
self.assertEqual(len(repo.users), 1)
|
|
Pierre-Yves Chibon |
228df2 |
self.assertEqual(repo.users[0].user, 'foo')
|
|
Pierre-Yves Chibon |
228df2 |
|
|
Pierre-Yves Chibon |
4fbc78 |
def test_new_project(self):
|
|
Pierre-Yves Chibon |
4fbc78 |
""" Test the new_project of progit.lib. """
|
|
Pierre-Yves Chibon |
4fbc78 |
gitfolder = os.path.join(self.path, 'repos')
|
|
Pierre-Yves Chibon |
4fbc78 |
docfolder = os.path.join(self.path, 'docs')
|
|
Pierre-Yves Chibon |
4fbc78 |
ticketfolder = os.path.join(self.path, 'tickets')
|
|
Pierre-Yves Chibon |
4fbc78 |
|
|
Pierre-Yves Chibon |
4fbc78 |
os.mkdir(gitfolder)
|
|
Pierre-Yves Chibon |
4fbc78 |
os.mkdir(docfolder)
|
|
Pierre-Yves Chibon |
4fbc78 |
os.mkdir(ticketfolder)
|
|
Pierre-Yves Chibon |
4fbc78 |
|
|
Pierre-Yves Chibon |
4fbc78 |
# Create a new project
|
|
Pierre-Yves Chibon |
4fbc78 |
msg = progit.lib.new_project(
|
|
Pierre-Yves Chibon |
4fbc78 |
session=self.session,
|
|
Pierre-Yves Chibon |
4fbc78 |
user='pingou',
|
|
Pierre-Yves Chibon |
4fbc78 |
name='testproject',
|
|
Pierre-Yves Chibon |
4fbc78 |
gitfolder=gitfolder,
|
|
Pierre-Yves Chibon |
4fbc78 |
docfolder=docfolder,
|
|
Pierre-Yves Chibon |
4fbc78 |
ticketfolder=ticketfolder,
|
|
Pierre-Yves Chibon |
4fbc78 |
description='description for testproject',
|
|
Pierre-Yves Chibon |
4fbc78 |
parent_id=None
|
|
Pierre-Yves Chibon |
4fbc78 |
)
|
|
Pierre-Yves Chibon |
4fbc78 |
self.session.commit()
|
|
Pierre-Yves Chibon |
4fbc78 |
self.assertEqual(msg, 'Project "testproject" created')
|
|
Pierre-Yves Chibon |
4fbc78 |
|
|
Pierre-Yves Chibon |
4fbc78 |
repo = progit.lib.get_project(self.session, 'testproject')
|
|
Pierre-Yves Chibon |
4fbc78 |
self.assertEqual(repo.path, 'testproject.git')
|
|
Pierre-Yves Chibon |
4fbc78 |
|
|
Pierre-Yves Chibon |
4fbc78 |
gitrepo = os.path.join(gitfolder, repo.path)
|
|
Pierre-Yves Chibon |
4fbc78 |
docrepo = os.path.join(docfolder, repo.path)
|
|
Pierre-Yves Chibon |
4fbc78 |
ticketrepo = os.path.join(ticketfolder, repo.path)
|
|
Pierre-Yves Chibon |
4fbc78 |
|
|
Pierre-Yves Chibon |
4fbc78 |
self.assertTrue(os.path.exists(gitrepo))
|
|
Pierre-Yves Chibon |
4fbc78 |
self.assertTrue(os.path.exists(docrepo))
|
|
Pierre-Yves Chibon |
4fbc78 |
self.assertTrue(os.path.exists(ticketrepo))
|
|
Pierre-Yves Chibon |
4fbc78 |
|
|
Pierre-Yves Chibon |
4fbc78 |
# Try re-creating it but all repos are existing
|
|
Pierre-Yves Chibon |
4fbc78 |
self.assertRaises(
|
|
Pierre-Yves Chibon |
4fbc78 |
progit.exceptions.ProgitException,
|
|
Pierre-Yves Chibon |
4fbc78 |
progit.lib.new_project,
|
|
Pierre-Yves Chibon |
4fbc78 |
session=self.session,
|
|
Pierre-Yves Chibon |
4fbc78 |
user='pingou',
|
|
Pierre-Yves Chibon |
4fbc78 |
name='testproject',
|
|
Pierre-Yves Chibon |
4fbc78 |
gitfolder=gitfolder,
|
|
Pierre-Yves Chibon |
4fbc78 |
docfolder=docfolder,
|
|
Pierre-Yves Chibon |
4fbc78 |
ticketfolder=ticketfolder,
|
|
Pierre-Yves Chibon |
4fbc78 |
description='description for testproject',
|
|
Pierre-Yves Chibon |
4fbc78 |
parent_id=None
|
|
Pierre-Yves Chibon |
4fbc78 |
)
|
|
Pierre-Yves Chibon |
4fbc78 |
self.session.rollback()
|
|
Pierre-Yves Chibon |
4fbc78 |
|
|
Pierre-Yves Chibon |
4fbc78 |
self.assertTrue(os.path.exists(gitrepo))
|
|
Pierre-Yves Chibon |
4fbc78 |
self.assertTrue(os.path.exists(docrepo))
|
|
Pierre-Yves Chibon |
4fbc78 |
self.assertTrue(os.path.exists(ticketrepo))
|
|
Pierre-Yves Chibon |
4fbc78 |
|
|
Pierre-Yves Chibon |
4fbc78 |
# Drop the main git repo and try again
|
|
Pierre-Yves Chibon |
4fbc78 |
shutil.rmtree(gitrepo)
|
|
Pierre-Yves Chibon |
4fbc78 |
self.assertRaises(
|
|
Pierre-Yves Chibon |
4fbc78 |
progit.exceptions.ProgitException,
|
|
Pierre-Yves Chibon |
4fbc78 |
progit.lib.new_project,
|
|
Pierre-Yves Chibon |
4fbc78 |
session=self.session,
|
|
Pierre-Yves Chibon |
4fbc78 |
user='pingou',
|
|
Pierre-Yves Chibon |
4fbc78 |
name='testproject',
|
|
Pierre-Yves Chibon |
4fbc78 |
gitfolder=gitfolder,
|
|
Pierre-Yves Chibon |
4fbc78 |
docfolder=docfolder,
|
|
Pierre-Yves Chibon |
4fbc78 |
ticketfolder=ticketfolder,
|
|
Pierre-Yves Chibon |
4fbc78 |
description='description for testproject',
|
|
Pierre-Yves Chibon |
4fbc78 |
parent_id=None
|
|
Pierre-Yves Chibon |
4fbc78 |
)
|
|
Pierre-Yves Chibon |
4fbc78 |
self.session.rollback()
|
|
Pierre-Yves Chibon |
4fbc78 |
|
|
Pierre-Yves Chibon |
4fbc78 |
self.assertFalse(os.path.exists(gitrepo))
|
|
Pierre-Yves Chibon |
4fbc78 |
self.assertTrue(os.path.exists(docrepo))
|
|
Pierre-Yves Chibon |
4fbc78 |
self.assertTrue(os.path.exists(ticketrepo))
|
|
Pierre-Yves Chibon |
4fbc78 |
|
|
Pierre-Yves Chibon |
4fbc78 |
# Drop the doc repo and try again
|
|
Pierre-Yves Chibon |
4fbc78 |
shutil.rmtree(docrepo)
|
|
Pierre-Yves Chibon |
4fbc78 |
self.assertRaises(
|
|
Pierre-Yves Chibon |
4fbc78 |
progit.exceptions.ProgitException,
|
|
Pierre-Yves Chibon |
4fbc78 |
progit.lib.new_project,
|
|
Pierre-Yves Chibon |
4fbc78 |
session=self.session,
|
|
Pierre-Yves Chibon |
4fbc78 |
user='pingou',
|
|
Pierre-Yves Chibon |
4fbc78 |
name='testproject',
|
|
Pierre-Yves Chibon |
4fbc78 |
gitfolder=gitfolder,
|
|
Pierre-Yves Chibon |
4fbc78 |
docfolder=docfolder,
|
|
Pierre-Yves Chibon |
4fbc78 |
ticketfolder=ticketfolder,
|
|
Pierre-Yves Chibon |
4fbc78 |
description='description for testproject',
|
|
Pierre-Yves Chibon |
4fbc78 |
parent_id=None
|
|
Pierre-Yves Chibon |
4fbc78 |
)
|
|
Pierre-Yves Chibon |
4fbc78 |
self.session.rollback()
|
|
Pierre-Yves Chibon |
4fbc78 |
self.assertFalse(os.path.exists(gitrepo))
|
|
Pierre-Yves Chibon |
4fbc78 |
self.assertFalse(os.path.exists(docrepo))
|
|
Pierre-Yves Chibon |
4fbc78 |
self.assertTrue(os.path.exists(ticketrepo))
|
|
Pierre-Yves Chibon |
4fbc78 |
|
|
Pierre-Yves Chibon |
d88010 |
|
|
Pierre-Yves Chibon |
d88010 |
if __name__ == '__main__':
|
|
Pierre-Yves Chibon |
d88010 |
SUITE = unittest.TestLoader().loadTestsFromTestCase(ProgitLibtests)
|
|
Pierre-Yves Chibon |
d88010 |
unittest.TextTestRunner(verbosity=2).run(SUITE)
|