Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add requirements file and initial tests.

  • Loading branch information...
commit e51e0c325f1d5e811d5cde98b39eab24e15e5ac6 1 parent ba1a0f5
@carljm carljm authored
View
1  .gitignore
@@ -0,0 +1 @@
+htmlcov/
View
17 README.rst
@@ -24,3 +24,20 @@ CSV output will go to stdout.
Use the `-v` or `--verbose` option to get debug logging to stderr.
See the included ``basecamp.sh`` for sample usage.
+
+Requires Python 2.7.
+
+Developing
+----------
+
+To install the requirements for running the tests::
+
+ pip install -r requirements.txt
+
+To run the tests and measure coverage::
+
+ ./runtests.sh
+
+To view test coverage data::
+
+ firefox htmlcov/index.html
View
12 bughub.py
@@ -52,7 +52,6 @@ def __init__(self, user, repo, **filters):
self.user = user
self.repo = repo
self.filters = filters
- self.filters.setdefault("per_page", 100)
def get_all(self):
@@ -74,12 +73,15 @@ def get_all(self):
def get_issues(self):
"""Yield github issues in GitHub API JSON format."""
+ filters = self.filters.copy()
+ filters.setdefault("per_page", 100)
+
url = "{0}?{1}".format(
urljoin(
self.API_BASE,
"/".join(["repos", self.user, self.repo, "issues"])
),
- urlencode(self.filters, doseq=True),
+ urlencode(filters, doseq=True),
)
while url:
@@ -111,8 +113,6 @@ def __init__(self, **filters):
"""
self.filters = filters
- self.filters["include_fields"] = (
- "id,assigned_to,status,summary,product,component,attachments")
def get_all(self):
@@ -133,6 +133,10 @@ def get_all(self):
def get_issues(self):
"""Yield Bugzilla issues in Bugzilla REST API JSON format."""
+ filters = self.filters.copy()
+ filters["include_fields"] = (
+ "id,assigned_to,status,summary,product,component,attachments")
+
url = "{0}?{1}".format(
self.API_BASE,
urlencode(self.filters, doseq=True)
View
7 requirements.txt
@@ -0,0 +1,7 @@
+# Development requirements only; bughub has no production dependencies
+
+cov-core==1.6
+coverage==3.5.2
+py==1.4.9
+pytest==2.2.4
+pytest-cov==1.6
View
3  runtests.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+py.test --cov-report html --cov bughub
View
19 test_bughub.py
@@ -0,0 +1,19 @@
+"""
+Tests for bughub.
+
+"""
+import bughub
+
+
+def test_parse_source_github():
+ s = bughub.parse_source("github:user:repo:foo=bar:foo=baz")
+
+ assert s.user == "user"
+ assert s.repo == "repo"
+ assert s.filters == {"foo": ["bar", "baz"]}
+
+
+def test_parse_source_bugzilla():
+ s = bughub.parse_source("bugzilla:foo=bar:foo=baz")
+
+ assert s.filters == {"foo": ["bar", "baz"]}
Please sign in to comment.
Something went wrong with that request. Please try again.