inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

176만명의 커뮤니티!! 함께 토론해봐요.

25-04 pointTransaction.service.ts 에러

해결됨

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

// 2. 유저의 돈 찾아오기 // const user = await this.userRepository.findOne({ // where: { id: currentUser.id }, // }); const user = await queryRunner.manager.findOne( User, { id: currentUser.id }, { lock: { mode: "pessimistic_write" } }, ); 위의 코드에서 { lock: { mode: "pessimistic_write" } }, 부분이 추가되면서 아래의 에러가 발생하고 있습니다. src/apis/pointTransaction/pointTransaction.service.ts:52:9 - error TS2554: Expected 2 arguments, but got 3. 52 { lock: { mode: "pessimistic_write" } }, 테스트를 진행해보려면 어떻게 코드 수정이 되어야 할런지요?

  • node.js
  • docker
  • tdd
  • javascript
  • rest-api
  • express
  • nodejs
  • nestjs
  • NestJS
dreaminliner 댓글 2 좋아요 0 조회수 700

port와 adapter에 대해

미해결

실전! 스프링부트 상품-주문 API 개발로 알아보는 TDD

만들때 쓰셨던 port와 adapter 패턴에 대해 좀 설명해주실수 있을까요?

  • spring-boot
  • tdd
  • api
  • pojo
Minkyu Ha 댓글 1 좋아요 1 조회수 1028

속도감..

미해결

실전! 스프링부트 상품-주문 API 개발로 알아보는 TDD

조금.. 빠른감이 있네여.. ㅠㅠㅎ

  • tdd
  • spring-boot
  • api
  • pojo
SJ 댓글 0 좋아요 12 조회수 983

aws 질문입니다.

미해결

따라하며 배우는 리액트 A-Z[19버전 반영]

안녕하세요! 혹시 강의 대로 진행하면 요금은 따로 청구되지 않는걸까요? 예전에 요금 폭탄을 맞은적이 있어 혹시 몰라 질문드립니다!ㅜㅜ

  • redux
  • react
  • tdd
  • typescript
  • next.js
  • Next.js
박진영 댓글 1 좋아요 0 조회수 596

nextjs13강의 pdf랑 소스코드 올려주실수 있나요..

미해결

따라하며 배우는 리액트 A-Z[19버전 반영]

에러 잡는부분이랑 제 코드 어딘가 잘못된거 같은데 보면서 확인하고 싶어요..

  • Next.js
  • redux
  • tdd
  • typescript
  • next.js
  • react
바퀴Roach 댓글 1 좋아요 0 조회수 784

노션과제에 대한 질문있습니다

해결됨

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

혹시 과제 풀이를 볼수 있는곳이 있을까요?

  • nodejs
  • node.js
  • tdd
  • javascript
  • docker
  • express
  • nestjs
  • rest-api
  • NestJS
gogo 댓글 1 좋아요 2 조회수 520

개인 블로그 정리

미해결

따라하며 배우는 리액트 A-Z[19버전 반영]

안녕하세요 선생님 혹시 강의를 듣고 정리한 내용을 개인 블로그에 게시해도 될까요??

  • Next.js
  • redux
  • react
  • next.js
  • tdd
  • typescript
kwonhd 댓글 1 좋아요 0 조회수 487

mini project swagger 작성 중 문제가 있어서 질문드립니다.

해결됨

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

구현은 끝나서 swagger 만들고 있는데, 계속 swagger가 보내는 json을 못찾는것같습니다. request의 body에도 아무 값이 안나오네요. 도와주세요ㅠㅠ API 코드 app.post("/users", async (req, res) => { const newUser = req.body.newUser; // 여기에서 오류가 납니다. if ((await isAuthPhone(newUser.phone)) === true) { if (checkValidationEmail(newUser.email) === true) { const og = await makeOG(newUser.prefer); console.log(og); const securePersonal = secure(newUser.personal); const user = new UserCollection({ name: newUser.name, email: newUser.email, personal: securePersonal, prefer: newUser.prefer, pwd: newUser.pwd, phone: newUser.phone, og: og, }); await user.save(); await sendWelcomeTemplateToEmail(newUser); console.log( `✅: "${user.name}" 사용자가 신규 가입에 성공했습니다.` ); res.send(user._id); } else { res.status(422).send("NotValidationEmail"); } } else { res.status(422).send("NotAuthPhone"); } }); Swagger 코드 (yaml 파일은 복붙하니까 이상하게 나와서 이미지로 첨부할게요) (+ 이미지에선 parameter의 name이 body로 되어있지만, 위 API 코드에 맞춰서 name을 newUser로 설정했었지만 같은 에러가 떴었습니다.) 에러 메시지 Swagger parameter 화면 아무리 찾아도 방법을 모르겠어서 올립니다ㅠㅠ.... 도와주세요.....

  • node.js
  • NestJS
  • express
  • tdd
  • rest-api
  • rest-api
  • docker
  • nestjs
  • javascript
  • nodejs
김정욱 댓글 1 좋아요 0 조회수 909

API전환하기 테스트에서

미해결

실전! 스프링부트 상품-주문 API 개발로 알아보는 TDD

자바 1.8만 설치되어 있어 해당 버전으로 실습중에 있는데요 ProductApiTest > 상품등록() > API 요청 final AddProductRequest request = 상품등록요청_생성(); // API 요청 final ExtractableResponse<Response> response = RestAssured.given().log().all() .contentType(MediaType.APPLICATION_JSON_VALUE) .body(request) .when() .post("/products") .then() .log().all().extract(); 위 코드에서 request는 java class object인데 json으로 type변환 없이 전송이 잘 되네요. 저 같은 경우 serialize exception이 발생하면서 테스트가 진행되지 않습니다. ㅠ 버전에 따른 차이일까요? com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class com.example.productorderservice.product.AddProductRequest and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:77) at com.fasterxml.jackson.databind.SerializerProvider.reportBadDefinition(SerializerProvider.java:1300) at com.fasterxml.jackson.databind.DatabindContext.reportBadDefinition(DatabindContext.java:400) at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:46) at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:29) at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480) at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319) at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:3160) at com.fasterxml.jackson.databind.ObjectMapper$writeValue.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:148) at io.restassured.internal.mapping.Jackson2Mapper.serialize(Jackson2Mapper.groovy:53) at io.restassured.internal.mapping.Jackson2Mapper.serialize(Jackson2Mapper.groovy) at io.restassured.mapper.ObjectMapper$serialize.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139) at io.restassured.internal.mapping.ObjectMapping.serializeWithJackson2(ObjectMapping.groovy:209) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107) at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:149) at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.callStatic(StaticMetaMethodSite.java:100) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:55) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:217) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:240) at io.restassured.internal.mapping.ObjectMapping.serialize(ObjectMapping.groovy:150) at io.restassured.internal.mapping.ObjectMapping$serialize.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) at io.restassured.internal.RequestSpecificationImpl.body(RequestSpecificationImpl.groovy:753) at com.example.productorderservice.product.ProductApiTest.상품등록(ProductApiTest.java:25) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725) at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131) at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84) at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115) at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:214) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:210) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.util.ArrayList.forEach(ArrayList.java:1259) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.util.ArrayList.forEach(ArrayList.java:1259) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:84) at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:98) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)

  • tdd
  • spring-boot
  • api
  • pojo
라피텔 댓글 1 좋아요 1 조회수 1505

커리큘럼 질문

미해결

따라하며 배우는 리액트 A-Z[19버전 반영]

안녕하세요 ! 이번에 리액트 강의를 구매했는데 커리큘럼 문제로 질문드립니다. 리액트 강의를 듣기전에 따라하며 배우는 노드 ,리액트 시리즈 기본강의=>유튜브=>영화사이트 =>챗봇 =>쇼핑몰 =>리액트 A-Z=>레딧사이트 만들기 이순서로 들을까 하는데 괜찮을까요?

  • Next.js
  • redux
  • typescript
  • react
  • next.js
  • tdd
qorwnsdn11 댓글 1 좋아요 0 조회수 256

마이너스 버튼 관련 질문

해결됨

따라하며 배우는 리액트 A-Z[19버전 반영]

안녕하세요 아래와 같이 코드를 작성할 경우, 0 으로 입력하면 에러 메세지가 보여집니다. 반대로 플러스 버튼과 동일하게 1로 하면 에러 없이 제대로 작동이 됩니다. 왜 0으로 하면 에러가 발생하는 걸까요? test('when the - button is pressed, the counter change to 0', () => { render(<App />); const buttonElement = screen.getByTestId("minus-button"); // click plus button fireEvent.click(buttonElement); // 카운터가 1에서 -1로 되서 0이 된다. const counterElement = screen.getByTestId("counter"); expect(counterElement).toHaveTextContent(0); })

  • react
  • tdd
  • redux
  • typescript
  • next.js
  • Next.js
이은혜 댓글 1 좋아요 0 조회수 326

.ast

미해결

실전! 스프링부트 상품-주문 API 개발로 알아보는 TDD

안녕하세요 강사님 테스트하실 때 .ast를 활용하여 assertThat()을 활성화하시던데 방법을 알 수 있을까요? postfix 를 활용하시는 것 같은데 어떻게 하는지 정확히 궁금합니다!

  • spring-boot
  • tdd
  • pojo
  • pojo
  • api
  • api
하하하 댓글 1 좋아요 1 조회수 646

API 테스트로 전환하기 영상에서..

미해결

실전! 스프링부트 상품-주문 API 개발로 알아보는 TDD

4:40에.. extends ApiTest 하면서 SpringBootTest 어노테이션을 지웁니다! 에러를 계속 마주치다가 간신히 찾았군요..

  • api
  • pojo
  • api
  • tdd
  • spring-boot
doxxx93 댓글 5 좋아요 18 조회수 1555

Delete 'CR' eslint 표시 없애기 공유(windows사용자)

해결됨

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

windows에서 vscode에서 typescript를 사용하시다 보면 아래와 같이 delete 'cr'이라고 계속 빨간 글씨가 떠서 눈에 거슬리는 경우가 있습니다. 해결책 : eslintrc.js파일에 가셔서 아래와 같이 rules에 추가한 후 저장해 주시면 됩니다. 긁어서 eslintrc.js파일의 하단의 rules에 추가해 주세요 'prettier/prettier': [ 'error', { endOfLine: 'auto', }, ],

  • docker
  • node.js
  • rest-api
  • nodejs
  • express
  • javascript
  • tdd
  • nestjs
  • NestJS
똑같이썼는데안돼 댓글 1 좋아요 3 조회수 1121

Nextjs gh-pages 배포

미해결

따라하며 배우는 리액트 A-Z[19버전 반영]

안녕하세요~ Nextjs 강의 부분까지 수업을 마쳤습니다. 선생님께서 nextjs & typescript로 제작하신 블로그 부분을 gh-pages를 사용해서 배포해보려는데 디렉토링 부분이나 렌더되는 부분이 기존의 react 부분과 달라 질문 드립니다. baseurl 설정은 어디서 해야할까요? deploy 방식은 동일한 건가요? 혹시 위의 질문 말고도 다른점이 있을까요?

  • Next.js
  • tdd
  • typescript
  • redux
  • next.js
  • react
soon 댓글 1 좋아요 0 조회수 1973

포스트 목록 페이지 수정하기2 중에서 막히는 부분이 있습니다. (미분류)

미해결

Do It! 장고+부트스트랩: 파이썬 웹개발의 정석

안녕하세요 선생님. 강의 열심히 듣고 있습니다^^; 다름이 아니라 아래와 같이 미분류 카운트가 입력되지 않아 오류가 발생하는 부분때문에 계속 찾아보았으나, 답답한 마음에 질문글을 남깁니다. 우선 카테고리 분류에서 프로그래밍, 문화&예술 까진 카운트가 잘 입력됩니다. 그렇지만 "미분류" 부분은 계속 () 으로 표시됩니다. 분명 미분류 부분이 존재함에도 불구하고, 카운트가 되지 않는 건 무엇이 잘못되었는지 도저히 알기가 어렵습니다. 혹시 확인이 가능할까요?^^;; test.py 실행시 오류화면 미분류() 카운트 부분을 주석처리하면 테스트는 잘 완료됩니다. 총 4개의 페이지에 대한 코드를 올려봅니다. test.py base.html views.py post_list.html test.py from django.test import TestCase, Client from django.contrib.auth.models import User from bs4 import BeautifulSoup from .models import Post, Category # Create your tests here. class TestView(TestCase): def setUp(self): self.client = Client() # 방문하는 사람의 브라우저다 Client() self.user_trump = User.objects.create_user( username='trump', password='somepassword' ) self.user_obama = User.objects.create_user( username='obama', password='somepassword' ) self.category_programming = Category.objects.create( name='programming', slug='programming' ) self.category_music = Category.objects.create( name='music', slug='music' ) self.post_001 = Post.objects.create( title='첫 번째 포스트입니다.', content='Hello, world, we are the world', category=self.category_programming, author=self.user_trump, ) self.post_002 = Post.objects.create( title='두 번째 포스트입니다.', content='1등이 전부는 아니잖아요. 저는 개발을 좋아할겁니다.', category=self.category_music, author=self.user_obama, ) self.post_003 = Post.objects.create( title='세 번째 포스트입니다.', content='Category 가 없을 수도 있죠.', author=self.user_obama, ) def navbar_test(self, soup): navbar = soup.nav self.assertIn('Blog', navbar.text) self.assertIn('about_me', navbar.text) logo_btn = navbar.find('a', text='Do it Django') self.assertEqual(logo_btn.attrs['href'], '/') home_btn = navbar.find('a', text='Home') self.assertEqual(home_btn.attrs['href'], '/') blog_btn = navbar.find('a', text='Blog') self.assertEqual(blog_btn.attrs['href'], '/blog/') about_me_btn = navbar.find('a', text='about_me') self.assertEqual(about_me_btn.attrs['href'], '/about_me/') def category_card_test(self, soup): categories_card = soup.find('div', id='categories-card') self.assertIn('Categories', categories_card.text) self.assertIn( f'{self.category_programming} ({self.category_programming.post_set.count()})', categories_card.text ) self.assertIn( f'{self.category_music} ({self.category_music.post_set.count()})', categories_card.text ) self.assertIn( f'미분류 ({Post.objects.filter(category=None).count()})', categories_card.text ) def test_post_list_with_posts(self): self.assertEqual(Post.objects.count(), 3) # 1.1 포스트 목록 페이지 (post_list)를 연다. response = self.client.get('/blog/') # 1.2 정상적으로 페이지가 로드된다. self.assertEqual(response.status_code, 200) # 1.3 페이지 타이틀에 Blog 라는 문구가 있다. soup = BeautifulSoup(response.content, 'html.parser') self.assertIn('Blog', soup.title.text) self.navbar_test(soup) self.category_card_test(soup) # 3-2. 포스트 목록 페이지를 새로 고침 했을 때, response = self.client.get('/blog/') soup = BeautifulSoup(response.content, 'html.parser') # 3-3. 메인영역에 포스트 2개의 타이틀이 존재한다. main_area = soup.find('div', id='main-area') self.assertNotIn('아직 게시물이 없습니다.', main_area.text) post_001_card = main_area.find('div', id='post-1') self.assertIn(self.post_001.title, post_001_card.text) self.assertIn(self.post_001.category.name, post_001_card.text) post_002_card = main_area.find('div', id='post-2') self.assertIn(self.post_002.title, post_002_card.text) self.assertIn(self.post_002.category.name, post_002_card.text) post_003_card = main_area.find('div', id='post-3') self.assertIn(self.post_003.title, post_003_card.text) self.assertIn('미분류', post_003_card.text) self.assertIn(self.post_001.author.username.upper(), main_area.text) self.assertIn(self.post_002.author.username.upper(), main_area.text) self.assertIn(self.post_003.author.username.upper(), main_area.text) def test_post_list_without_post(self): Post.objects.all().delete() self.assertEqual(Post.objects.count(), 0) response = self.client.get('/blog/') self.assertEqual(response.status_code, 200) soup = BeautifulSoup(response.content, 'html.parser') self.navbar_test(soup) self.assertIn('Blog', soup.title.text) # 2-2. 메인영역에 "아직 게시물이 없습니다." 라는 문구가 나온다. main_area = soup.find('div', id='main-area') self.assertIn('아직 게시물이 없습니다.', main_area.text) def test_post_detail(self): self.assertEqual(Post.objects.count(), 3) # 1.2 그 포스트의 url은 '/blog/1/' 이다. self.assertEqual(self.post_001.get_absolute_url(), '/blog/1/') #.2. 첫 번째 포스트의 상세 페이지 테스트 # 2-1. 첫 번째 포스트의 url로 접근하면 정상적으로 작동한다. (status code : 200). response = self.client.get(self.post_001.get_absolute_url()) self.assertEqual(response.status_code, 200) soup = BeautifulSoup(response.content, 'html.parser') # # 2-2. 포스트 목록 페이지와 똑같은 네비게이션 바가 있다. self.navbar_test(soup) # 2-3. 첫 번째 포스트의 제목이 웹 브라우저 탭 타이틀에 들어있다. self.assertIn(self.post_001.title, soup.title.text) # 2-4. 첫 번째 포스트의 제목이 포스트 영역에 있다. main_area = soup.find('div', id='main-area') post_area = main_area.find('div', id='post-area') self.assertIn(self.post_001.title, post_area.text) # # 2-5. 첫 번째 포스트의 작성자(author)가 포스트 영역에 있다. (아직 구현할 수 없음) self.assertIn(self.user_trump.username.upper(), post_area.text) # # 2-6. 첫 번째 포스트의 내용(content)이 포스트 영역에 있다. self.assertIn(self.post_001.content, post_area.text) base.html <!DOCTYPE html> {% load static %} <html> <head> <title>{% block head_title %} Blog | 하도영 웹사이트 {% endblock %}</title> <link href="{% static 'blog/bootstrap/bootstrap.min.css' %}" rel="stylesheet" type="text/css"> <!-- <link href="./practice.css" rel="stylesheet" type="text/css"> --> <!-- 주석처리 키 ctrl + / --> <script src="https://kit.fontawesome.com/c1d4d1ab30.js" crossorigin="anonymous"></script> </head> <body> {% include 'blog/navbar.html' %} <div class="container"> <!-- 블로그 리스트 페이지 만들기 강의 5:04 blog 글자 부분 container 클래스에 의해 do it django 와 같은 간격으로 맞춰짐 --> <!-- 이 아래는 9:3, 좁을때는 8:4 로 나눌거임 --> <div class="row my-3"> <div class="col-md-8 col-lg-9", id="main-area"> {% block main_area %} {% endblock %} </div> <div class="col-md-4 col-lg-3"> <!-- Search widget--> <div class="card mb-4"> <div class="card-header">Search</div> <div class="card-body"> <div class="input-group"> <input class="form-control" type="text" placeholder="Enter search term..." aria-label="Enter search term..." aria-describedby="button-search" /> <button class="btn btn-primary" id="button-search" type="button">Go!</button> </div> </div> <!-- Categories widget--> <div class="card mb-4", id="categories-card"> <div class="card-header">Categories</div> <div class="card-body"> <div class="row"> <ul> {% for category in categories %} <li> <a href="#!">{{ category.name }} ({{ category.post_set.count }})</a> </li> {% endfor %} <!-- views.py 에 def get_context_data(self, **kwargs): 를 참고한다. --> <li> <a href="#!">미분류 ({{ no_category_post.count }})</a> </li> </ul> </div> </div> </div> </div> </div> </div> {% include 'blog/footer.html' %} <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-Fy6S3B9q64WdZWQUiU+q4/2Lc9npb8tCaSX9FK7E8HnRr0Jz8D6OP9dO5Vg3Q9ct" crossorigin="anonymous"></script> </body> </html> views.py from django.shortcuts import render from django.views.generic import ListView, DetailView from .models import Post, Category class PostList(ListView): model = Post # template_name = 'blog/post_list.html' ordering = '-pk' def get_context_data(self, **kwargs): context = super(PostList, self).get_context_data() context['categories'] = Category.objects.all() context['no_category_post.count'] = Post.objects.filter(category=None).count() # 미분류인 애들이 몇개인지 확인한다. filter기능을 이용해 none 인 애를 확인하고 count() 에 숫자를 담아 no_category_post.count에 넣어준다. return context class PostDetail(DetailView): model = Post template_name = 'blog/post_detail.html' # def index(request): # posts = Post.objects.all().order_by('-pk') # # pk는 순서대로 -pk 는 역순으로 최신 쓰레드가 위로 나오도록 조회 # return render( # request, # 'blog/index.html', # { # 'posts': posts, # } # ) # def single_post_page(request, pk): # post = Post.objects.get(pk=pk) # # return render( # request, # 'blog/single_page.html', # { # 'post': post, # } # ) post_list.html {% extends 'blog/base.html' %} {% block main_area %} <h1> Blog </h1> {% if post_list.exists %} {% for p in post_list %} <!-- Blog Post --> <div class="card mb-4", id="post-{{ p.id }}"> {% if p.head_image %} <img class="card-img-top" src="{{ p.head_image.url}}" alt="{{ p.title }}" /> {% else %} <img class="card-img-top" src="https://picsum.photos/seed/{{ p.id }}/600/200" alt="{{ p.title }}" /> {% endif %} <div class="card-body"> <!-- <div class="small text-muted">January 1, 2022</div>--> {% if p.category %} <span class="badge badge-secondary float-right">{{ p.category }} </span> {% else %} <span class="badge badge-secondary float-right">미분류</span> {% endif %} <h2 class="card-title h4">{{ p.title }}</h2> {% if p.hook_text %} <h5 class="text-muted">{{ p.hook_text }}</h5> {% endif %} <p class="card-text">{{ p.content | truncatewords:45 }}</p> <a href="{{ p.get_absolute_url }}" class="btn btn-primary">Read more →</a> </div> <div class="card-footer text-muted"> Posted on {{ p.created_at }} by <a href="#">{{ p.author | upper }}</a> </div> </div> {% endfor %} {% else %} <h1> 아직 게시물이 없습니다. </h1> {% endif %} <!-- Pagination--> <ul class="pagination justify-content-center my-4"> <li class="page-item"> <a class="page-link" href="#!">&larr; Older</a> </li> <li class="page-item disabled"> <a class="page-link" href="#!">Newer &rarr;</a> </li> </ul> {% endblock %}

  • html/css
  • django
  • HTML/CSS
  • docker
  • tdd
  • javascript
  • python
  • bootstrap
  • aws
몽상가 댓글 1 좋아요 0 조회수 488

재밌게 잘 보고있습니다.

미해결

실전! 스프링부트 상품-주문 API 개발로 알아보는 TDD

1배속이지만 다른강의 2배속 느낌이네요.. 이게 실무인가 싶기도 하고 ㅎ_ㅎ 특정 메서드를 만들면, throw new 이후 나오는 건 따로 설정을 하신거려나요?

  • pojo
  • api
  • tdd
  • api
  • spring-boot
doxxx93 댓글 1 좋아요 0 조회수 997

조언 부탁드립니다. mini-project

해결됨

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

현재 puppeteer-crawling해서 스타벅스메뉴와 이미지는 잘 긁어 왔는데요. 자꾸 MongoDB에 저장되어 있는 img를 불러올 때 에러가 발생하는데, 성공하신 분 있나요? 스키마에서 이미지 형식을 Buffer 했습니다. import mongoose from "mongoose"; const StarbucksSchema = new mongoose.Schema({ name: String, img: Buffer, }); export const Starbucks = mongoose.model("Starbucks", StarbucksSchema); //이미지 URL로부터 이미지 다운로드 if (!fs.existsSync("img_crawling")) { fs.mkdirSync("img_crawling"); } let fileName = `img_crawling/${menuName}.jpg`; request(menuImage).pipe(fs.createWriteStream(fileName)); console.log(`이미지 ${fileName} 저장 완료`); 저는 fs모듈과 request모듈을 추가로 사용했는데, 이미지의 주소를 MongDB에 저장하고, 이미지는 별도의 폴더에 저장되게 만들었습니다. 질문 요약 1. MongDB에 이미지 저장할 때 fs라이브러리와 request라이브러리를 사용하게 맞나요? 2. 이미지를 저장은 잘 됐는데, 화면에 뿌려 줄려고 하는데 자꾸 에러가 나요. 3.몽고DB에 접속해서 이미지 주소를 가져와서, 그 주소를 기반으로 뿌려줘야 되는지 4.아니면 몽고DB에 접속해서 그 메타주소(?)를 기반으로 현재 컴퓨터에 저장된 이미지를 화면에 뿌려줘야 하는지 자꾸 구글링하면 몽고DB에 이미지파일을 직접적으로 저장하는 것은 DB에 무리를 일으킨다. 그래서 어떠한 라이브러리를 사용해서 DB에는 메타주소(?)만을 저장하고, 이미지파일을 별도의 localStorage에 저장한다. 또한 이미지를 그냥 가져(load) 올 수 없어서 인코딩을 해줘야 한다. 뭔 말인지 모르겠어요 ㅠ.ㅠ

  • node.js
  • express
  • javascript
  • tdd
  • nodejs
  • rest-api
  • docker
  • rest-api
  • nestjs
  • NestJS
똑같이썼는데안돼 댓글 1 좋아요 1 조회수 444

테스트 코드 작성할 때 이미 작성했던 코드 어떻게 나오게 해서 선택하시나요?

해결됨

실전! 스프링부트 상품-주문 API 개발로 알아보는 TDD

테스트 코드 Assert.isTrue 작성할 때 이미 작성했던 코드가 나와서 선택만 해주시던데 어떻게 나오게 해서 선택하시나요? 플러그인이나 어떤 옵션이 있으신가요?

  • spring-boot
  • tdd
  • spring-boot
  • pojo
  • api
  • pojo
  • api
아라레 댓글 1 좋아요 0 조회수 1167

맥용, prettier 단축키

해결됨

따라하며 배우는 리액트 A-Z[19버전 반영]

안녕하세요 vscode에서 Prettier 설치를 했는데 shift + option + f 단축키가 먹히질 않네요ㅠ 왜 그런 건지 알 수 있을까요..?

  • redux
  • react
  • tdd
  • typescript
  • next.js
  • Next.js
이은혜 댓글 1 좋아요 0 조회수 548

인기 태그

인프런 TOP Writers

주간 인기글