# Path: bbcflib/frontend.py
# class Frontend(object):
#     """Connection to Fabrice David's web frontends for workflows.
# 
#     A Frontend object either takes *url* to connect to, or a
#     ``ConfigParser`` given as the *config* keyword argument (and
#     optionally a *section* keyword argument defaulting to
#     ``"frontend"``.
# 
#     If a *config* argument is given, it reads the field
#     ``frontend_url`` from the configuration.  If both the *url* and
#     *config* arguments are given, *url* overrides config.
#     """
#     def __init__(self, url=None, config=None, section='frontend'):
#         if url == None and config == None:
#             raise TypeError("Must specify a URL or a configuration.")
#         elif url != None:
#             self.url = normalize_url(url)
#         else:
#             self.url = normalize_url(config.get(section, 'frontend_url'))
# 
#     def query_url(self, method, key):
#         return """%s/%s.json?key=%s""" % (self.url, method, key)
# 
#     def _fix_dict(self,a):
#         for k,v in a.iteritems():
#             if isinstance(v,unicode): a[k] = str(v)
#             if isinstance(k,unicode): a[str(k)] = a.pop(k)
# #        if isinstance(a.get('created_at'),str):
# #            a['created_at'] = datetime.strptime(a['created_at'], '%Y-%m-%dT%H:%M:%SZ')
#         return a
# 
#     def _fetch_groups(self, key):
#         return [self._fix_dict(g['group']) for g in json.load(urllib2.urlopen(self.query_url('groups', key)))]
# 
#     def _fetch_runs(self, key):
#         def _f(a):
#             a['lane'] = a.pop('lane_nber')
#             a['run'] = a.pop('run_nber')
#             a['facility'] = a.pop('facility_name')
#             a['machine'] = a.pop('machine_name')
#             return self._fix_dict(a)
#         return [_f(r['run']) for r in json.load(urllib2.urlopen(self.query_url('runs', key)))]
# 
#     def _fetch_job(self, key):
#         j = json.load(urllib2.urlopen("""%s/jobs/%s.json""" % (self.url, key)))['job']
#         j = self._fix_dict(j)
#         ret_val = {'id': j.pop('id'),
#                    'created_at': j.pop('created_at'),
#                    'key': j.pop('key'),
#                    'assembly_id': j.pop('assembly_id'),
#                    'description': j.pop('description'),
#                    'email': j.pop('email')}
#         ret_val.update({'options': j})
#         return ret_val
# 
#     def job(self, key):
#         """Fetch information about job *key* as a Job object."""
#         x = self._fetch_job(key)
#         x = self._fix_dict(x)
#         j = Job(**x)
#         [j.add_group(id=g.pop('id'), name=g.pop('name'), group=g)
#          for g in self._fetch_groups(key)]
#         [j.add_run(**r) for r in self._fetch_runs(key)]
#         return j


import datetime
    import unittest2 as unittest
    import unittest
from ..frontend import Frontend
                                         u'from_action': None,
                                         u'status_id': None,
                                         u'query_string': None,
                                         u'controller': None,
                                         u'referer': None,
                                         u'path': None,
                                         u'facility_id': None,
                                         u'user_agent': None,
                                         u'time': None,
                                         u'action': None,
                                         u'machine_id': None})
        self.frontend_job.add_group(id = 3,
                                    control = False,
                                    name = u'My first group')
        self.frontend_job.add_run(id = 5, group = 3,
                                  facility = u"lgtf", facility_location = u"Lausanne",
                                  machine = u"C3PO", machine_id = 1,
                                  run = 36, lane = 1)
        self.frontend_job.add_run(id = 6, group = 3,
                                  facility = u"lgtf", facility_location = u"Lausanne",
                                  machine = u"C3PO", machine_id = 1,
                                  run = 36, lane = 2)
        self.frontend_job.add_group(id = 4, control = True, name = u'Other group')
        self.frontend_job.add_run(id = 7, group = 4,
                                  facility = u"lgtf", facility_location = u"Lausanne",
                                  machine = u"C3PO", machine_id = 1,
                                  run = 37, lane = 3)

    def test_init(self):
        def _f(url):

# Path: bbcflib/frontend.py
# class Frontend(object):
#     """Connection to Fabrice David's web frontends for workflows.
# 
#     A Frontend object either takes *url* to connect to, or a
#     ``ConfigParser`` given as the *config* keyword argument (and
#     optionally a *section* keyword argument defaulting to
#     ``"frontend"``.
# 
#     If a *config* argument is given, it reads the field
#     ``frontend_url`` from the configuration.  If both the *url* and
#     *config* arguments are given, *url* overrides config.
#     """
#     def __init__(self, url=None, config=None, section='frontend'):
#         if url == None and config == None:
#             raise TypeError("Must specify a URL or a configuration.")
#         elif url != None:
#             self.url = normalize_url(url)
#         else:
#             self.url = normalize_url(config.get(section, 'frontend_url'))
# 
#     def query_url(self, method, key):
#         return """%s/%s.json?key=%s""" % (self.url, method, key)
# 
#     def _fix_dict(self,a):
#         for k,v in a.iteritems():
#             if isinstance(v,unicode): a[k] = str(v)
#             if isinstance(k,unicode): a[str(k)] = a.pop(k)
# #        if isinstance(a.get('created_at'),str):
# #            a['created_at'] = datetime.strptime(a['created_at'], '%Y-%m-%dT%H:%M:%SZ')
#         return a
# 
#     def _fetch_groups(self, key):
#         return [self._fix_dict(g['group']) for g in json.load(urllib2.urlopen(self.query_url('groups', key)))]
# 
#     def _fetch_runs(self, key):
#         def _f(a):
#             a['lane'] = a.pop('lane_nber')
#             a['run'] = a.pop('run_nber')
#             a['facility'] = a.pop('facility_name')
#             a['machine'] = a.pop('machine_name')
#             return self._fix_dict(a)
#         return [_f(r['run']) for r in json.load(urllib2.urlopen(self.query_url('runs', key)))]
# 
#     def _fetch_job(self, key):
#         j = json.load(urllib2.urlopen("""%s/jobs/%s.json""" % (self.url, key)))['job']
#         j = self._fix_dict(j)
#         ret_val = {'id': j.pop('id'),
#                    'created_at': j.pop('created_at'),
#                    'key': j.pop('key'),
#                    'assembly_id': j.pop('assembly_id'),
#                    'description': j.pop('description'),
#                    'email': j.pop('email')}
#         ret_val.update({'options': j})
#         return ret_val
# 
#     def job(self, key):
#         """Fetch information about job *key* as a Job object."""
#         x = self._fetch_job(key)
#         x = self._fix_dict(x)
#         j = Job(**x)
#         [j.add_group(id=g.pop('id'), name=g.pop('name'), group=g)
#          for g in self._fetch_groups(key)]
#         [j.add_run(**r) for r in self._fetch_runs(key)]
#         return j


# Path: bbcflib/tests/test_frontend.py
import datetime
    import unittest2 as unittest
    import unittest
from ..frontend import Frontend

                                         u'from_action': None,
                                         u'status_id': None,
                                         u'query_string': None,
                                         u'controller': None,
                                         u'referer': None,
                                         u'path': None,
                                         u'facility_id': None,
                                         u'user_agent': None,
                                         u'time': None,
                                         u'action': None,
                                         u'machine_id': None})
        self.frontend_job.add_group(id = 3,
                                    control = False,
                                    name = u'My first group')
        self.frontend_job.add_run(id = 5, group = 3,
                                  facility = u"lgtf", facility_location = u"Lausanne",
                                  machine = u"C3PO", machine_id = 1,
                                  run = 36, lane = 1)
        self.frontend_job.add_run(id = 6, group = 3,
                                  facility = u"lgtf", facility_location = u"Lausanne",
                                  machine = u"C3PO", machine_id = 1,
                                  run = 36, lane = 2)
        self.frontend_job.add_group(id = 4, control = True, name = u'Other group')
        self.frontend_job.add_run(id = 7, group = 4,
                                  facility = u"lgtf", facility_location = u"Lausanne",
                                  machine = u"C3PO", machine_id = 1,
                                  run = 37, lane = 3)

    def test_init(self):
        def _f(url):

            q = Frontend(url)