def post(self): try: claims = get_jwt_claims() user_id = claims['user_id'] name = request.form['name'] project = Project.query.filter( and_(Project.user_id == user_id, Project.name == name)).first() if not project: description = request.form['description'] image_tag = request.form['imageTag'] cpu = request.form['cpu'] memory = request.form['memory'] storage = request.form['storage'] is_custom = boolean(request.form['isCustom']) project = Project(user_id=user_id, name=name, description=description, image_tag=image_tag, cpu=cpu, memory=memory, storage=storage, is_custom=is_custom) db.session.add(project) time.sleep(1) # db.session.flush() # port = project.id+2000 # container_name = docker_manager.create_container(mem=memory, cpu=cpu, os_name=image_tag, open_port=port) # project.container_name = container_name # project.port = port db.session.commit() return Response('', status=201) else: return Response('', status=409) except Exception as e: print(e) return Response('', status=400)
def test_checkbox(self): assert inputs.boolean('on') is True
def test_python_bool(self): assert inputs.boolean(True) is True assert inputs.boolean(False) is False
def test_1(self): assert inputs.boolean('1') is True
def test_0(self): assert inputs.boolean('0') is False
def test_python_bool(self): assert_equal(inputs.boolean(True), True) assert_equal(inputs.boolean(False), False)
def test_false(self): assert_equal(inputs.boolean('False'), False)
def test_1(self): assert_equal(inputs.boolean('1'), True)
def test_bad_boolean(self): with pytest.raises(ValueError): inputs.boolean('blah')
def test_case(self): assert inputs.boolean('FaLSE') is False assert inputs.boolean('FaLSE') is False
def test_true(self): assert inputs.boolean('true') is True
def test_0(self): assert_equal(inputs.boolean('0'), False)
def test_true(self): assert_equal(inputs.boolean('true'), True)
def test_case(self): assert_equal(inputs.boolean('FaLSE'), False) assert_equal(inputs.boolean('FaLSE'), False)
def test_bad_boolean(self): with assert_raises(ValueError): inputs.boolean('blah')
def test_false(self): assert inputs.boolean('False') is False
def test_bad_boolean(self): with pytest.raises(ValueError): inputs.boolean('blah') with pytest.raises(ValueError): inputs.boolean(None)
def test_non_strings(self): assert inputs.boolean(0) is False assert inputs.boolean(1) is True assert inputs.boolean([]) is False