예제 #1
0
파일: test.py 프로젝트: ab9-er/TestSheriff
 def post(self):
     parser = reqparse.RequestParser()
     parser.add_argument('test_id', type=str, help='test ID', required=True, location='json')
     parser.add_argument('type', type=str, help='test type', required=True, location='json')
     parser.add_argument('owner', type=str, help='test owner', required=False, location='json')
     args = parser.parse_args()
     test = TestCore(test_id=args['test_id'], test_type=args['type'], owner=args['owner'])
     test.save()
     test = prep_test(test)
     return jsonify(result='Success', test=test)
예제 #2
0
 def test_save(self):
     from core.Test import Test
     from core.Base import Base
     test_id = str(uuid.uuid4())
     owner = str(uuid.uuid4())
     test_type = str(uuid.uuid4())
     test = Test(test_id, owner, test_type)
     now = datetime.datetime.now()
     res = test.save()
     assert res
     at = Base().get_all(Test.collection, {})
     assert at.count() == 1
     assert at[0]['_id'] == test_id
     assert at[0]['owner'] == owner
     assert at[0]['test_id'] == test_id
     assert at[0]['type'] == test_type
     assert at[0]['last_seen'] < now + datetime.timedelta(seconds=1)