Skip to content

Commit

Permalink
reworked tests of votes so they should not randomly fail anymore.
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Jan 15, 2015
1 parent d2db73e commit 69c5295
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 26 deletions.
3 changes: 1 addition & 2 deletions jira/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1768,8 +1768,7 @@ def _get_url(self, path, base=JIRA_BASE_URL):

def _get_json(self, path, params=None, base=JIRA_BASE_URL):
url = self._get_url(path, base)
r = self._session.get(
url, params=params, headers=self._options['headers'])
r = self._session.get(url, params=params)
try:
r_json = json_loads(r)
except ValueError as e:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def initialize_options(self):
# pass
self.pytest_args.append("-s")

if os.isatty(sys.stdout.fileno()):
if sys.stdout.isatty():
# when run manually we enable fail fast
self.pytest_args.append("--maxfail=2")

Expand Down
40 changes: 17 additions & 23 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,39 +1028,33 @@ def test_transition_issue_with_fielddict(self):
self.assertEqual(issue.fields.status.id, '5')

def test_votes(self):
self.jira_normal.remove_vote(self.issue_1)
# not checking the result on this
votes = self.jira.votes(self.issue_1)
self.assertEqual(votes.votes, 0)

self.jira_normal.add_vote(self.issue_1)
new_votes = self.jira.votes(self.issue_1)
assert votes.votes + 1 == new_votes.votes

self.jira_normal.remove_vote(self.issue_1)
new_votes = self.jira.votes(self.issue_1)
assert votes.votes == new_votes.votes

def test_votes_with_issue_obj(self):
issue = self.jira.issue(self.issue_1)
issue = self.jira_normal.issue(self.issue_1)
self.jira_normal.remove_vote(issue)
# not checking the result on this
votes = self.jira.votes(issue)
self.assertEqual(votes.votes, 0)

def test_add_vote(self):
votes = self.jira.votes(self.issue_2)
init_len = votes.votes
self.jira_normal.add_vote(self.issue_2)
votes = self.jira.votes(self.issue_2)
self.assertEqual(votes.votes, init_len + 1)
self.jira_normal.remove_vote(self.issue_2)

def test_add_vote_with_issue_obj(self):
issue = self.jira.issue(self.issue_2)
votes = self.jira.votes(issue)
init_len = votes.votes
self.jira_normal.add_vote(issue)
votes = self.jira.votes(issue)
self.assertEqual(votes.votes, init_len + 1)
self.jira_normal.remove_vote(self.issue_2)
new_votes = self.jira.votes(issue)
assert votes.votes + 1 == new_votes.votes

def test_remove_vote_with_issue_obj(self):
self.jira_normal.add_vote(self.issue_2)
issue = self.jira.issue(self.issue_2)
votes = self.jira.votes(issue)
init_len = votes.votes
self.jira_normal.remove_vote(issue)
votes = self.jira.votes(issue)
self.assertEqual(votes.votes, init_len - 1)
new_votes = self.jira.votes(issue)
assert votes.votes == new_votes.votes

def test_watchers(self):
watchers = self.jira.watchers(self.issue_1)
Expand Down

0 comments on commit 69c5295

Please sign in to comment.