Skip to content

Commit

Permalink
Test changes towards getting them passing on Travis too
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Jan 7, 2015
1 parent c060601 commit 996589a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 50 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ os:
- linux
- osx
python:
- "2.6"
# - "2.6"
- "2.7"
- "3.3"
- "3.4"
# - "3.3"
# - "3.4"
env:
global:
- secure: EUpWmrnhHKPkz9cOGbEEwhBtUBRqtQ775ck042B8/pI9ZZZghbKl3Jm8ahpfms3JiZcHMCG06MBREs1ISK/g2OfHKsdULCg5g3UFXteVQo769kwh/x4lniSbU2eipcN0s9Q/Ak5zStwTa5aNQ4FU/3zSgTDxi/OcDKGXDbVwHD8=
Expand Down
4 changes: 1 addition & 3 deletions jira/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@
import requests
import json
import warnings
import threading

from six import string_types
from six.moves import html_parser
from six import print_ as print


from jira.exceptions import raise_on_error, JIRAError
# JIRA specific resources
Expand Down
13 changes: 7 additions & 6 deletions jira/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@
"""

import re
import sys
import logging
import random
import pprint
import json

from six import iteritems, string_types, text_type
from six import print_ as print

from jira.exceptions import raise_on_error, get_error_list
from jira.client import threaded_requests


class Resource(object):
Expand Down Expand Up @@ -194,8 +191,12 @@ def delete(self, params=None):
def _load(self, url, headers=None, params=None):
r = self._session.get(url, headers=headers, params=params)
raise_on_error(r)

self._parse_raw(json.loads(r.text))
try:
j = json.loads(r.text)
except ValueError as e:
logging.error("%s:\n%s" % (e, r.text))
raise e
self._parse_raw(j)

def _parse_raw(self, raw):
self.raw = raw
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ upload-dir = docs/build/html
[pytest]
norecursedirs = . .svn jira _build tmp* lib/third lib *.egg bin distutils build docs demo
python_files = *.py
addopts = -p no:xdist --ignore=setup.py --tb=long -rsxX -v --junitxml=reports --maxfail=3 --pep8 tests
addopts = -p no:xdist --ignore=setup.py --tb=long -rsxX -v --junitxml=reports --maxfail=10 --pep8 tests
# -n 1
# --maxfail=2 -n4
# -n4 runs up to 4 parallel procs
Expand Down
45 changes: 8 additions & 37 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,8 @@ def get_status_code(host, path="/", auth=None):
return None


"""
if CI_JIRA_ADMIN_USER:
j = JIRA(options={'server': CI_JIRA_URL}, basic_auth=(CI_JIRA_ADMIN_USER, CI_JIRA_ADMIN_PASSWORD))
else:
j = JIRA(options={'server': CI_JIRA_URL})
j.add_user('eviladmin', 'noreply@example.com', password='eviladmin') # , fullname=None, sendEmail=False, active=True)
j.add_user_to_group('eviladmin', 'jira-administrators')
j.add_user('fred', 'noreply@example.com', password='fred')
j.delete_project("XSS")
j.delete_project("BULK")
j.create_project("XSS", "XSS")
r = j.create_project("BULK", "BULK")
print(r)
j.create_issue(project={'key': 'BULK'}, summary='issue 1 from BULK', issuetype={'name': 'Bug'})
j.create_issue(project={'key': 'BULK'}, summary='issue 2 from BULK', issuetype={'name': 'Bug'})
j.create_issue(project={'key': 'BULK'}, summary='issue 3 from BULK', issuetype={'name': 'Bug'})
"""
def rndstr():
return ''.join(random.sample(string.ascii_letters, 6))


class Singleton(type):
Expand Down Expand Up @@ -472,7 +455,7 @@ def test_3_update(self):
# We ignore errors as this code intends only to prepare for component creation
pass

name = 'component-' + ''.join(random.sample(string.ascii_letters, 15))
name = 'component-' + rndstr()

component = self.jira.create_component(name,
self.project_b, description='stand by!',
Expand Down Expand Up @@ -548,7 +531,7 @@ def setUp(self):

def test_filter(self):
jql = "project = %s and component is not empty" % self.project_b
name = 'same filter ' + ''.join(random.sample(string.ascii_letters, 15))
name = 'same filter ' + rndstr()
myfilter = self.jira.create_filter(name=name,
description="just some new test filter", jql=jql,
favourite=False)
Expand All @@ -560,7 +543,7 @@ def test_favourite_filters(self):
filters = self.jira.favourite_filters()
initial_len = len(filters)
jql = "project = %s and component is not empty" % self.project_b
name = "filter-to-fav-" + ''.join(random.sample(string.ascii_letters, 15))
name = "filter-to-fav-" + rndstr()
myfilter = self.jira.create_filter(name=name,
description="just some new test filter", jql=jql,
favourite=True)
Expand Down Expand Up @@ -1335,27 +1318,15 @@ def find_selected_avatar(avatars):

def test_project_components(self):
proj = self.jira.project(self.project_b)
component = self.jira.create_component('Project b test component',
name = "component-%s from project %s" % (proj, rndstr())
component = self.jira.create_component(name,
proj, description='test!!', assigneeType='COMPONENT_LEAD',
isAssigneeTypeValid=False)
components = self.jira.project_components(self.project_b)
self.assertGreaterEqual(len(components), 1)
sample = find_by_id(components, component.id)
self.assertEqual(sample.id, component.id)
self.assertEqual(sample.name, 'Project b test component')
component.delete()

def test_project_components_with_project_obj(self):
proj = self.jira.project(self.project_b)
component = self.jira.create_component('Project b test component',
proj, description='test!!', assigneeType='COMPONENT_LEAD',
isAssigneeTypeValid=False)
project = self.jira.project(self.project_b)
components = self.jira.project_components(project)
self.assertGreaterEqual(len(components), 1)
sample = find_by_id(components, component.id)
self.assertEqual(sample.id, component.id)
self.assertEqual(sample.name, 'Project b test component')
self.assertEqual(sample.name, name)
component.delete()

def test_project_versions(self):
Expand Down

0 comments on commit 996589a

Please sign in to comment.