def test_create_plant_invalid_species(test_plants_data, test_cu_plant_data, test_value): test_cu_plant_data['species'] = test_value with pytest.raises(ApiException) as excinfo: create_plant(test_plants_data, test_cu_plant_data) assert 'species' in excinfo.value.message assert excinfo.value.status == 400
def test_create_plant_invalid_garden_friendly(test_plants_data, test_cu_plant_data, test_value): test_cu_plant_data['garden_friendly'] = test_value with pytest.raises(ApiException) as excinfo: create_plant(test_plants_data, test_cu_plant_data) assert 'garden_friendly' in excinfo.value.message assert excinfo.value.status == 400
def test_create_plant_missing_family(test_plants_data, test_cu_plant_data): del test_cu_plant_data['family'] with pytest.raises(ApiException) as excinfo: create_plant(test_plants_data, test_cu_plant_data) assert 'family' in excinfo.value.message assert excinfo.value.status == 400
def test_create_plant(test_plants_data, test_cu_plant_data): plant = create_plant(test_plants_data, test_cu_plant_data) assert len(test_plants_data) == 4 assert plant['plant_id'] == 4 del plant['plant_id'] assert plant == test_cu_plant_data
def post(self): validate_body(request.json) return ApiResult(data_logic.create_plant(plants_data, request.json), 201)