Permalink
Browse files

separate results collection from posting

  • Loading branch information...
Jeff Hammel
Jeff Hammel committed Jul 31, 2012
1 parent de84ef1 commit 1aedd43aa4d59e30a1ec586e16d3c6c49af06d2e
Showing with 43 additions and 14 deletions.
  1. +1 −1 dzclient/__init__.py
  2. +42 −13 dzclient/client.py
View
@@ -2,4 +2,4 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-from .client import DatazillaResult, DatazillaRequest
+from .client import DatazillaResult, DatazillaResultsCollection, DatazillaRequest
View
@@ -2,11 +2,12 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-from copy import deepcopy
+import inspect
import httplib
import oauth2 as oauth
import time
import urllib
+from copy import deepcopy
from urlparse import urlparse
try:
@@ -41,22 +42,16 @@ def join_results(self, results):
for test_name, values in tests.items():
suite.setdefault(test_name, []).extend(values)
+class DatazillaResultsCollection(object):
-class DatazillaRequest(object):
- """
- Datazilla request object that manages test information and submission.
-
- Note that the revision id can be 16 characters, maximum.
- """
- def __init__(self, host, project, oauth_key, oauth_secret,
- machine_name="", os="", os_version="", platform="",
+ def __init__(self, machine_name="", os="", os_version="", platform="",
build_name="", version="", revision="", branch="", id="",
test_date=None):
- self.host = host
- self.project = project
- self.oauth_key = oauth_key
- self.oauth_secret = oauth_secret
+ """
+ - id : the build ID for which the dzresults are for; a unique identifier to which these results belong
+ """
+
self.machine_name = machine_name
self.os = os
self.os_version = os_version
@@ -106,6 +101,40 @@ def datasets(self):
return datasets
+
+class DatazillaRequest(DatazillaResultsCollection):
+ """
+ Datazilla request object that manages test information and submission.
+
+ Note that the revision id can be 16 characters, maximum.
+
+ """
+
+ @classmethod
+ def create(cls, host, project, oauth_key, oauth_secret, collection):
+ """create a DatazillaRequest instance from a results collection"""
+
+ # get attributes from the collection
+ attributes = inspect.getargspec(foo).args[1:]
+ kw = dict([(i, gettattr(collection, i))
+ for i in attributes])
+
+ # create the instance
+ instance = cls(host, project, oauth_key, oauth_secret, **kw)
+
+ # add the results
+ instance.add_datazilla_results(collection.results)
+
+ return instance
+
+ def __init__(self, host, project, oauth_key, oauth_secret, **kw):
+ self.host = host
+ self.project = project
+ self.oauth_key = oauth_key
+ self.oauth_secret = oauth_secret
+ DatazillaResultsCollection.__init__(self, **kw)
+
+
def submit(self):
"""Submit test data to datazilla server, return list of responses."""

0 comments on commit 1aedd43

Please sign in to comment.