return True, len(polissa_ids)>20000, None
    except Exception, e:
        return False, False, None


def test_billing():
    '''
    WARNING: To be updated will proper data
    '''
    if not O:
        return False, False, None

    billing_obj = O.GiscedataFacturacioFactura
    fields_to_read = ['origin', 'cups_id']
    return True, billing_obj.read([1000, 1010], fields_to_read) == \
        [{'origin': 'F0000000000000',
          'id': 1000,
          'cups_id': [100, 'ES00000000000000000000']},
         {'origin': 'F0000000000000',
          'id': 1000,
          'cups_id': [101, 'ES00000000000000000001']}], None  # To be updated


results = []
results.append(run_test(test_connection, 100))
results.append(run_test(test_users, 10))
results.append(run_test(test_contracts, 10))
results.append(run_test(test_billing, 10))

push_test('ERP status %s' % datetime.datetime.now(), results)
            else:
                alert.dismiss()
            return alert_text
        finally: self.accept_next_alert = True

    def tearDown(self):
        self.driver.quit()
        self.assertEqual([], self.verificationErrors)

def test_HS_latency():
    try:
        unittest.main(exit=False)
        return True, True, None
    except Exception, e:
        return False, False, None

def test_cloudfront_latency():
    try:
        for downloaded_file in downloaded_files:
            response = urllib2.urlopen(downloaded_file)
            html = response.read()
        return True, True, None
    except Exception, e:
        return False, False, None

results = []
results.append(run_test(test_HS_latency, 5))
results.append(run_test(test_cloudfront_latency, 5))

push_test('Help Scout-cloudfront status %s' % datetime.datetime.now(), results)
db = MongoClient(conn_str.format(
    **{'username': config['mongodb']['username'],
       'password': config['mongodb']['password'],
       'hostname': config['mongodb']['hostname'],
       'port': config['mongodb']['port'],
       'dbname': config['mongodb']['dbname'],
       'replica': config['mongodb'].get('replica'),
}))

O = OOOP(dbname=config['erp']['dbname'],
         user=config['erp']['username'],
         pwd=config['erp']['password'],
         port=config['erp']['port'],
         uri=config['erp']['hostname'])

cch_stats = CCHStats(db, O)

today = datetime.datetime.today()
today_sof = datetime.datetime(today.year, today.month, today.day, 0, 0, 0)

out = {name: {} for name in NAMES}
results = []
for name in NAMES:
    results.append(run_test(name, cch_stats.get_n_entries,[name]))
    results.append(run_test(name, cch_stats.get_n_entries,[name, today_sof]))
    results.append(run_test(name, cch_stats.get_storage,[name]))
    results.append(run_test(name, cch_stats.get_providers,[name]))
    results.append(run_test(name, cch_stats.get_update_providers,[name]))
push_test('CCH loader status %s' % datetime.datetime.now(), results)
import urllib2
import time
import requests
import base64
import datetime
import subprocess
from check import send_report, run_test, push_test

def test_internet():
    p = subprocess.Popen(['/bin/sh','check_internet.sh'], stdout=subprocess.PIPE, 
                        stderr=subprocess.PIPE)
    out, err = p.communicate()
    return True, True, out.replace(r'\n','\n<br>')

results = []
results.append(run_test(test_internet, 1000))

push_test('Internet status %s' % datetime.datetime.now(), results)
db = MongoClient('mongodb://{username}:{password}@{hostname}/{dbname}'.format(**
                 {
                 'username': config['mongodb']['username'],
                 'password': config['mongodb']['password'],
                 'hostname': config['mongodb']['hostname'],
                 'port': config['mongodb']['port'],
                 'dbname': config['mongodb']['dbname']
                  }))

O = OOOP(dbname=config['erp']['dbname'],
         user=config['erp']['username'],
         pwd=config['erp']['password'],
         port=config['erp']['port'],
         uri=config['erp']['hostname'])

cch_stats = CCHStats(db, O)

today = datetime.datetime.today()
today_sof = datetime.datetime(today.year, today.month, today.day, 0, 0, 0)

out = {name: {} for name in NAMES}
results = []
for name in NAMES:
    results.append(run_test(name, cch_stats.get_n_entries,[name]))
    results.append(run_test(name, cch_stats.get_n_entries,[name, today_sof]))
    results.append(run_test(name, cch_stats.get_storage,[name]))
    results.append(run_test(name, cch_stats.get_providers,[name]))
    results.append(run_test(name, cch_stats.get_update_providers,[name]))
push_test('CCH loader status %s' % datetime.datetime.now(), results)
        return False, False, None
    return (True, True, _collections == \
        [], None) # To be updated


def test_get_doc():
    url_articles = 'https://docsapi.helpscout.net/v1/articles/'
    article_id = ''
    url = url_articles + article_id
    try:
        content = _url_req(url)
        urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+',
                          content['article']['text'])
        for url in urls:
            response = urllib2.urlopen(url)
            dummy = response.read()
        return True, True,None
    except urllib2.URLError as e:
        return True, False,None
    except socket.timeout, e:
        return False, False, None


results = []
results.append(run_test(test_list_mailboxes, 2))
results.append(run_test(test_list_users, 2))
results.append(run_test(test_list_collections, 2))
results.append(run_test(test_get_doc, 20))

push_test('Help Scout status %s' % datetime.datetime.now(), results)