Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_init(self):
# Test the default initialization
cc = ComputeClass('test', 'key', 'val', 'echo')
assert_equal(cc.name, 'test', msg='Name not set correctly')
assert_equal(cc.resource, 'key', msg='Resource not set correctly')
assert_equal(cc.value, 'val', msg='Value not set correctly')
cc = ComputeClass('test2', 'key2', 'val2', 'echo')
assert_equal(cc.name, 'test2', msg='Name not set correctly')
assert_equal(cc.resource, 'key2', msg='Resource not set correctly')
assert_equal(cc.value, 'val2', msg='Value not set correctly')
def test_clone_design(self):
#@TODO@ Prakash fix this test
raise SkipTest
n_available = Document.objects.available_docs(Workflow, self.user).count()
response = self.client.post(reverse('jobsub.views.clone_design',
kwargs={'design_id': self.design.id}),
follow=True,
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
assert_equal(response.status_code, 200)
assert_equal(n_available + 1, Document.objects.available_docs(Workflow, self.user).count())
assert_equal(conf.QUERYCACHE_ROWS.get(), expected_rows)
assert_equal(conf.IMPERSONATION_ENABLED.get(), False)
flags = """
-webserver_certificate_file=/etc/test-ssl-conf/CA_STANDARD/impala-cert.pem
-ssl_server_certificate=/etc/test-ssl-conf/CA_STANDARD/impala-cert.pem
-max_result_cache_size=%d
-authorized_proxy_user_config=hue=*
""" % expected_rows
open_file(os.path.join(test_impala_conf_dir, 'impalad_flags'), 'w').write(flags)
resets.append(conf.IMPALA_CONF_DIR.set_for_testing(test_impala_conf_dir))
impala_flags.reset()
assert_equal(impala_flags.get_webserver_certificate_file(), '/etc/test-ssl-conf/CA_STANDARD/impala-cert.pem')
assert_equal(impala_flags.get_ssl_server_certificate(), '/etc/test-ssl-conf/CA_STANDARD/impala-cert.pem')
assert_equal(impala_flags.get_max_result_cache_size(), expected_rows)
assert_equal(impala_flags.get_authorized_proxy_user_config(), 'hue=*')
# From Config
assert_equal(conf.QUERYCACHE_ROWS.get(), expected_rows)
assert_equal(conf.IMPERSONATION_ENABLED.get(), True)
finally:
impala_flags.reset()
for reset in resets:
reset()
def test_current_value():
"""should not make preference's current value actionable"""
results = yvs.get_result_list('language english')
nose.assert_equal(results[0]['title'], 'English')
nose.assert_equal(results[0]['valid'], False)
nose.assert_equal(len(results), 1)
def b_check_matrix_local(b_obj):
b_loc_vec, b_rot_quat, b_scale_vec = b_obj.matrix_local.decompose() # transforms
print("b_loc_vec - {0}".format(b_loc_vec))
nose.tools.assert_equal(b_loc_vec, b_translation_mat().to_translation()) # location
print("b_scale_vec - {0}".format(b_scale_vec))
nose.tools.assert_equal((b_scale_vec - b_scale_mat().to_scale()) < E_VEC, True) # uniform scale
b_rot_eul = b_rot_quat.to_euler()
print("b_rot_eul - {0}".format(b_rot_eul))
b_rot_axis = (degrees(b_rot_eul.x), degrees(b_rot_eul.y), degrees(b_rot_eul.z))
print("b_rot_eul(x,y,z) - {0}".format(b_rot_axis))
nose.tools.assert_equal((b_rot_eul.x - RAD_30) < EPSILON, True) # x rotation
nose.tools.assert_equal((b_rot_eul.y - RAD_60) < EPSILON, True) # y rotation
nose.tools.assert_equal((b_rot_eul.z - RAD_90) < EPSILON, True) # z rotation
assert_equal(d['key'], 'hamms-test')
r = requests.get(url)
assert_equal(r.status_code, 500)
d = r.json()
assert_equal(d['tries_remaining'], 1)
otherkey_url = 'http://127.0.0.1:{port}?key=other-key'.format(port=BASE_PORT+12)
r = requests.get(otherkey_url)
assert_equal(r.status_code, 500)
d = r.json()
assert_equal(d['tries_remaining'], 2)
url = 'http://127.0.0.1:{port}?key=hamms-test'.format(port=BASE_PORT+12)
r = requests.get(url)
assert_equal(r.status_code, 200)
d = r.json()
assert_equal(d['tries_remaining'], 0)
url = 'http://127.0.0.1:{port}/counters?key=hamms-test&tries=7'.format(port=BASE_PORT+12)
r = requests.post(url)
assert_equal(r.status_code, 200)
d = r.json()
assert_equal(d['key'], 'hamms-test')
assert_equal(d['tries_remaining'], 7)
url = 'http://127.0.0.1:{port}/counters'.format(port=BASE_PORT+12)
r = requests.post(url, data={'key': 'hamms-test', 'tries': 7})
assert_equal(r.status_code, 200)
d = r.json()
assert_equal(d['key'], 'hamms-test')
assert_equal(d['tries_remaining'], 7)
def test_segment_and_send(self, batcher_mock):
"""App Integration Batcher - Segment and Send Logs to StreamAlert"""
logs = [{'timestamp': 'time',
'eventtype': 'authentication',
'host': 'host'} for _ in range(3000)]
self.batcher._segment_and_send(logs)
assert_equal(batcher_mock.call_count, 2)
def test_ARGB32():
qimg = QtGui.QImage(320, 240, QtGui.QImage.Format_ARGB32)
qimg.fill(0)
v = _qimageview(qimg)
qimg.setPixel(12, 10, 42)
assert_equal(v.shape, (240, 320))
assert_equal(v[10,12], 42)
assert_equal(v.nbytes, numBytes(qimg))
def test_simcc_x86_64():
binary_path = os.path.join(test_location, 'x86_64', 'simcc')
p = angr.Project(binary_path)
p.analyses.CFGEmulated()
f_arg1 = p.kb.functions['arg1']
nose.tools.assert_not_equal(f_arg1, None)
nose.tools.assert_equal(type(f_arg1.calling_convention), SimCCSystemVAMD64)
nose.tools.assert_equal(len(f_arg1.arguments), 1)
nose.tools.assert_equal(f_arg1.arguments[0].reg_name, 'rdi')
f_arg7 = p.kb.functions['arg7']
nose.tools.assert_not_equal(f_arg7, None)
nose.tools.assert_equal(type(f_arg7.calling_convention), SimCCSystemVAMD64)
nose.tools.assert_equal(len(f_arg7.arguments), 7)
nose.tools.assert_equal(f_arg7.arguments[1].reg_name, 'rsi')
f_arg9 = p.kb.functions.function(name='arg9')
nose.tools.assert_not_equal(f_arg9, None)
nose.tools.assert_equal(type(f_arg9.calling_convention), SimCCSystemVAMD64)
nose.tools.assert_equal(len(f_arg9.arguments), 9)
nose.tools.assert_equal(f_arg9.arguments[8].stack_offset, 0x8 + 0x8 * 2)
def require_valid_user(user, uid=None):
nose.tools.assert_is_instance(user, dict)
for field in ["email", "name", "uid"]:
nose.tools.assert_in(field, user)
if uid is not None:
nose.tools.assert_equal(user["uid"], uid)
return user