def test_add_matching(): fl = t.FileList() fl.append("a.java") fl.include("*.c") t.eq(fl[0], "a.java") t.eq(len(fl), 4) t.isin("abc.c", fl)
def test_native_lower(conn, cursor): try: t.dbwrapper.DB_INFO['sqlite'].native_case = "lower" cursor.execute("select 1 as A") t.isin("a", cursor.columns) finally: t.dbwrapper.DB_INFO['sqlite'].native_case = None
def test_py_no_del_item(rt): glbl = ActiveGlobal() cx = rt.new_context(glbl) cx.execute('foo = 4;') t.eq(glbl.data["foo"], 8) cx.execute("delete foo;") t.isin("foo", glbl.data)
def test_create_user(api): data = { "username": "******", "firstname": "Blossom", "lastname": "Utonium", "password1": "ng5qhhbiwozcANc3", "password2": "ng5qhhbiwozcANc3", "email": "*****@*****.**", "timezone": "Africa/Johannesburg", "account_type": "3", "domains": "9", "active": "y", "send_report": "y", "spam_checks": "y", "low_score": "0.0", "high_score": "0.0", } req = api.create_user(data) path = ENDPOINTS["users"]["new"]["name"] t.eq(api.response.final_url, "%s%s%s" % (BASE_URL, API_PATH, path)) t.eq(api.response.request.method, ENDPOINTS["users"]["new"]["method"]) t.eq(api.response.status_int, 201) t.isin("username", req) t.isin("email", req) t.eq(req["id"], 10) t.eq(req["username"], "blossom") t.eq(req["email"], "*****@*****.**") t.isnotin("password1", req)
def test_get_insync(api): """comments""" resp = api.get_insync() path = ENDPOINTS["config"]["insync"]['name'] t.eq(api.response.final_url, '%s%s' % (BASE_URL, path)) t.eq(api.response.request.method, ENDPOINTS["config"]["insync"]['method']) t.eq(api.response.status_int, 200) t.isin('configInSync', resp)
def test_get_connections(api): """Get connections""" resp = api.get_connections() path = ENDPOINTS["connections"]['name'] t.eq(api.response.final_url, '%s%s' % (BASE_URL, path)) t.eq(api.response.request.method, ENDPOINTS["connections"]['method']) t.eq(api.response.status_int, 200) t.isin('connections', resp)
def test_get_errors(api): """comments""" resp = api.get_errors() path = ENDPOINTS["errors"]["get"]['name'] t.eq(api.response.final_url, '%s%s' % (BASE_URL, path)) t.eq(api.response.request.method, ENDPOINTS["errors"]["get"]['method']) t.eq(api.response.status_int, 200) t.isin('errors', resp)
def test_new_config(api): """comments""" resp = api.new_config({}) path = ENDPOINTS["config"]["new"]['name'] t.eq(api.response.final_url, '%s%s' % (BASE_URL, path)) t.eq(api.response.request.method, ENDPOINTS["config"]["new"]['method']) t.eq(api.response.status_int, 200) t.isin('code', resp) t.eq(resp['code'], 200)
def test_get_version(api): resp = api.get_version() path = ENDPOINTS['version']['name'] t.eq(api.response.final_url, '%s%s' % (BASE_URL, path)) t.eq(api.response.request.method, ENDPOINTS['version']['method']) t.eq(api.response.status_int, 200) t.isin('os', resp) t.isin('version', resp) t.eq(resp['os'], 'linux')
def test_reset(api): """comments""" resp = api.reset() path = ENDPOINTS["system"]["reset"]['name'] t.eq(api.response.final_url, '%s%s' % (BASE_URL, path)) t.eq(api.response.request.method, ENDPOINTS["system"]["reset"]['method']) t.eq(api.response.status_int, 200) t.isin('ok', resp) t.eq(resp['ok'], 'resetting database')
def test_clear_errors(api): """comments""" resp = api.clear_errors() path = ENDPOINTS["errors"]["clear"]['name'] t.eq(api.response.final_url, '%s%s' % (BASE_URL, path)) t.eq(api.response.request.method, ENDPOINTS["errors"]["clear"]['method']) t.eq(api.response.status_int, 200) t.isin('code', resp) t.eq(resp['code'], 200)
def test_get_folder_statistics(api): """comments""" resp = api.get_folder_statistics() path = ENDPOINTS["stats"]["folder"]['name'] t.eq(api.response.final_url, '%s%s' % (BASE_URL, path)) t.eq( api.response.request.method, ENDPOINTS["stats"]["folder"]['method']) t.eq(api.response.status_int, 200) t.isin('ms-quarantine', resp)
def test_get_users(api): req = api.get_users() path = ENDPOINTS["users"]["list"]["name"] t.eq(api.response.final_url, "%s%s%s" % (BASE_URL, API_PATH, path)) t.eq(api.response.request.method, ENDPOINTS["users"]["list"]["method"]) t.eq(api.response.status_int, 200) t.isin("items", req) t.isin("meta", req) t.eq(req["items"][0]["username"], "*****@*****.**") t.eq(req["meta"]["total"], 2)
def test_get_status(api): """comments""" resp = api.get_status() path = ENDPOINTS["system"]["status"]['name'] t.eq(api.response.final_url, '%s%s' % (BASE_URL, path)) t.eq( api.response.request.method, ENDPOINTS["system"]["status"]['method']) t.eq(api.response.status_int, 200) t.isin('pathSeparator', resp) t.eq(resp['pathSeparator'], '/')
def test_new_ping(api): """comments""" resp = api.new_ping() path = ENDPOINTS["system"]["ping"]['name'] t.eq(api.response.final_url, '%s%s' % (BASE_URL, path)) t.eq( api.response.request.method, ENDPOINTS["system"]["ping"]['method']) t.eq(api.response.status_int, 200) t.isin('ping', resp) t.eq(resp['ping'], 'pong')
def test_upgrade(api): """comments""" resp = api.upgrade() path = ENDPOINTS["system"]["do_upgrade"]['name'] t.eq(api.response.final_url, '%s%s' % (BASE_URL, path)) t.eq( api.response.request.method, ENDPOINTS["system"]["do_upgrade"]['method']) t.eq(api.response.status_int, 200) t.isin('code', resp) t.eq(resp['code'], 200)
def test_multiple_counters(q, s): s.send("gorm:1|c") s.send("gurm:1|c") stats = {"stats.gorm": 2, "stats.gurm": 2} for i in range(2): stat = q.get() t.isin(stat[0], stats) t.eq(stats[stat[0]], stat[1]) t.gt(stat[1], 0) stats.pop(stat[0]) t.same_stat("stats.numStats", 2, q.get())
def test_shutdown(api): """comments""" resp = api.shutdown() path = ENDPOINTS["system"]["shutdown"]['name'] t.eq(api.response.final_url, '%s%s' % (BASE_URL, path)) t.eq( api.response.request.method, ENDPOINTS["system"]["shutdown"]['method']) t.eq(api.response.status_int, 200) t.isin('ok', resp) t.eq(resp['ok'], 'shutting down')
def test_get_user(api): userid = 5 req = api.get_user(userid) path = ENDPOINTS["users"]["get"]["name"] % dict(userid=userid) t.eq(api.response.final_url, "%s%s%s" % (BASE_URL, API_PATH, path)) t.eq(api.response.request.method, ENDPOINTS["users"]["get"]["method"]) t.eq(api.response.status_int, 200) t.isin("username", req) t.isin("email", req) t.eq(req["username"], "rowdyrough") t.eq(req["email"], "*****@*****.**") t.raises(BaruwaAPIError, api.get_user, 7)
def test_get_file(api): """comments""" resp = api.get_file('phishingupdate') path = ENDPOINTS["db"]["file"]['name'] prd = urlparse(api.response.final_url) the_url = "%s://%s%s" % (prd.scheme, prd.netloc, prd.path) t.eq(the_url, '%s%s' % (BASE_URL, path)) t.eq( api.response.request.method, ENDPOINTS["db"]["file"]['method']) t.eq(api.response.status_int, 200) t.isin('global', resp)
def test_list_domains(api): req = api.get_domains() path = ENDPOINTS['domains']['list']['name'] t.eq( api.response.final_url, '%s%s%s' % (BASE_URL, API_PATH, path)) t.eq(api.response.request.method, ENDPOINTS['domains']['list']['method']) t.eq(api.response.status_int, 200) t.isin('items', req) t.isin('meta', req) t.eq(req['items'][0]['name'], 'example.com') t.eq(req['meta']['total'], 2)
def test_get_ignores(api): """comments""" folder = 'ms-quarantine' resp = api.get_ignores(folder) path = ENDPOINTS["db"]["ignores"]['name'] prd = urlparse(api.response.final_url) the_url = "%s://%s%s" % (prd.scheme, prd.netloc, prd.path) t.eq(the_url, '%s%s' % (BASE_URL, path)) t.eq( api.response.request.method, ENDPOINTS["db"]["ignores"]['method']) t.eq(api.response.status_int, 200) t.isin('patterns', resp)
def test_assign_priority(api): """comments""" folder = 'ms-quarantine' filename = 'phishingupdate' resp = api.assign_priority(folder, filename) path = ENDPOINTS["db"]["prio"]['name'] prd = urlparse(api.response.final_url) the_url = "%s://%s%s" % (prd.scheme, prd.netloc, prd.path) t.eq(the_url, '%s%s' % (BASE_URL, path)) t.eq( api.response.request.method, ENDPOINTS["db"]["prio"]['method']) t.eq(api.response.status_int, 200) t.isin('perpage', resp) t.isin('total', resp)
def test_list_deliveryservers(api): orgid = 1 req = api.get_fallbackservers(orgid) path = ENDPOINTS['fallbackservers']['list']['name'] % dict(orgid=orgid) t.eq( api.response.final_url, '%s%s%s' % (BASE_URL, API_PATH, path)) t.eq( api.response.request.method, ENDPOINTS['fallbackservers']['list']['method']) t.eq(api.response.status_int, 200) t.isin('items', req) t.isin('meta', req) t.eq(req['items'][0]['address'], '192.168.1.150') t.eq(req['meta']['total'], 1)
def test_list_domainaliases(api): domainid = 9 req = api.get_domainaliases(domainid) path = ENDPOINTS['domainaliases']['list']['name'] % dict(domainid=domainid) t.eq( api.response.final_url, '%s%s%s' % (BASE_URL, API_PATH, path)) t.eq( api.response.request.method, ENDPOINTS['domainaliases']['list']['method']) t.eq(api.response.status_int, 200) t.isin('items', req) t.isin('meta', req) t.eq(req['items'][0]['name'], 'example.net') t.eq(req['meta']['total'], 1)
def test_get_completion(api): """comments""" devid = '6RBLNBN-6EIGPRG-ZLZR7XI-LDWUXSE-NYWEBLI-3DFE2AI-L2DP3JL-4R77ZAM' folder = 'ms-quarantine' resp = api.get_completion(devid, folder) path = ENDPOINTS["db"]["completion"]['name'] prd = urlparse(api.response.final_url) the_url = "%s://%s%s" % (prd.scheme, prd.netloc, prd.path) t.eq(the_url, '%s%s' % (BASE_URL, path)) t.eq( api.response.request.method, ENDPOINTS["db"]["completion"]['method']) t.eq(api.response.status_int, 200) t.isin('completion', resp) t.eq(resp['completion'], 0)
def test_list_authservers(api): domainid = 9 req = api.get_authservers(domainid) path = ENDPOINTS['authservers']['list']['name'] % dict( domainid=domainid) t.eq( api.response.final_url, '%s%s%s' % (BASE_URL, API_PATH, path)) t.eq( api.response.request.method, ENDPOINTS['authservers']['list']['method']) t.eq(api.response.status_int, 200) t.isin('items', req) t.isin('meta', req) t.eq(req['items'][0]['address'], '192.168.1.150') t.eq(req['meta']['total'], 1)
def test_multiple_counters(q, s): s.send("gorm:1|c") s.send("gurm:1|c") stats = { "stats.gorm": 2, "stats_counts.gorm": 1, "stats.gurm": 2, "stats_counts.gurm": 1 } for i in range(4): stat = q.get(timeout=TIMEOUT) t.isin(stat[1], stats) t.eq(stats[stat[1]], stat[2]) t.gt(stat[2], 0) stats.pop(stat[1]) t.same_stat(None, "stats.numStats", 2, q.get(timeout=TIMEOUT))
def test_new_ignores(api): """comments""" filename = '.git' folder = 'ms-quarantine' ignores = {'ignore': [filename]} resp = api.new_ignores(folder, ignores) path = ENDPOINTS["db"]["new_ignores"]['name'] prd = urlparse(api.response.final_url) the_url = "%s://%s%s" % (prd.scheme, prd.netloc, prd.path) t.eq(the_url, '%s%s' % (BASE_URL, path)) t.eq( api.response.request.method, ENDPOINTS["db"]["new_ignores"]['method']) t.eq(api.response.status_int, 200) t.isin('patterns', resp) t.isin('ignore', resp) t.eq("""["[u'%s']"]""" % filename, resp['ignore'])
def test_default_excludes(): fl = t.FileList() fl.clear_excludes() fl.include("*~", "*.bak", "core") t.isin("core", fl) t.isin("x.bak", fl) t.isin("x~", fl)
def test_match(): fl = t.FileList() fl.include("*.c") t.isin("abc.c", fl) t.eq(len(fl), 3) map(lambda p: t.eq(p.ext, ".c"), fl)
def test_002(o, u, b): r = request(u, "POST", filters=[o]) t.eq(r.status_int, 200) f = dict(parse_qsl(r.body_string())) t.isin('oauth_token', f) t.isin('oauth_token_secret', f)
def test_iter_js_object(cx): ret = cx.execute('var f = {"foo": 1, "domino": "daily"}; f;') items = set(["domino", "foo"]) for k in ret: t.isin(k, items) items.remove(k)
def test_contains(): fl = t.FileList("*.c") t.isin("abc.c", fl) t.isin("x.c", fl) t.isin("xyz.c", fl)