Пример #1
0
    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)
Пример #2
0
 def test_checkbox(self):
     assert inputs.boolean('on') is True
Пример #3
0
 def test_python_bool(self):
     assert inputs.boolean(True) is True
     assert inputs.boolean(False) is False
Пример #4
0
 def test_1(self):
     assert inputs.boolean('1') is True
Пример #5
0
 def test_0(self):
     assert inputs.boolean('0') is False
Пример #6
0
 def test_python_bool(self):
     assert_equal(inputs.boolean(True), True)
     assert_equal(inputs.boolean(False), False)
Пример #7
0
 def test_false(self):
     assert_equal(inputs.boolean('False'), False)
Пример #8
0
 def test_1(self):
     assert_equal(inputs.boolean('1'), True)
Пример #9
0
 def test_python_bool(self):
     assert inputs.boolean(True) is True
     assert inputs.boolean(False) is False
Пример #10
0
 def test_bad_boolean(self):
     with pytest.raises(ValueError):
         inputs.boolean('blah')
Пример #11
0
 def test_case(self):
     assert inputs.boolean('FaLSE') is False
     assert inputs.boolean('FaLSE') is False
Пример #12
0
 def test_1(self):
     assert inputs.boolean('1') is True
Пример #13
0
 def test_true(self):
     assert inputs.boolean('true') is True
Пример #14
0
 def test_0(self):
     assert inputs.boolean('0') is False
Пример #15
0
 def test_0(self):
     assert_equal(inputs.boolean('0'), False)
Пример #16
0
 def test_true(self):
     assert_equal(inputs.boolean('true'), True)
Пример #17
0
 def test_true(self):
     assert_equal(inputs.boolean('true'), True)
Пример #18
0
 def test_case(self):
     assert_equal(inputs.boolean('FaLSE'), False)
     assert_equal(inputs.boolean('FaLSE'), False)
Пример #19
0
 def test_1(self):
     assert_equal(inputs.boolean('1'), True)
Пример #20
0
 def test_bad_boolean(self):
     with assert_raises(ValueError):
         inputs.boolean('blah')
Пример #21
0
 def test_case(self):
     assert_equal(inputs.boolean('FaLSE'), False)
     assert_equal(inputs.boolean('FaLSE'), False)
Пример #22
0
 def test_false(self):
     assert inputs.boolean('False') is False
Пример #23
0
 def test_python_bool(self):
     assert_equal(inputs.boolean(True), True)
     assert_equal(inputs.boolean(False), False)
Пример #24
0
 def test_true(self):
     assert inputs.boolean('true') is True
Пример #25
0
 def test_bad_boolean(self):
     with assert_raises(ValueError):
         inputs.boolean('blah')
Пример #26
0
 def test_case(self):
     assert inputs.boolean('FaLSE') is False
     assert inputs.boolean('FaLSE') is False
Пример #27
0
 def test_false(self):
     assert_equal(inputs.boolean('False'), False)
Пример #28
0
 def test_bad_boolean(self):
     with pytest.raises(ValueError):
         inputs.boolean('blah')
     with pytest.raises(ValueError):
         inputs.boolean(None)
Пример #29
0
 def test_0(self):
     assert_equal(inputs.boolean('0'), False)
Пример #30
0
 def test_non_strings(self):
     assert inputs.boolean(0) is False
     assert inputs.boolean(1) is True
     assert inputs.boolean([]) is False
Пример #31
0
 def test_false(self):
     assert inputs.boolean('False') is False