コード例 #1
0
 def test_should_i_run_custom_all(self):
     from core.Status import Status
     from core.TestType import TestType
     test_type = str(uuid.uuid4())
     tt = TestType(test_type)
     tt.add_run_type('default', 'ALL', {'field': 'Status._status', 'operator': 'EQUAL', 'value': 'SUCCESS'})
     tt.save()
     test_id = str(uuid.uuid4())
     test_status1 = 'FAILURE'
     details = {'browser': random.choice(['Firefox', 'Chrome'])}
     status1 = Status(test_id, test_type, test_status1, details=details)
     status1.save_and_update()
     res = Status(test_id).should_i_run()
     assert res == False
     test_id2 = str(uuid.uuid4())
     test_status2 = 'SUCCESS'
     status2 = Status(test_id2, test_type, test_status2, details=details)
     status2.save_and_update()
     res = Status(test_id).should_i_run()
     assert res == False
     test_status3 = 'SUCCESS'
     status3 = Status(test_id, test_type, test_status3, details=details)
     status3.save_and_update()
     res = Status(test_id).should_i_run()
     assert res == False
     res = Status(test_id2).should_i_run()
     assert res == True
     status2 = Status(test_id2, test_type, test_status2, details=details)
     status2.save_and_update()
     res = Status(test_id2).should_i_run()
     assert res == True
コード例 #2
0
 def test_run(self):
     from core.TestType import TestType
     from core.Base import Base
     from core.Filter import Filter
     my_type1 = str(uuid.uuid4())
     doc1 = [str(uuid.uuid4()), str(uuid.uuid4()), str(uuid.uuid4())]
     test_type = TestType(my_type1, doc1)
     assert test_type.run() == test_type._default_run
     assert test_type.run('default') == test_type._default_run
     modifier = str(uuid.uuid4())
     res = test_type.add_run_type('new', modifier, {'operator': 'EQUAL', 'field': 1, 'value': 1})
     assert res == False
     assert test_type.run('new') == None
     modifier = 'ANY'
     res = test_type.add_run_type('new', modifier, {'operator': 'EQUAL', 'field': 1, 'value': 1})
     assert res
     assert test_type.run('new')['modifier'] == 'ANY'
     assert test_type.run('new')['condition'].to_dict() == {'operator': 'EQUAL', 'field': 1, 'value': 1}
     assert test_type.run('default') == test_type._default_run
     modifier = 'ALL'
     res = test_type.add_run_type('default', modifier, {'operator': 'EQUAL', 'field': 2, 'value': 3})
     assert res
     assert test_type.run('default')['modifier'] == 'ALL'
     assert test_type.run('default')['condition'].to_dict() == {'operator': 'EQUAL', 'field': 2, 'value': 3}
     assert test_type.run('not_existing') == None
コード例 #3
0
ファイル: test_test.py プロジェクト: ab9-er/TestSheriff
 def test_should_i_run_custom(self):
     from core.Status import Status
     from core.TestType import TestType
     test_type = str(uuid.uuid4())
     tt = TestType(test_type)
     tt.add_run_type('ALLOK', 'ALL', {'field': 'Status._status', 'operator': 'EQUAL', 'value': 'SUCCESS'})
     tt.save()
     test_id = str(uuid.uuid4())
     details = {'browser': 'Firefox'}
     test_type = str(uuid.uuid4())
     test_status1 = 'SUCCESS'
     status1 = Status(test_id, test_type, test_status1, details=details)
     status1.save_and_update()
     rv = self.app_test.get('/test/tests/{0}/run/ALLOK'.format(test_id))
     assert rv.status_code == 200
     res = json.loads(rv.data.decode('utf-8'))
     assert res['result'] == 'Success'
     assert res['run'] == True
     test_status2 = 'FAILURE'
     status2 = Status(test_id, test_type, test_status2, details=details)
     status2.save_and_update()
     rv = self.app_test.get('/test/tests/{0}/run/ALLOK'.format(test_id))
     assert rv.status_code == 200
     res = json.loads(rv.data.decode('utf-8'))
     assert res['result'] == 'Success'
     assert res['run'] == False
     rv = self.app_test.get('/test/tests/{0}/run'.format(test_id))
     assert rv.status_code == 200
     res = json.loads(rv.data.decode('utf-8'))
     assert res['result'] == 'Success'
     assert res['run'] == False
     test_status2 = 'SUCCESS'
     status2 = Status(test_id, test_type, test_status2, details=details)
     status2.save_and_update()
     rv = self.app_test.get('/test/tests/{0}/run/ALLOK'.format(test_id))
     assert rv.status_code == 200
     res = json.loads(rv.data.decode('utf-8'))
     assert res['result'] == 'Success'
     assert res['run'] == False
     rv = self.app_test.get('/test/tests/{0}/run'.format(test_id))
     assert rv.status_code == 200
     res = json.loads(rv.data.decode('utf-8'))
     assert res['result'] == 'Success'
     assert res['run'] == True
     rv = self.app_test.get('/test/tests/{0}/run/{1}'.format(test_id, str(uuid.uuid4())))
     assert rv.status_code == 404
コード例 #4
0
ファイル: test_testType.py プロジェクト: ab9-er/TestSheriff
 def test_get_run(self):
     from core.Status import Status
     from core.TestType import TestType
     from core.Base import Base
     test_id = str(uuid.uuid4())
     test_status = 'SUCCESS'
     test_type = str(uuid.uuid4())
     field1 = 'browser'
     field2 = 'environment'
     tt = TestType(test_type, doc_fields_to_index=[field1, field2])
     tt.add_run_type('new', 'ANY', {'operator': 'EQUAL', 'field': 1, 'value': 1})
     tt.save()
     details1 = {field1: 'Firefox', field2: 'master'}
     status1 = Status(test_id, test_type, test_status, details=details1)
     status1.save()
     rv = self.app_test_type.get('/test/test_types/{0}/runs/{1}'.format(str(uuid.uuid4()), 'default'))
     assert rv.status_code == 404
     rv = self.app_test_type.get('/test/test_types/{0}/runs/{1}'.format(test_type, str(uuid.uuid4())))
     assert rv.status_code == 404
     rv = self.app_test_type.get('/test/test_types/{0}/runs/{1}'.format(test_type, 'default'))
     assert rv.status_code == 200
     res = json.loads(rv.data.decode('utf-8'))
     assert res['result'] == 'Success'
     assert res['run']['modifier'] == TestType._default_run['modifier']
     assert res['run']['condition'] == TestType._default_run['condition'].to_dict()
     rv = self.app_test_type.get('/test/test_types/{0}/runs/{1}'.format(test_type, 'new'))
     assert rv.status_code == 200
     res = json.loads(rv.data.decode('utf-8'))
     assert res['result'] == 'Success'
     assert res['run']['modifier'] == 'ANY'
     assert res['run']['condition'] == {'operator': 'EQUAL', 'field': 1, 'value': 1}
     rv = self.app_test_type.get('/test/test_types/{0}/runs'.format(str(uuid.uuid4())))
     assert rv.status_code == 404
     rv = self.app_test_type.get('/test/test_types/{0}/runs'.format(test_type))
     assert rv.status_code == 200
     res = json.loads(rv.data.decode('utf-8'))
     assert res['result'] == 'Success'
     assert res['count'] == 2
     rv = self.app_test_type.get('/test/test_types/{0}'.format(test_type))
     assert rv.status_code == 200
     res = json.loads(rv.data.decode('utf-8'))
     assert res['result'] == 'Success'
     assert 'run' not in res['test_type']