Add Bugsy Python package
authorGregory Szorc <gps@mozilla.com>
Mon, 30 Jun 2014 19:15:13 -0700
changeset 358882 a01e217d4ddaee04abe016d81c46136fec69cb62
parent 358881 82329c1b70a6a7da13bb86fb342173020b0572ac
child 358883 cf4d1078cb31ecce46ccda7acbb6266a00fb89d9
push id16998
push userrwood@mozilla.com
push dateMon, 02 May 2016 19:42:03 +0000
Add Bugsy Python package Bugsy commit abca623150fa87bcf826f6eb47deabfb2a650af0 imported without modifications.
hgext/bootstrap.py
pylib/Bugsy/.gitignore
pylib/Bugsy/.travis.yml
pylib/Bugsy/CONTRIBUTING.md
pylib/Bugsy/History.md
pylib/Bugsy/LICENSE
pylib/Bugsy/README.md
pylib/Bugsy/bugsy/__init__.py
pylib/Bugsy/bugsy/bug.py
pylib/Bugsy/bugsy/bugsy.py
pylib/Bugsy/bugsy/search.py
pylib/Bugsy/docs/Makefile
pylib/Bugsy/docs/make.bat
pylib/Bugsy/docs/source/bug.rst
pylib/Bugsy/docs/source/bugsy.rst
pylib/Bugsy/docs/source/conf.py
pylib/Bugsy/docs/source/index.rst
pylib/Bugsy/docs/source/search_bug.rst
pylib/Bugsy/example/create_new_bug.py
pylib/Bugsy/requirements.txt
pylib/Bugsy/setup.py
pylib/Bugsy/tests/test_bugs.py
pylib/Bugsy/tests/test_bugsy.py
pylib/Bugsy/tests/test_search.py
--- a/hgext/bootstrap.py
+++ b/hgext/bootstrap.py
@@ -25,16 +25,17 @@ def HGEXT_BOOTSTRAP():
         here = os.path.dirname(here)
 
     if not here or not root:
         raise Exception('Could not find repository root.')
 
     paths = set(sys.path)
 
     lib_paths = [
+        'pylib/bugsy',
         'pylib/flake8',
         'pylib/mccabe',
         'pylib/mozautomation',
         'pylib/mozhg',
         'pylib/pep8',
         'pylib/pyflakes',
         'pylib/requests',
         'pylib/reviewboardmods',
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/.gitignore
@@ -0,0 +1,54 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+env/
+bin/
+build/
+develop-eggs/
+dist/
+eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+*.egg-info/
+.installed.cfg
+*.egg
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.coverage
+.cache
+nosetests.xml
+coverage.xml
+
+# Translations
+*.mo
+
+# Mr Developer
+.mr.developer.cfg
+.project
+.pydevproject
+
+# Rope
+.ropeproject
+
+# Django stuff:
+*.log
+*.pot
+
+# Sphinx documentation
+docs/_build/
+
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/.travis.yml
@@ -0,0 +1,6 @@
+language: python
+python:
+  - 2.6
+  - 2.7
+install: pip install -r requirements.txt
+script: python setup.py develop && py.test tests
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/CONTRIBUTING.md
@@ -0,0 +1,30 @@
+# How to Contribute
+
+Firstly, thanks for wanting to contribute back to this project. Below are
+guidelines that should hopefully minimise the amount of backwards and forwards
+in the review process.
+
+## Getting Started
+
+* Fork the repository on GitHub - well... duh :P
+
+## Making Changes
+
+* Create a topic branch from where you want to base your work.
+  * This is usually the master branch.
+  * Only target release branches if you are certain your fix must be on that
+    branch.
+  * To quickly create a topic branch based on master; `git checkout -b
+    /my_contribution master`. Please avoid working directly on the
+    `master` branch.
+* Make commits of logical units.
+* Check for unnecessary whitespace with `git diff --check` before committing.
+* Make sure you have added the necessary tests for your changes.
+* Run _all_ the tests to assure nothing else was accidentally broken.
+
+## Submitting Changes
+
+* Push your changes to a topic branch in your fork of the repository.
+* Submit a pull request to the main repository
+* After feedback has been given we expect responses within two weeks. After two
+  weeks will may close the pull request if it isn't showing any activity.
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/History.md
@@ -0,0 +1,14 @@
+
+0.2.0 / 2014-06-26
+==================
+
+ * Added the ability to search Bugzilla
+    * Set include_fields to have defaults as used in Bugs object
+    * Add the ability to search whiteboard
+    * Add the ability to search summary fields
+    * Add in the ability to search for bugs assigned to people
+
+0.1.0
+==============================
+
+ * Initial implementation
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/LICENSE
@@ -0,0 +1,201 @@
+Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "{}"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright {yyyy} {name of copyright owner}
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/README.md
@@ -0,0 +1,8 @@
+Bugsy
+=====
+[![Build Status](https://travis-ci.org/AutomatedTester/Bugsy.svg?branch=master)](https://travis-ci.org/AutomatedTester/Bugsy)
+
+
+Bugsy is a library for interacting with the native REST API for Bugzilla.
+
+Documentation can be found on [Read The Docs](http://bugsy.readthedocs.org/en/latest)
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/bugsy/__init__.py
@@ -0,0 +1,3 @@
+from bug import Bug, BugException
+from bugsy import Bugsy, BugsyException, LoginException
+from search import Search
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/bugsy/bug.py
@@ -0,0 +1,226 @@
+import requests
+
+
+VALID_STATUS = ["RESOLVED", "ASSIGNED", "NEW", "UNCONFIRMED"]
+VALID_RESOLUTION = ["FIXED", "INCOMPLETE", "INVALID", "WORKSFORME", "DUPLICATE", "WONTFIX"]
+
+
+class BugException(Exception):
+    """
+        If we try do something that is not allowed to a bug then
+        this error is raised
+    """
+    def __init__(self, msg):
+        self.msg = msg
+
+    def __str__(self):
+        return "Message: %s" % self.msg
+
+
+class Bug(object):
+    """This represents a Bugzilla Bug"""
+
+    def __init__(self, bugzilla_url=None, token=None, **kwargs):
+        """
+            Defaults are set if there are no kwargs passed in. To pass in
+            a dict create the Bug object like the following
+
+            :param bugzilla_url: This is the Bugzilla REST URL endpoint. Defaults to None
+            :param token: Login token generated when instantiating a Bugsy() object with
+                          a valid username and password
+
+            >>> bug = Bug(**myDict)
+        """
+        self.bugzilla_url = bugzilla_url
+        self.token = token
+        self._bug = dict(**kwargs)
+        self._bug['op_sys'] = kwargs.get('op_sys', 'All')
+        self._bug['product'] = kwargs.get('product', 'core')
+        self._bug['component'] = kwargs.get('component', 'general')
+        self._bug['platform'] = kwargs.get('platform', 'All')
+        self._bug['version'] = kwargs.get('version', 'unspecified')
+
+    def id():
+        doc = """
+            Property for getting the ID of a bug.
+
+            >>> bug.id
+            123456
+        """
+        def fget(self):
+            return self._bug.get('id', None)
+        return locals()
+    id = property(**id())
+
+    def summary():
+        doc = """
+            Property for getting and setting the bug summary
+
+            >>> bug.summary = "I like cheese"
+            >>> bug.summary
+            "I like cheese"
+        """
+        def fget(self):
+            return self._bug.get('summary', '')
+        def fset(self, value):
+            self._bug['summary'] = value
+        def fdel(self):
+            del self._bug['summary']
+        return locals()
+    summary = property(**summary())
+
+    def status():
+        doc = """
+            Property for getting or setting the bug status
+
+            >>> bug.status = "REOPENED"
+            >>> bug.status
+            "REOPENED"
+        """
+        def fget(self):
+            return self._bug.get('status', '')
+        def fset(self, value):
+            if self._bug.get('id', None):
+                if value in VALID_STATUS:
+                    self._bug['status'] = value
+                else:
+                    raise BugException("Invalid status type was used")
+            else:
+                raise BugException("Can not set status unless there is a bug id. Please call Update() before setting")
+        def fdel(self):
+            del self._bug['status']
+        return locals()
+    status = property(**status())
+
+    def OS():
+        doc = """
+            Property for getting or setting the OS that the bug occured on
+
+            >>> bug.OS
+            "All"
+            >>> bug.OS = "Linux"
+        """
+        def fget(self):
+            return self._bug['op_sys']
+        def fset(self, value):
+            self._bug['op_sys']
+        return locals()
+    OS = property(**OS())
+
+    def resolution():
+        doc = """
+            Property for getting or setting the bug resolution
+
+            >>> bug.resolution = "FIXED"
+            >>> bug.resolution
+            "FIXED"
+        """
+        def fget(self):
+            return self._bug['resolution']
+        def fset(self, value):
+            if value in VALID_RESOLUTION:
+                self._bug['resolution'] = value
+            else:
+                raise BugException("Invalid resolution type was used")
+        def fdel(self):
+            del self._bug['resolution']
+        return locals()
+    resolution = property(**resolution())
+
+    def product():
+        doc = """
+            Property for getting the bug product
+
+            >>> bug.product
+            Core
+        """
+        def fget(self):
+            return self._bug['product']
+        def fset(self, value):
+            self._product = value
+        return locals()
+    product = property(**product())
+
+    def component():
+        doc = """
+            Property for getting the bug component
+
+            >>> bug.component
+            General
+        """
+        def fget(self):
+            return self._bug['component']
+        def fset(self, value):
+            self._bug['component'] = value
+        return locals()
+    component = property(**component())
+
+    def platform():
+        doc = """
+            Property for getting the bug platform
+
+            >>> bug.platform
+            "ARM"
+        """
+        def fget(self):
+            return self._bug['platform']
+        def fset(self, value):
+            self._bug['platform'] = value
+        return locals()
+    platform = property(**platform())
+
+    def version():
+        doc = """
+            Property for getting the bug platform
+
+            >>> bug.version
+            "TRUNK"
+        """
+        def fget(self):
+            return self._bug['version']
+        def fset(self, value):
+            self._bug['version'] = value
+        return locals()
+    version = property(**version())
+
+    def to_dict(self):
+        """
+            Return the raw dict that is used inside this object
+        """
+        return self._bug
+
+    def update(self):
+        """
+            Update this object with the latest changes from Bugzilla
+
+            >>> bug.status
+            'NEW'
+            #Changes happen on Bugzilla
+            >>> bug.update()
+            >>> bug.status
+            'FIXED'
+        """
+        if self._bug.has_key('id'):
+            url = self.bugzilla_url + "/bug/%s" % self._bug['id']
+            if self.token:
+                url = url + '?token=%s' % self.token
+            result = requests.get(url).json()
+            self._bug = dict(**result['bugs'][0])
+        else:
+            raise BugException("Unable to update bug that isn't in Bugzilla")
+
+    def add_comment(self, comment):
+        """
+            Adds a comment to a bug. Once you have added it you will need to
+            call put on the Bugsy object
+
+            >>> bug.add_comment("I like sausages")
+            >>> bugzilla.put(bug)
+        """
+        self._bug['comment'] = comment
+
+    def to_dict(self):
+        """
+            Return the raw dict that is used inside this object
+        """
+        return self._bug
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/bugsy/bugsy.py
@@ -0,0 +1,112 @@
+import json
+
+import requests
+from bug import Bug
+from search import Search
+
+
+class BugsyException(Exception):
+    """
+        If while interacting with Bugzilla and we try do something that is not
+        supported this error will be raised.
+    """
+    def __init__(self, msg):
+        self.msg = msg
+
+    def __str__(self):
+        return "Message: %s" % self.msg
+
+class LoginException(Exception):
+    """
+        If a username and password are passed in but we don't receive a token
+        then this error will be raised.
+    """
+    def __init__(self, msg):
+        self.msg = msg
+
+    def __str__(self):
+        return "Message: %s" % self.msg
+
+class Bugsy(object):
+    """
+        Bugsy allows easy getting and putting of Bugzilla bugs
+    """
+
+    def __init__(self, username=None, password=None, bugzilla_url='https://bugzilla.mozilla.org/rest'):
+        """
+            Initialises a new instance of Bugsy
+
+            :param username: Username to login with. Defaults to None
+            :param password: Password to login with. Defaults to None
+            :param bugzilla_url: URL endpoint to interact with. Defaults to https://bugzilla.mozilla.org/rest
+
+            If a username AND password are passed in Bugsy will try get a login token
+            from Bugzilla. If we can't login then a LoginException will
+            be raised.
+        """
+        self.username = username
+        self.password = password
+        self.token = None
+        self.bugzilla_url = bugzilla_url
+        if self.username and self.password:
+            result = requests.get(bugzilla_url + '/login?login=%s&password=%s' % (self.username, self.password)).json()
+            if result.has_key('token'):
+                self.token = result['token']
+            else:
+                raise LoginException(result['message'])
+
+    def get(self, bug_number):
+        """
+            Get a bug from Bugzilla. If there is a login token created during object initialisation
+            it will be part of the query string passed to Bugzilla
+
+            :param bug_number: Bug Number that will be searched. If found will return a Bug object.
+
+            >>> bugzilla = Bugsy()
+            >>> bug = bugzilla.get(123456)
+        """
+        url = self.bugzilla_url + "/bug/%s" % bug_number
+        if self.token:
+            url = url + "?token=%s" % self.token
+
+        bug = requests.get(url).json()
+        return Bug(self.bugzilla_url, self.token, **bug['bugs'][0])
+
+    def put(self, bug):
+        """
+            This method allows you to create or update a bug on Bugzilla. You will have had to pass
+            in a valid username and password to the object initialisation and recieved back a token.
+
+            :param bug: A Bug object either created by hand or by using get()
+
+            If there is no valid token then a BugsyException will be raised.
+            If the object passed in is not a Bug then a BugsyException will be raised.
+
+            >>> bugzilla = Bugsy()
+            >>> bug = bugzilla.get(123456)
+            >>> bug.summary = "I like cheese and sausages"
+            >>> bugzilla.put(bug)
+
+        """
+        if not self.token:
+            raise BugsyException("Unfortunately you can't put bugs in Bugzilla without credentials")
+
+        if not isinstance(bug, Bug):
+            raise BugsyException("Please pass in a Bug object when posting to Bugzilla")
+
+        if not bug.id:
+            result = requests.post(self.bugzilla_url + "/bug?token=%s" % self.token, bug.to_dict()).json()
+            if not result.has_key('error'):
+                bug._bug['id'] = result['id']
+            else:
+                raise BugsyException(result['message'])
+        else:
+            requests.post(self.bugzilla_url + "/bug/%s?token=%s" % (bug.id, self.token), bug.to_dict())
+
+    def search_for():
+        doc = "The search_for property."
+        def fget(self):
+            return Search(self.bugzilla_url, self.token)
+        return locals()
+    search_for = property(**search_for())
+
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/bugsy/search.py
@@ -0,0 +1,130 @@
+import requests
+from bug import Bug
+
+
+class Search(object):
+    """
+        This allows searching for bugs in Bugzilla
+    """
+    def __init__(self, bugzilla_url, token):
+        """
+            Initialises the search object
+
+            :param bugzilla_url: This is the Bugzilla REST URL endpoint. Defaults to None
+            :param token: Login token generated when instantiating a Bugsy() object with
+                          a valid username and password
+        """
+        self.bugzilla_url = bugzilla_url
+        self.token = token
+        self.includefields = ['version', 'id', 'summary', 'status', 'op_sys',
+                              'resolution', 'product', 'component', 'platform']
+        self.keywrds = []
+        self.assigned = []
+        self.summs = []
+        self.whitebord = []
+
+    def include_fields(self, *args):
+        r"""
+            Include fields is the fields that you want to be returned when searching. These
+            are in addition to the fields that are always included below.
+
+            :param args: items passed in will be turned into a list
+            :returns: :class:`Search`
+
+            >>> bugzilla.search_for.include_fields("flags")
+
+            The following fields are always included in search:
+                'version', 'id', 'summary', 'status', 'op_sys',
+                'resolution', 'product', 'component', 'platform'
+        """
+        for arg in args:
+            self.includefields.append(arg)
+        return self
+
+    def keywords(self, *args):
+        r"""
+            When search() is called it will search for the keywords passed in here
+
+            :param args: items passed in will be turned into a list
+            :returns: :class:`Search`
+
+            >>> bugzilla.search_for.keywords("checkin-needed")
+        """
+        self.keywrds = list(args)
+        return self
+
+    def assigned_to(self, *args):
+        r"""
+            When search() is called it will search for bugs assigned to these users
+
+            :param args: items passed in will be turned into a list
+            :returns: :class:`Search`
+
+            >>> bugzilla.search_for.assigned_to("dburns@mozilla.com")
+        """
+        self.assigned = list(args)
+        return self
+
+    def summary(self, *args):
+        r"""
+            When search is called it will search for bugs with the words passed into the
+            methods
+
+            :param args: items passed in will be turned into a list
+            :returns: :class:`Search`
+
+            >>> bugzilla.search_for.summary("663399")
+        """
+        self.summs = list(args)
+        return self
+
+    def whiteboard(self, *args):
+        r"""
+            When search is called it will search for bugs with the words passed into the
+            methods
+
+            :param args: items passed in will be turned into a list
+            :returns: :class:`Search`
+
+            >>> bugzilla.search_for.whiteboard("affects")
+        """
+        self.whitebord = list(args)
+        return self
+
+    def search(self):
+        r"""
+            Call the Bugzilla endpoint that will do the search. It will take the information
+            used in other methods on the Search object and build up the query string. If no
+            bugs are found then an empty list is returned.
+
+            >>> bugs = bugzilla.search_for\
+            ...                .keywords("checkin-needed")\
+            ...                .include_fields("flags")\
+            ...                .search()
+        """
+        include_fields = ""
+        for field in self.includefields:
+            include_fields = include_fields + "include_fields=%s&" % field
+
+        keywrds = ""
+        for word in self.keywrds:
+            keywrds = keywrds + "keywords=%s&" % word
+
+        assigned = ""
+        for assign in self.assigned:
+            assigned = assigned + "assigned_to=%s&" % assign
+
+        sumary = ""
+        for sums in self.summs:
+            sumary = sumary + "short_desc=%s&short_desc_type=allwordssubstr&" % sums
+
+        whiteb = ""
+        for white in self.whitebord:
+            whiteb = whiteb + "whiteboard=%s&short_desc_type=allwordssubstr&" % white
+
+
+        url = self.bugzilla_url +"/bug?" + include_fields + keywrds + assigned + sumary + whiteb
+        if self.token:
+            url = url + "token=%s" % self.token
+        results = requests.get(url).json()
+        return [Bug(self.bugzilla_url, self.token, **bug) for bug in results['bugs']]
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/docs/Makefile
@@ -0,0 +1,177 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = sphinx-build
+PAPER         =
+BUILDDIR      = build
+
+# User-friendly check for sphinx-build
+ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
+$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
+endif
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+
+help:
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html       to make standalone HTML files"
+	@echo "  dirhtml    to make HTML files named index.html in directories"
+	@echo "  singlehtml to make a single large HTML file"
+	@echo "  pickle     to make pickle files"
+	@echo "  json       to make JSON files"
+	@echo "  htmlhelp   to make HTML files and a HTML help project"
+	@echo "  qthelp     to make HTML files and a qthelp project"
+	@echo "  devhelp    to make HTML files and a Devhelp project"
+	@echo "  epub       to make an epub"
+	@echo "  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  latexpdf   to make LaTeX files and run them through pdflatex"
+	@echo "  latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
+	@echo "  text       to make text files"
+	@echo "  man        to make manual pages"
+	@echo "  texinfo    to make Texinfo files"
+	@echo "  info       to make Texinfo files and run them through makeinfo"
+	@echo "  gettext    to make PO message catalogs"
+	@echo "  changes    to make an overview of all changed/added/deprecated items"
+	@echo "  xml        to make Docutils-native XML files"
+	@echo "  pseudoxml  to make pseudoxml-XML files for display purposes"
+	@echo "  linkcheck  to check all external links for integrity"
+	@echo "  doctest    to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+	rm -rf $(BUILDDIR)/*
+
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+	$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+	@echo
+	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+	@echo
+	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
+	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Bugzilla.qhcp"
+	@echo "To view the help file:"
+	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Bugzilla.qhc"
+
+devhelp:
+	$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+	@echo
+	@echo "Build finished."
+	@echo "To view the help file:"
+	@echo "# mkdir -p $$HOME/.local/share/devhelp/Bugzilla"
+	@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Bugzilla"
+	@echo "# devhelp"
+
+epub:
+	$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+	@echo
+	@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+	@echo "Run \`make' in that directory to run these through (pdf)latex" \
+	      "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo "Running LaTeX files through pdflatex..."
+	$(MAKE) -C $(BUILDDIR)/latex all-pdf
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+latexpdfja:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo "Running LaTeX files through platex and dvipdfmx..."
+	$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+	$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+	@echo
+	@echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+	@echo
+	@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo
+	@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+	@echo "Run \`make' in that directory to run these through makeinfo" \
+	      "(use \`make info' here to do that automatically)."
+
+info:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo "Running Texinfo files through makeinfo..."
+	make -C $(BUILDDIR)/texinfo info
+	@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+	$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+	@echo
+	@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+	@echo
+	@echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in $(BUILDDIR)/doctest/output.txt."
+
+xml:
+	$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
+	@echo
+	@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
+
+pseudoxml:
+	$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
+	@echo
+	@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/docs/make.bat
@@ -0,0 +1,242 @@
+@ECHO OFF
+
+REM Command file for Sphinx documentation
+
+if "%SPHINXBUILD%" == "" (
+	set SPHINXBUILD=sphinx-build
+)
+set BUILDDIR=build
+set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source
+set I18NSPHINXOPTS=%SPHINXOPTS% source
+if NOT "%PAPER%" == "" (
+	set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+	set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
+)
+
+if "%1" == "" goto help
+
+if "%1" == "help" (
+	:help
+	echo.Please use `make ^<target^>` where ^<target^> is one of
+	echo.  html       to make standalone HTML files
+	echo.  dirhtml    to make HTML files named index.html in directories
+	echo.  singlehtml to make a single large HTML file
+	echo.  pickle     to make pickle files
+	echo.  json       to make JSON files
+	echo.  htmlhelp   to make HTML files and a HTML help project
+	echo.  qthelp     to make HTML files and a qthelp project
+	echo.  devhelp    to make HTML files and a Devhelp project
+	echo.  epub       to make an epub
+	echo.  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter
+	echo.  text       to make text files
+	echo.  man        to make manual pages
+	echo.  texinfo    to make Texinfo files
+	echo.  gettext    to make PO message catalogs
+	echo.  changes    to make an overview over all changed/added/deprecated items
+	echo.  xml        to make Docutils-native XML files
+	echo.  pseudoxml  to make pseudoxml-XML files for display purposes
+	echo.  linkcheck  to check all external links for integrity
+	echo.  doctest    to run all doctests embedded in the documentation if enabled
+	goto end
+)
+
+if "%1" == "clean" (
+	for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
+	del /q /s %BUILDDIR%\*
+	goto end
+)
+
+
+%SPHINXBUILD% 2> nul
+if errorlevel 9009 (
+	echo.
+	echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
+	echo.installed, then set the SPHINXBUILD environment variable to point
+	echo.to the full path of the 'sphinx-build' executable. Alternatively you
+	echo.may add the Sphinx directory to PATH.
+	echo.
+	echo.If you don't have Sphinx installed, grab it from
+	echo.http://sphinx-doc.org/
+	exit /b 1
+)
+
+if "%1" == "html" (
+	%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/html.
+	goto end
+)
+
+if "%1" == "dirhtml" (
+	%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
+	goto end
+)
+
+if "%1" == "singlehtml" (
+	%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
+	goto end
+)
+
+if "%1" == "pickle" (
+	%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can process the pickle files.
+	goto end
+)
+
+if "%1" == "json" (
+	%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can process the JSON files.
+	goto end
+)
+
+if "%1" == "htmlhelp" (
+	%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can run HTML Help Workshop with the ^
+.hhp project file in %BUILDDIR%/htmlhelp.
+	goto end
+)
+
+if "%1" == "qthelp" (
+	%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can run "qcollectiongenerator" with the ^
+.qhcp project file in %BUILDDIR%/qthelp, like this:
+	echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Bugzilla.qhcp
+	echo.To view the help file:
+	echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Bugzilla.ghc
+	goto end
+)
+
+if "%1" == "devhelp" (
+	%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished.
+	goto end
+)
+
+if "%1" == "epub" (
+	%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The epub file is in %BUILDDIR%/epub.
+	goto end
+)
+
+if "%1" == "latex" (
+	%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
+	goto end
+)
+
+if "%1" == "latexpdf" (
+	%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+	cd %BUILDDIR%/latex
+	make all-pdf
+	cd %BUILDDIR%/..
+	echo.
+	echo.Build finished; the PDF files are in %BUILDDIR%/latex.
+	goto end
+)
+
+if "%1" == "latexpdfja" (
+	%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+	cd %BUILDDIR%/latex
+	make all-pdf-ja
+	cd %BUILDDIR%/..
+	echo.
+	echo.Build finished; the PDF files are in %BUILDDIR%/latex.
+	goto end
+)
+
+if "%1" == "text" (
+	%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The text files are in %BUILDDIR%/text.
+	goto end
+)
+
+if "%1" == "man" (
+	%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The manual pages are in %BUILDDIR%/man.
+	goto end
+)
+
+if "%1" == "texinfo" (
+	%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
+	goto end
+)
+
+if "%1" == "gettext" (
+	%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
+	goto end
+)
+
+if "%1" == "changes" (
+	%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.The overview file is in %BUILDDIR%/changes.
+	goto end
+)
+
+if "%1" == "linkcheck" (
+	%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Link check complete; look for any errors in the above output ^
+or in %BUILDDIR%/linkcheck/output.txt.
+	goto end
+)
+
+if "%1" == "doctest" (
+	%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Testing of doctests in the sources finished, look at the ^
+results in %BUILDDIR%/doctest/output.txt.
+	goto end
+)
+
+if "%1" == "xml" (
+	%SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The XML files are in %BUILDDIR%/xml.
+	goto end
+)
+
+if "%1" == "pseudoxml" (
+	%SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.
+	goto end
+)
+
+:end
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/docs/source/bug.rst
@@ -0,0 +1,10 @@
+.. toctree::
+   :maxdepth: 2
+
+:mod:`Bug`
+---------------------
+.. automodule:: bugsy
+.. autoclass:: Bug
+   :members:
+.. autoclass:: BugException
+   :members:
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/docs/source/bugsy.rst
@@ -0,0 +1,12 @@
+.. toctree::
+   :maxdepth: 2
+
+:mod:`Bugsy`
+---------------------
+.. automodule:: bugsy
+.. autoclass:: Bugsy
+   :members:
+.. autoclass:: BugsyException
+   :members:
+.. autoclass:: LoginException
+   :members:
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/docs/source/conf.py
@@ -0,0 +1,271 @@
+# -*- coding: utf-8 -*-
+#
+# Bugzilla documentation build configuration file, created by
+# sphinx-quickstart on Sat May 31 20:43:30 2014.
+#
+# This file is execfile()d with the current directory set to its
+# containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys
+import os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+sys.path.insert(0, os.path.abspath('../..'))
+
+# -- General configuration ------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
+extensions = [
+    'sphinx.ext.autodoc',
+    'sphinx.ext.doctest',
+    'sphinx.ext.intersphinx',
+    'sphinx.ext.todo',
+    'sphinx.ext.coverage',
+    'sphinx.ext.pngmath',
+    'sphinx.ext.mathjax',
+    'sphinx.ext.viewcode',
+]
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'Bugsy'
+copyright = u'2014, David Burns'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '0.2'
+# The full version, including alpha/beta/rc tags.
+release = '0.2'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = []
+
+# The reST default role (used for this markup: `text`) to use for all
+# documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+# If true, keep warnings as "system message" paragraphs in the built documents.
+#keep_warnings = False
+
+
+# -- Options for HTML output ----------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  See the documentation for
+# a list of builtin themes.
+html_theme = 'default'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further.  For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents.  If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar.  Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# Add any extra paths that contain custom files (such as robots.txt or
+# .htaccess) here, relative to this directory. These files are copied
+# directly to the root of the documentation.
+#html_extra_path = []
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it.  The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'Bugzilladoc'
+
+
+# -- Options for LaTeX output ---------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title,
+#  author, documentclass [howto, manual, or own class]).
+latex_documents = [
+  ('index', 'Bugzilla.tex', u'Bugzilla Documentation',
+   u'David Burns', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output ---------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+    ('index', 'bugzilla', u'Bugzilla Documentation',
+     [u'David Burns'], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output -------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+#  dir menu entry, description, category)
+texinfo_documents = [
+  ('index', 'Bugzilla', u'Bugzilla Documentation',
+   u'David Burns', 'Bugzilla', 'One line description of project.',
+   'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
+
+# If true, do not generate a @detailmenu in the "Top" node's menu.
+#texinfo_no_detailmenu = False
+
+
+# Example configuration for intersphinx: refer to the Python standard library.
+intersphinx_mapping = {'http://docs.python.org/': None}
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/docs/source/index.rst
@@ -0,0 +1,108 @@
+.. Bugzilla documentation master file, created by
+   sphinx-quickstart on Sat May 31 20:43:30 2014.
+   You can adapt this file completely to your liking, but it should at least
+   contain the root `toctree` directive.
+
+Welcome to Bugsy!
+=================
+
+Bugsy is a tool that allows you to programmatically work with Bugzilla using its native REST API.
+
+To use you will do
+
+.. code-block:: python
+
+    import bugsy
+    bugzilla = bugsy.Bugsy()
+    bug = bugzilla.get(123456)
+    bug123456.status = 'RESOLVED'
+    bug123456.resolution = 'FIXED'
+    bugzilla.put(bug123456)
+
+Installing Bugsy
+----------------
+
+To install Bugsy, simply use pip or easy install
+
+Pip
+
+.. code-block:: bash
+
+    pip install bugsy
+
+
+easy_install
+
+.. code-block:: bash
+
+    easy_install bugsy
+
+Using Bugsy
+-----------
+
+Getting a bug from Bugzilla
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Getting a bug is quite simple. Create a Bugsy object and then get the bug
+number that you want.
+
+.. code-block:: python
+
+    import bugsy
+    bugzilla = bugsy.Bugsy()
+    bug = bugzilla.get(123456)
+
+Creating a new bug
+~~~~~~~~~~~~~~~~~~
+
+To create a new bug, create a Bug object, populate it with the items that you need and then
+use the Bugsy object to put the bug into Bugzilla
+
+.. code-block:: python
+
+    import bugsy
+    bug = bugsy.Bug()
+    bug.summary = "I really realy love cheese"
+    bug.add_comment("and I really want sausages with it!")
+
+    bugzilla = bugsy.Bugsy("username", "password")
+    bugzilla.put(bug)
+    bug.id #returns the bug id from Bugzilla
+
+
+Searching Bugzilla
+~~~~~~~~~~~~~~~~~~
+
+To search for bugs you will need to create a :class:`Bugsy` object and then you can call
+`search_for` and chain the search. The :class:`Search` API is a `Fluent API <https://en.wikipedia.org/wiki/Fluent_interface>`_
+o you just chain the items that you need and then call `search` when the search is complete.
+
+.. code-block:: python
+
+    import bugsy
+    bugzilla = bugsy.Bugsy()
+    bugs = bugzilla.search_for\
+                    .keywords("checkin-needed")\
+                    .include_fields("flags")\
+                    .search()
+
+More details can be found in from the :class:`Search` class
+
+
+To see further details look at:
+
+.. toctree::
+   :maxdepth: 2
+
+   bugsy.rst
+   bug.rst
+   search_bug.rst
+
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+
+.. _Bugsy:
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/docs/source/search_bug.rst
@@ -0,0 +1,9 @@
+.. toctree::
+   :maxdepth: 2
+
+:mod:`Search`
+---------------------
+.. versionchanged:: 0.2
+.. automodule:: bugsy
+.. autoclass:: Search
+   :members:
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/example/create_new_bug.py
@@ -0,0 +1,6 @@
+import bugsy
+bz = bugsy.Bugsy("someUser", "theirPassword", "https://bugzilla-dev.allizom.org/rest")
+bug = bugsy.Bug()
+bug.summary = "I love cheese"
+bug.add_comment('I do love sausages')
+bz.put(bug)
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/requirements.txt
@@ -0,0 +1,3 @@
+pytest
+requests
+responses
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/setup.py
@@ -0,0 +1,19 @@
+from setuptools import setup, find_packages
+
+setup(name='bugsy',
+      version='0.2.0',
+      description='A library for interacting Bugzilla Native REST API',
+      author='David Burns',
+      author_email='david.burns at theautomatedtester dot co dot uk',
+      url='http://oss.theautomatedtester.co.uk/bugzilla',
+      classifiers=['Development Status :: 3 - Alpha',
+                  'Intended Audience :: Developers',
+                  'License :: OSI Approved :: Apache Software License',
+                  'Operating System :: POSIX',
+                  'Operating System :: Microsoft :: Windows',
+                  'Operating System :: MacOS :: MacOS X',
+                  'Topic :: Software Development :: Libraries',
+                  'Programming Language :: Python'],
+        packages = find_packages(),
+        install_requires=['requests>=1.1.0'],
+        )
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/tests/test_bugs.py
@@ -0,0 +1,155 @@
+import responses
+import json
+
+from bugsy import Bugsy, Bug
+from bugsy import BugException
+
+example_return = {u'faults': [], u'bugs': [{u'cf_tracking_firefox29': u'---', u'classification': u'Other', u'creator': u'jgriffin@mozilla.com', u'cf_status_firefox30':
+u'---', u'depends_on': [], u'cf_status_firefox32': u'---', u'creation_time': u'2014-05-28T23:57:58Z', u'product': u'Release Engineering', u'cf_user_story': u'', u'dupe_of': None, u'cf_tracking_firefox_relnote': u'---', u'keywords': [], u'cf_tracking_b2g18': u'---', u'summary': u'Schedule Mn tests on o\
+pt Linux builds on cedar', u'id': 1017315, u'assigned_to_detail': {u'id': 347295, u'email': u'jgriffin@mozilla.com', u'name': u'jgriffin@mozilla.com',
+u'real_name': u'Jonathan Griffin (:jgriffin)'}, u'severity': u'normal', u'is_confirmed': True, u'is_creator_accessible': True, u'cf_status_b2g_1_1_hd':
+ u'---', u'qa_contact_detail': {u'id': 20203, u'email': u'catlee@mozilla.com', u'name': u'catlee@mozilla.com', u'real_name': u'Chris AtLee [:catlee]'},
+ u'priority': u'--', u'platform': u'All', u'cf_crash_signature': u'', u'version': u'unspecified', u'cf_qa_whiteboard': u'', u'cf_status_b2g_1_3t': u'--\
+-', u'cf_status_firefox31': u'---', u'is_open': False, u'cf_blocking_fx': u'---', u'status': u'RESOLVED', u'cf_tracking_relnote_b2g': u'---', u'cf_stat\
+us_firefox29': u'---', u'blocks': [], u'qa_contact': u'catlee@mozilla.com', u'see_also': [], u'component': u'General Automation', u'cf_tracking_firefox\
+32': u'---', u'cf_tracking_firefox31': u'---', u'cf_tracking_firefox30': u'---', u'op_sys': u'All', u'groups': [], u'cf_blocking_b2g': u'---', u'target\
+_milestone': u'---', u'is_cc_accessible': True, u'cf_tracking_firefox_esr24': u'---', u'cf_status_b2g_1_2': u'---', u'cf_status_b2g_1_3': u'---', u'cf_\
+status_b2g18': u'---', u'cf_status_b2g_1_4': u'---', u'url': u'', u'creator_detail': {u'id': 347295, u'email': u'jgriffin@mozilla.com', u'name': u'jgri\
+ffin@mozilla.com', u'real_name': u'Jonathan Griffin (:jgriffin)'}, u'whiteboard': u'', u'cf_status_b2g_2_0': u'---', u'cc_detail': [{u'id': 30066, u'em\
+ail': u'coop@mozilla.com', u'name': u'coop@mozilla.com', u'real_name': u'Chris Cooper [:coop]'}, {u'id': 397261, u'email': u'dburns@mozilla.com', u'nam\
+e': u'dburns@mozilla.com', u'real_name': u'David Burns :automatedtester'}, {u'id': 438921, u'email': u'jlund@mozilla.com', u'name': u'jlund@mozilla.com ', u'real_name': u'Jordan Lund (:jlund)'}, {u'id': 418814, u'email': u'mdas@mozilla.com', u'name': u'mdas@mozilla.com', u'real_name': u'Malini Das [:md\
+as]'}], u'alias': None, u'cf_tracking_b2g_v1_2': u'---', u'cf_tracking_b2g_v1_3': u'---', u'flags': [], u'assigned_to': u'jgriffin@mozilla.com', u'cf_s\
+tatus_firefox_esr24': u'---', u'resolution': u'FIXED', u'last_change_time': u'2014-05-30T21:20:17Z', u'cc': [u'coop@mozilla.com', u'dburns@mozilla.com'
+, u'jlund@mozilla.com', u'mdas@mozilla.com'], u'cf_blocking_fennec': u'---'}]}
+
+def test_can_create_bug_and_set_summary_afterwards():
+    bug = Bug()
+    assert bug.id == None, "Id has been set"
+    assert bug.summary == '', "Summary is not set to nothing on plain initialisation"
+    bug.summary = "Foo"
+    assert bug.summary == 'Foo', "Summary is not being set"
+    assert bug.status == '', 'Status has been set'
+
+def test_we_cant_set_status_unless_there_is_a_bug_id():
+    bug = Bug()
+    try:
+        bug.status = 'RESOLVED'
+    except BugException as e:
+        assert str(e) == "Message: Can not set status unless there is a bug id. Please call Update() before setting"
+
+def test_we_can_get_OS_set_from_default():
+    bug = Bug()
+    assert bug.OS == "All"
+
+def test_we_can_get_OS_we_set():
+    bug = Bug(op_sys="Linux")
+    assert bug.OS == "Linux"
+
+def test_we_can_get_Product_set_from_default():
+    bug = Bug()
+    assert bug.product == "core"
+
+def test_we_can_get_Product_we_set():
+    bug = Bug(product="firefox")
+    assert bug.product == "firefox"
+
+def test_we_throw_an_error_for_invalid_status_types():
+    bug = Bug(**example_return['bugs'][0])
+    try:
+        bug.status = "foo"
+        assert 1 == 0, "Should have thrown an error about invalid type"
+    except BugException as e:
+        assert str(e) == "Message: Invalid status type was used"
+
+def test_we_can_get_the_resolution():
+    bug = Bug(**example_return['bugs'][0])
+    assert "FIXED" == bug.resolution
+
+def test_we_can_set_the_resolution():
+    bug = Bug(**example_return['bugs'][0])
+    bug.resolution = 'INVALID'
+    assert bug.resolution == 'INVALID'
+
+def test_we_cant_set_the_resolution_when_not_valid():
+    bug = Bug(**example_return['bugs'][0])
+    try:
+        bug.resolution = 'FOO'
+        assert 1==0, "Should thrown an error"
+    except BugException as e:
+        assert str(e) == "Message: Invalid resolution type was used"
+
+def test_we_can_pass_in_dict_and_get_a_bug():
+    bug = Bug(**example_return['bugs'][0])
+    assert bug.id == 1017315
+    assert bug.status == 'RESOLVED'
+    assert bug.summary == 'Schedule Mn tests on opt Linux builds on cedar'
+
+def test_we_can_get_a_dict_version_of_the_bug():
+    bug = Bug(**example_return['bugs'][0])
+    result = bug.to_dict()
+    assert example_return['bugs'][0]['id'] == result['id']
+
+@responses.activate
+def test_we_can_update_a_bug_from_bugzilla():
+    responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/bug/1017315',
+                      body=json.dumps(example_return), status=200,
+                      content_type='application/json', match_querystring=True)
+    bugzilla = Bugsy()
+    bug = bugzilla.get(1017315)
+    import copy
+    bug_dict = copy.deepcopy(example_return)
+    bug_dict['bugs'][0]['status'] = "REOPENED"
+    responses.reset()
+    responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/bug/1017315',
+                      body=json.dumps(bug_dict), status=200,
+                      content_type='application/json')
+    bug.update()
+    assert bug.status == 'REOPENED'
+
+def test_we_cant_update_unless_we_have_a_bug_id():
+    bug = Bug()
+    try:
+        bug.update()
+    except BugException as e:
+        assert str(e) == "Message: Unable to update bug that isn't in Bugzilla"
+
+@responses.activate
+def test_we_can_update_a_bug_with_login_token():
+  responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/login?login=foo&password=bar',
+                        body='{"token": "foobar"}', status=200,
+                        content_type='application/json', match_querystring=True)
+
+  responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/bug/1017315?token=foobar',
+                    body=json.dumps(example_return), status=200,
+                    content_type='application/json', match_querystring=True)
+  bugzilla = Bugsy("foo", "bar")
+  bug = bugzilla.get(1017315)
+  import copy
+  bug_dict = copy.deepcopy(example_return)
+  bug_dict['bugs'][0]['status'] = "REOPENED"
+  responses.reset()
+  responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/bug/1017315?token=foobar',
+                    body=json.dumps(bug_dict), status=200,
+                    content_type='application/json', match_querystring=True)
+  bug.update()
+  assert bug.id == 1017315
+  assert bug.status == 'REOPENED'
+  assert bug.summary == 'Schedule Mn tests on opt Linux builds on cedar'
+
+@responses.activate
+def test_that_we_can_add_a_comment_to_a_bug():
+    responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/login?login=foo&password=bar',
+                          body='{"token": "foobar"}', status=200,
+                          content_type='application/json', match_querystring=True)
+
+    responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/bug/1017315?token=foobar',
+                      body=json.dumps(example_return), status=200,
+                      content_type='application/json', match_querystring=True)
+    bugzilla = Bugsy("foo", "bar")
+    bug = bugzilla.get(1017315)
+    bug.add_comment("I like sausages")
+
+    responses.add(responses.POST, 'https://bugzilla.mozilla.org/rest/bug/1017315?token=foobar',
+                      body=json.dumps(example_return), status=200,
+                      content_type='application/json', match_querystring=True)
+    bugzilla.put(bug)
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/tests/test_bugsy.py
@@ -0,0 +1,150 @@
+import bugsy
+from bugsy import Bugsy, BugsyException, LoginException
+from bugsy import Bug
+
+import responses
+import json
+
+example_return = {u'faults': [], u'bugs': [{u'cf_tracking_firefox29': u'---', u'classification': u'Other', u'creator': u'jgriffin@mozilla.com', u'cf_status_firefox30':
+u'---', u'depends_on': [], u'cf_status_firefox32': u'---', u'creation_time': u'2014-05-28T23:57:58Z', u'product': u'Release Engineering', u'cf_user_story': u'', u'dupe_of': None, u'cf_tracking_firefox_relnote': u'---', u'keywords': [], u'cf_tracking_b2g18': u'---', u'summary': u'Schedule Mn tests on o\
+pt Linux builds on cedar', u'id': 1017315, u'assigned_to_detail': {u'id': 347295, u'email': u'jgriffin@mozilla.com', u'name': u'jgriffin@mozilla.com',
+u'real_name': u'Jonathan Griffin (:jgriffin)'}, u'severity': u'normal', u'is_confirmed': True, u'is_creator_accessible': True, u'cf_status_b2g_1_1_hd':
+ u'---', u'qa_contact_detail': {u'id': 20203, u'email': u'catlee@mozilla.com', u'name': u'catlee@mozilla.com', u'real_name': u'Chris AtLee [:catlee]'},
+ u'priority': u'--', u'platform': u'All', u'cf_crash_signature': u'', u'version': u'unspecified', u'cf_qa_whiteboard': u'', u'cf_status_b2g_1_3t': u'--\
+-', u'cf_status_firefox31': u'---', u'is_open': False, u'cf_blocking_fx': u'---', u'status': u'RESOLVED', u'cf_tracking_relnote_b2g': u'---', u'cf_stat\
+us_firefox29': u'---', u'blocks': [], u'qa_contact': u'catlee@mozilla.com', u'see_also': [], u'component': u'General Automation', u'cf_tracking_firefox\
+32': u'---', u'cf_tracking_firefox31': u'---', u'cf_tracking_firefox30': u'---', u'op_sys': u'All', u'groups': [], u'cf_blocking_b2g': u'---', u'target\
+_milestone': u'---', u'is_cc_accessible': True, u'cf_tracking_firefox_esr24': u'---', u'cf_status_b2g_1_2': u'---', u'cf_status_b2g_1_3': u'---', u'cf_\
+status_b2g18': u'---', u'cf_status_b2g_1_4': u'---', u'url': u'', u'creator_detail': {u'id': 347295, u'email': u'jgriffin@mozilla.com', u'name': u'jgri\
+ffin@mozilla.com', u'real_name': u'Jonathan Griffin (:jgriffin)'}, u'whiteboard': u'', u'cf_status_b2g_2_0': u'---', u'cc_detail': [{u'id': 30066, u'em\
+ail': u'coop@mozilla.com', u'name': u'coop@mozilla.com', u'real_name': u'Chris Cooper [:coop]'}, {u'id': 397261, u'email': u'dburns@mozilla.com', u'nam\
+e': u'dburns@mozilla.com', u'real_name': u'David Burns :automatedtester'}, {u'id': 438921, u'email': u'jlund@mozilla.com', u'name': u'jlund@mozilla.com ', u'real_name': u'Jordan Lund (:jlund)'}, {u'id': 418814, u'email': u'mdas@mozilla.com', u'name': u'mdas@mozilla.com', u'real_name': u'Malini Das [:md\
+as]'}], u'alias': None, u'cf_tracking_b2g_v1_2': u'---', u'cf_tracking_b2g_v1_3': u'---', u'flags': [], u'assigned_to': u'jgriffin@mozilla.com', u'cf_s\
+tatus_firefox_esr24': u'---', u'resolution': u'FIXED', u'last_change_time': u'2014-05-30T21:20:17Z', u'cc': [u'coop@mozilla.com', u'dburns@mozilla.com'
+, u'jlund@mozilla.com', u'mdas@mozilla.com'], u'cf_blocking_fennec': u'---'}]}
+
+def test_we_cant_post_without_a_username_or_password():
+    bugzilla = Bugsy()
+    try:
+        bugzilla.put("foo")
+        assert 1 == 0, "Should have thrown when calling put"
+    except BugsyException as e:
+        assert str(e) == "Message: Unfortunately you can't put bugs in Bugzilla without credentials"
+
+@responses.activate
+def test_we_get_a_login_exception_when_details_are_wrong():
+    responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/login?login=foo&password=bar',
+                      body='{"message": "The username or password you entered is not valid."}', status=200,
+                      content_type='application/json', match_querystring=True)
+    try:
+        Bugsy("foo", "bar")
+        assert 1 == 0, "Should have thrown an error"
+    except LoginException as e:
+        assert str(e) == "Message: The username or password you entered is not valid."
+
+@responses.activate
+def test_we_cant_post_without_passing_a_bug_object():
+    responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/login?login=foo&password=bar',
+                      body='{"token": "foobar"}', status=200,
+                      content_type='application/json', match_querystring=True)
+    bugzilla = Bugsy("foo", "bar")
+    try:
+        bugzilla.put("foo")
+        assert 1 == 0, "Should have thrown an error about type when calling put"
+    except BugsyException as e:
+        assert str(e) == "Message: Please pass in a Bug object when posting to Bugzilla"
+
+@responses.activate
+def test_we_can_get_a_bug():
+    responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/bug/1017315',
+                      body=json.dumps(example_return), status=200,
+                      content_type='application/json', match_querystring=True)
+    bugzilla = Bugsy()
+    bug = bugzilla.get(1017315)
+    assert bug.id == 1017315
+    assert bug.status == 'RESOLVED'
+    assert bug.summary == 'Schedule Mn tests on opt Linux builds on cedar'
+
+@responses.activate
+def test_we_can_get_a_bug_with_login_token():
+  responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/login?login=foo&password=bar',
+                        body='{"token": "foobar"}', status=200,
+                        content_type='application/json', match_querystring=True)
+
+  responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/bug/1017315?token=foobar',
+                    body=json.dumps(example_return), status=200,
+                    content_type='application/json', match_querystring=True)
+  bugzilla = Bugsy("foo", "bar")
+  bug = bugzilla.get(1017315)
+  assert bug.id == 1017315
+  assert bug.status == 'RESOLVED'
+  assert bug.summary == 'Schedule Mn tests on opt Linux builds on cedar'
+
+@responses.activate
+def test_we_can_create_a_new_remote_bug():
+    bug = Bug()
+    bug.summary = "I like foo"
+    responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/login?login=foo&password=bar',
+                      body='{"token": "foobar"}', status=200,
+                      content_type='application/json', match_querystring=True)
+    bug_dict = bug.to_dict().copy()
+    bug_dict['id'] = 123123
+    responses.add(responses.POST, 'https://bugzilla.mozilla.org/rest/bug',
+                      body=json.dumps(bug_dict), status=200,
+                      content_type='application/json')
+    bugzilla = Bugsy("foo", "bar")
+    bugzilla.put(bug)
+    assert bug.id != None
+
+@responses.activate
+def test_we_can_put_a_current_bug():
+    responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/login?login=foo&password=bar',
+                      body='{"token": "foobar"}', status=200,
+                      content_type='application/json', match_querystring=True)
+    bug_dict = example_return.copy()
+    bug_dict['summary'] = 'I love foo but hate bar'
+    responses.add(responses.POST, 'https://bugzilla.mozilla.org/rest/bug/1017315',
+                      body=json.dumps(bug_dict), status=200,
+                      content_type='application/json')
+    bugzilla = Bugsy("foo", "bar")
+    bug = Bug(**example_return['bugs'][0])
+    bug.summary = 'I love foo but hate bar'
+
+
+    bugzilla.put(bug)
+    assert bug.summary == 'I love foo but hate bar'
+
+@responses.activate
+def test_we_handle_errors_from_bugzilla_when_posting():
+  responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/login?login=foo&password=bar',
+                    body='{"token": "foobar"}', status=200,
+                    content_type='application/json', match_querystring=True)
+  responses.add(responses.POST, 'https://bugzilla.mozilla.org/rest/bug',
+                    body='{"error":true,"code":50,"message":"You must select/enter a component."}', status=200,
+                    content_type='application/json')
+
+  bugzilla = Bugsy("foo", "bar")
+  bug = Bug()
+  try:
+      bugzilla.put(bug)
+      assert 1 == 0, "Put should have raised an error"
+  except BugsyException as e:
+      assert str(e) == "Message: You must select/enter a component."
+
+@responses.activate
+def test_we_handle_errors_from_bugzilla_when_updating_a_bug():
+  responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/login?login=foo&password=bar',
+                    body='{"token": "foobar"}', status=200,
+                    content_type='application/json', match_querystring=True)
+  responses.add(responses.POST, 'https://bugzilla.mozilla.org/rest/bug/1017315',
+                    body='{"error":true,"code":50,"message":"You must select/enter a component."}', status=200,
+                    content_type='application/json')
+  bugzilla = Bugsy("foo", "bar")
+
+  bug_dict = example_return.copy()
+  bug_dict['summary'] = 'I love foo but hate bar'
+  bug = Bug(**bug_dict['bugs'][0])
+  try:
+      bugzilla.put(bug)
+  except BugsyException as e:
+      assert str(e) == "Message: You must select/enter a component."
new file mode 100644
--- /dev/null
+++ b/pylib/Bugsy/tests/test_search.py
@@ -0,0 +1,265 @@
+import bugsy
+from bugsy import Bugsy, BugsyException, LoginException
+from bugsy import Bug
+
+import responses
+import json
+
+@responses.activate
+def test_we_only_ask_for_the_include_fields():
+  include_return = {
+         "bugs" : [
+            {
+               "component" : "Marionette",
+               "flags" : [],
+               "id" : 861874,
+               "op_sys" : "Gonk (Firefox OS)",
+               "platform" : "Other",
+               "product" : "Testing",
+               "resolution" : "",
+               "status" : "REOPENED",
+               "summary" : "Tracking bug for uplifting is_displayed issue fix for WebDriver",
+               "version" : "unspecified"
+            },
+            {
+               "component" : "Marionette",
+               "flags" : [
+                  {
+                     "creation_date" : "2013-11-26T14:16:09Z",
+                     "id" : 758758,
+                     "modification_date" : "2013-11-26T14:16:09Z",
+                     "name" : "needinfo",
+                     "requestee" : "dkuo@mozilla.com",
+                     "setter" : "bob.silverberg@gmail.com",
+                     "status" : "?",
+                     "type_id" : 800
+                  }
+               ],
+               "id" : 862156,
+               "op_sys" : "Gonk (Firefox OS)",
+               "platform" : "ARM",
+               "product" : "Testing",
+               "resolution" : "",
+               "status" : "NEW",
+               "summary" : "Marionette thinks that the play button in the music app is not displayed",
+               "version" : "unspecified"
+            }
+         ]
+      }
+
+
+  responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/bug?assigned_to=dburns@mozilla.com&whiteboard=affects&short_desc_type=allwordssubstr&include_fields=version&include_fields=id&include_fields=summary&include_fields=status&include_fields=op_sys&include_fields=resolution&include_fields=product&include_fields=component&include_fields=platform&include_fields=flags',
+                    body=json.dumps(include_return), status=200,
+                    content_type='application/json', match_querystring=True)
+
+  bugzilla = Bugsy()
+  bugs = bugzilla.search_for\
+          .include_fields('flags')\
+          .assigned_to("dburns@mozilla.com")\
+          .whiteboard("affects")\
+          .search()
+
+  assert len(responses.calls) == 1
+  assert len(bugs) == 2
+  assert bugs[0].to_dict()['flags'] == include_return['bugs'][0]['flags']
+
+@responses.activate
+def test_we_only_ask_for_the_include_fields_while_logged_in():
+  include_return = {
+         "bugs" : [
+            {
+               "component" : "Marionette",
+               "flags" : [],
+               "id" : 861874,
+               "op_sys" : "Gonk (Firefox OS)",
+               "platform" : "Other",
+               "product" : "Testing",
+               "resolution" : "",
+               "status" : "REOPENED",
+               "summary" : "Tracking bug for uplifting is_displayed issue fix for WebDriver",
+               "version" : "unspecified"
+            },
+            {
+               "component" : "Marionette",
+               "flags" : [
+                  {
+                     "creation_date" : "2013-11-26T14:16:09Z",
+                     "id" : 758758,
+                     "modification_date" : "2013-11-26T14:16:09Z",
+                     "name" : "needinfo",
+                     "requestee" : "dkuo@mozilla.com",
+                     "setter" : "bob.silverberg@gmail.com",
+                     "status" : "?",
+                     "type_id" : 800
+                  }
+               ],
+               "id" : 862156,
+               "op_sys" : "Gonk (Firefox OS)",
+               "platform" : "ARM",
+               "product" : "Testing",
+               "resolution" : "",
+               "status" : "NEW",
+               "summary" : "Marionette thinks that the play button in the music app is not displayed",
+               "version" : "unspecified"
+            }
+         ]
+      }
+  responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/login?login=foo&password=bar',
+                    body='{"token": "foobar"}', status=200,
+                    content_type='application/json', match_querystring=True)
+
+  responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/bug?include_fields=version&include_fields=id&include_fields=summary&include_fields=status&include_fields=op_sys&include_fields=resolution&include_fields=product&include_fields=component&include_fields=platform&include_fields=flags&token=foobar',
+                    body=json.dumps(include_return), status=200,
+                    content_type='application/json', match_querystring=True)
+
+  bugzilla = Bugsy('foo', 'bar')
+  bugs = bugzilla.search_for\
+          .include_fields('flags')\
+          .search()
+
+  assert len(responses.calls) == 2
+  assert len(bugs) == 2
+  assert bugs[0].product == include_return['bugs'][0]['product']
+
+@responses.activate
+def test_we_can_return_keyword_search():
+    keyword_return = {
+      "bugs" : [
+      {
+         "component" : "Networking: HTTP",
+         "product" : "Core",
+         "summary" : "IsPending broken for requests without Content-Type"
+      },
+      {
+         "component" : "Developer Tools: Graphic Commandline and Toolbar",
+         "product" : "Firefox",
+         "summary" : "GCLI Command to open Profile Directory"
+      },
+      {
+         "component" : "Video/Audio Controls",
+         "product" : "Toolkit",
+         "summary" : "Fullscreen video should disable screensaver during playback on Linux"
+      },
+      {
+         "component" : "Reader Mode",
+         "product" : "Firefox for Android",
+         "summary" : "Article showing twice in reader mode"
+      },
+      {
+         "component" : "Message Reader UI",
+         "product" : "Thunderbird",
+         "summary" : "Make \"visited link\" coloring work in thunderbird"
+      }]
+    }
+
+    responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/bug?include_fields=version&include_fields=id&include_fields=summary&include_fields=status&include_fields=op_sys&include_fields=resolution&include_fields=product&include_fields=component&include_fields=platform&keywords=checkin-needed&',
+                    body=json.dumps(keyword_return), status=200,
+                    content_type='application/json', match_querystring=True)
+
+    bugzilla = Bugsy()
+    bugs = bugzilla.search_for\
+            .keywords('checkin-needed')\
+            .search()
+
+    assert len(responses.calls) == 1
+    assert len(bugs) == 5
+    assert bugs[0].product == keyword_return['bugs'][0]['product']
+    assert bugs[0].component == keyword_return['bugs'][0]['component']
+
+@responses.activate
+def test_that_we_can_search_for_a_specific_user():
+    user_return = {
+        "bugs" : [
+            {
+              "product" : "addons.mozilla.org",
+               "summary" : "Add Selenium tests to the repository"
+            },
+            {
+               "product" : "addons.mozilla.org",
+               "summary" : "Add Ids to links to help with testability"
+            },
+            {
+               "product" : "addons.mozilla.org",
+               "summary" : "Add a name for AMO Themes sort links for testability"
+            },
+            {
+               "product" : "addons.mozilla.org",
+               "summary" : "Missing ID for div with class \"feature ryff\" (Mobile Add-on: Foursquare)"
+            }
+           ]
+        }
+    responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/bug?include_fields=version&include_fields=id&include_fields=summary&include_fields=status&include_fields=op_sys&include_fields=resolution&include_fields=product&include_fields=component&include_fields=platform&assigned_to=dburns@mozilla.com&',
+                    body=json.dumps(user_return), status=200,
+                    content_type='application/json', match_querystring=True)
+
+    bugzilla = Bugsy()
+    bugs = bugzilla.search_for\
+            .assigned_to('dburns@mozilla.com')\
+            .search()
+
+    assert len(responses.calls) == 1
+    assert len(bugs) == 4
+    assert bugs[0].product == user_return['bugs'][0]['product']
+    assert bugs[0].summary == user_return['bugs'][0]['summary']
+
+@responses.activate
+def test_we_can_search_summary_fields():
+    summary_return = {
+     "bugs" : [
+        {
+           "component" : "CSS Parsing and Computation",
+           "product" : "Core",
+           "summary" : "Map \"rebeccapurple\" to #663399 in named color list."
+        }
+      ]
+    }
+
+
+    responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/bug?assigned_to=dburns@mozilla.com&short_desc=rebecca&short_desc_type=allwordssubstr&include_fields=version&include_fields=id&include_fields=summary&include_fields=status&include_fields=op_sys&include_fields=resolution&include_fields=product&include_fields=component&include_fields=platform&',
+                    body=json.dumps(summary_return), status=200,
+                    content_type='application/json', match_querystring=True)
+
+    bugzilla = Bugsy()
+    bugs = bugzilla.search_for\
+            .assigned_to('dburns@mozilla.com')\
+            .summary("rebecca")\
+            .search()
+
+    assert len(responses.calls) == 1
+    assert len(bugs) == 1
+    assert bugs[0].product == summary_return['bugs'][0]['product']
+    assert bugs[0].summary == summary_return['bugs'][0]['summary']
+
+
+@responses.activate
+def test_we_can_search_whiteboard_fields():
+    whiteboard_return = {
+       "bugs" : [
+          {
+             "component" : "Marionette",
+             "product" : "Testing",
+             "summary" : "Tracking bug for uplifting is_displayed issue fix for WebDriver"
+          },
+          {
+             "component" : "Marionette",
+             "product" : "Testing",
+             "summary" : "Marionette thinks that the play button in the music app is not displayed"
+          }
+       ]
+    }
+
+
+    responses.add(responses.GET, 'https://bugzilla.mozilla.org/rest/bug?assigned_to=dburns@mozilla.com&whiteboard=affects&short_desc_type=allwordssubstr&include_fields=version&include_fields=id&include_fields=summary&include_fields=status&include_fields=op_sys&include_fields=resolution&include_fields=product&include_fields=component&include_fields=platform&',
+                    body=json.dumps(whiteboard_return), status=200,
+                    content_type='application/json', match_querystring=True)
+
+    bugzilla = Bugsy()
+    bugs = bugzilla.search_for\
+            .assigned_to('dburns@mozilla.com')\
+            .whiteboard("affects")\
+            .search()
+
+    assert len(responses.calls) == 1
+    assert len(bugs) == 2
+    assert bugs[0].product == whiteboard_return['bugs'][0]['product']
+    assert bugs[0].summary == whiteboard_return['bugs'][0]['summary']
\ No newline at end of file