From f1fc378cc3416e79d5fa811068bcc239894a9f0d Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Fri, 22 Oct 2021 15:34:16 +0100 Subject: [PATCH] Added new fields to the question details object --- docs/GraphqlQuestionDetail.md | 5 + leetcode/models/graphql_question_detail.py | 132 +++++++++++++++++- ...est_graphql_request_get_question_detail.py | 14 ++ 3 files changed, 150 insertions(+), 1 deletion(-) diff --git a/docs/GraphqlQuestionDetail.md b/docs/GraphqlQuestionDetail.md index 705c35e..c91d96f 100644 --- a/docs/GraphqlQuestionDetail.md +++ b/docs/GraphqlQuestionDetail.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **bound_topic_id** | **str** | | [optional] **title** | **str** | | [optional] **frequency** | **float** | | [optional] +**freq_bar** | **float** | | [optional] **content** | **str** | | [optional] **translated_title** | **str** | | [optional] **translated_content** | **str** | | [optional] @@ -16,6 +17,7 @@ Name | Type | Description | Notes **likes** | **int** | | [optional] **dislikes** | **int** | | [optional] **is_liked** | **bool** | | [optional] +**is_favor** | **bool** | | [optional] **similar_questions** | **str** | | [optional] **contributors** | [**list[GraphqlQuestionContributor]**](GraphqlQuestionContributor.md) | | [optional] **lang_to_valid_playground** | **str** | | [optional] @@ -23,8 +25,11 @@ Name | Type | Description | Notes **company_tag_stats** | **str** | | [optional] **code_snippets** | [**list[GraphqlQuestionCodeSnippet]**](GraphqlQuestionCodeSnippet.md) | | [optional] **stats** | **str** | | [optional] +**ac_rate** | **float** | | [optional] **hints** | **list[str]** | | [optional] **solution** | [**AnyOfGraphqlQuestionDetailSolution**](AnyOfGraphqlQuestionDetailSolution.md) | | [optional] +**has_solution** | **bool** | | [optional] +**has_video_solution** | **bool** | | [optional] **status** | **str** | | [optional] **sample_test_case** | **str** | | [optional] **judger_available** | **bool** | | [optional] diff --git a/leetcode/models/graphql_question_detail.py b/leetcode/models/graphql_question_detail.py index 2e39762..b699239 100644 --- a/leetcode/models/graphql_question_detail.py +++ b/leetcode/models/graphql_question_detail.py @@ -33,6 +33,7 @@ class GraphqlQuestionDetail(object): 'bound_topic_id': 'str', 'title': 'str', 'frequency': 'float', + 'freq_bar': 'float', 'content': 'str', 'translated_title': 'str', 'translated_content': 'str', @@ -41,6 +42,7 @@ class GraphqlQuestionDetail(object): 'likes': 'int', 'dislikes': 'int', 'is_liked': 'bool', + 'is_favor': 'bool', 'similar_questions': 'str', 'contributors': 'list[GraphqlQuestionContributor]', 'lang_to_valid_playground': 'str', @@ -48,8 +50,11 @@ class GraphqlQuestionDetail(object): 'company_tag_stats': 'str', 'code_snippets': 'list[GraphqlQuestionCodeSnippet]', 'stats': 'str', + 'ac_rate': 'float', 'hints': 'list[str]', 'solution': 'AnyOfGraphqlQuestionDetailSolution', + 'has_solution': 'bool', + 'has_video_solution': 'bool', 'status': 'str', 'sample_test_case': 'str', 'judger_available': 'bool', @@ -68,6 +73,7 @@ class GraphqlQuestionDetail(object): 'bound_topic_id': 'boundTopicId', 'title': 'title', 'frequency': 'frequency', + 'freq_bar': 'freqBar', 'content': 'content', 'translated_title': 'translatedTitle', 'translated_content': 'translatedContent', @@ -76,6 +82,7 @@ class GraphqlQuestionDetail(object): 'likes': 'likes', 'dislikes': 'dislikes', 'is_liked': 'isLiked', + 'is_favor': 'isFavor', 'similar_questions': 'similarQuestions', 'contributors': 'contributors', 'lang_to_valid_playground': 'langToValidPlayground', @@ -83,8 +90,11 @@ class GraphqlQuestionDetail(object): 'company_tag_stats': 'companyTagStats', 'code_snippets': 'codeSnippets', 'stats': 'stats', + 'ac_rate': 'acRate', 'hints': 'hints', 'solution': 'solution', + 'has_solution': 'hasSolution', + 'has_video_solution': 'hasVideoSolution', 'status': 'status', 'sample_test_case': 'sampleTestCase', 'judger_available': 'judgerAvailable', @@ -97,13 +107,14 @@ class GraphqlQuestionDetail(object): 'code_definition': 'codeDefinition' } - def __init__(self, question_id=None, question_frontend_id=None, bound_topic_id=None, title=None, frequency=None, content=None, translated_title=None, translated_content=None, is_paid_only=None, difficulty=None, likes=None, dislikes=None, is_liked=None, similar_questions=None, contributors=None, lang_to_valid_playground=None, topic_tags=None, company_tag_stats=None, code_snippets=None, stats=None, hints=None, solution=None, status=None, sample_test_case=None, judger_available=None, judge_type=None, mysql_schemas=None, enable_run_code=None, enable_test_mode=None, env_info=None, meta_data=None, code_definition=None): # noqa: E501 + def __init__(self, question_id=None, question_frontend_id=None, bound_topic_id=None, title=None, frequency=None, freq_bar=None, content=None, translated_title=None, translated_content=None, is_paid_only=None, difficulty=None, likes=None, dislikes=None, is_liked=None, is_favor=None, similar_questions=None, contributors=None, lang_to_valid_playground=None, topic_tags=None, company_tag_stats=None, code_snippets=None, stats=None, ac_rate=None, hints=None, solution=None, has_solution=None, has_video_solution=None, status=None, sample_test_case=None, judger_available=None, judge_type=None, mysql_schemas=None, enable_run_code=None, enable_test_mode=None, env_info=None, meta_data=None, code_definition=None): # noqa: E501 """GraphqlQuestionDetail - a model defined in Swagger""" # noqa: E501 self._question_id = None self._question_frontend_id = None self._bound_topic_id = None self._title = None self._frequency = None + self._freq_bar = None self._content = None self._translated_title = None self._translated_content = None @@ -112,6 +123,7 @@ def __init__(self, question_id=None, question_frontend_id=None, bound_topic_id=N self._likes = None self._dislikes = None self._is_liked = None + self._is_favor = None self._similar_questions = None self._contributors = None self._lang_to_valid_playground = None @@ -119,8 +131,11 @@ def __init__(self, question_id=None, question_frontend_id=None, bound_topic_id=N self._company_tag_stats = None self._code_snippets = None self._stats = None + self._ac_rate = None self._hints = None self._solution = None + self._has_solution = None + self._has_video_solution = None self._status = None self._sample_test_case = None self._judger_available = None @@ -142,6 +157,8 @@ def __init__(self, question_id=None, question_frontend_id=None, bound_topic_id=N self.title = title if frequency is not None: self.frequency = frequency + if freq_bar is not None: + self.freq_bar = freq_bar if content is not None: self.content = content if translated_title is not None: @@ -158,6 +175,8 @@ def __init__(self, question_id=None, question_frontend_id=None, bound_topic_id=N self.dislikes = dislikes if is_liked is not None: self.is_liked = is_liked + if is_favor is not None: + self.is_favor = is_favor if similar_questions is not None: self.similar_questions = similar_questions if contributors is not None: @@ -172,10 +191,16 @@ def __init__(self, question_id=None, question_frontend_id=None, bound_topic_id=N self.code_snippets = code_snippets if stats is not None: self.stats = stats + if ac_rate is not None: + self.ac_rate = ac_rate if hints is not None: self.hints = hints if solution is not None: self.solution = solution + if has_solution is not None: + self.has_solution = has_solution + if has_video_solution is not None: + self.has_video_solution = has_video_solution if status is not None: self.status = status if sample_test_case is not None: @@ -302,6 +327,27 @@ def frequency(self, frequency): self._frequency = frequency + @property + def freq_bar(self): + """Gets the freq_bar of this GraphqlQuestionDetail. # noqa: E501 + + + :return: The freq_bar of this GraphqlQuestionDetail. # noqa: E501 + :rtype: float + """ + return self._freq_bar + + @freq_bar.setter + def freq_bar(self, freq_bar): + """Sets the freq_bar of this GraphqlQuestionDetail. + + + :param freq_bar: The freq_bar of this GraphqlQuestionDetail. # noqa: E501 + :type: float + """ + + self._freq_bar = freq_bar + @property def content(self): """Gets the content of this GraphqlQuestionDetail. # noqa: E501 @@ -470,6 +516,27 @@ def is_liked(self, is_liked): self._is_liked = is_liked + @property + def is_favor(self): + """Gets the is_favor of this GraphqlQuestionDetail. # noqa: E501 + + + :return: The is_favor of this GraphqlQuestionDetail. # noqa: E501 + :rtype: bool + """ + return self._is_favor + + @is_favor.setter + def is_favor(self, is_favor): + """Sets the is_favor of this GraphqlQuestionDetail. + + + :param is_favor: The is_favor of this GraphqlQuestionDetail. # noqa: E501 + :type: bool + """ + + self._is_favor = is_favor + @property def similar_questions(self): """Gets the similar_questions of this GraphqlQuestionDetail. # noqa: E501 @@ -617,6 +684,27 @@ def stats(self, stats): self._stats = stats + @property + def ac_rate(self): + """Gets the ac_rate of this GraphqlQuestionDetail. # noqa: E501 + + + :return: The ac_rate of this GraphqlQuestionDetail. # noqa: E501 + :rtype: float + """ + return self._ac_rate + + @ac_rate.setter + def ac_rate(self, ac_rate): + """Sets the ac_rate of this GraphqlQuestionDetail. + + + :param ac_rate: The ac_rate of this GraphqlQuestionDetail. # noqa: E501 + :type: float + """ + + self._ac_rate = ac_rate + @property def hints(self): """Gets the hints of this GraphqlQuestionDetail. # noqa: E501 @@ -659,6 +747,48 @@ def solution(self, solution): self._solution = solution + @property + def has_solution(self): + """Gets the has_solution of this GraphqlQuestionDetail. # noqa: E501 + + + :return: The has_solution of this GraphqlQuestionDetail. # noqa: E501 + :rtype: bool + """ + return self._has_solution + + @has_solution.setter + def has_solution(self, has_solution): + """Sets the has_solution of this GraphqlQuestionDetail. + + + :param has_solution: The has_solution of this GraphqlQuestionDetail. # noqa: E501 + :type: bool + """ + + self._has_solution = has_solution + + @property + def has_video_solution(self): + """Gets the has_video_solution of this GraphqlQuestionDetail. # noqa: E501 + + + :return: The has_video_solution of this GraphqlQuestionDetail. # noqa: E501 + :rtype: bool + """ + return self._has_video_solution + + @has_video_solution.setter + def has_video_solution(self, has_video_solution): + """Sets the has_video_solution of this GraphqlQuestionDetail. + + + :param has_video_solution: The has_video_solution of this GraphqlQuestionDetail. # noqa: E501 + :type: bool + """ + + self._has_video_solution = has_video_solution + @property def status(self): """Gets the status of this GraphqlQuestionDetail. # noqa: E501 diff --git a/test/test_graphql_request_get_question_detail.py b/test/test_graphql_request_get_question_detail.py index 34873d8..dd7c5af 100644 --- a/test/test_graphql_request_get_question_detail.py +++ b/test/test_graphql_request_get_question_detail.py @@ -14,6 +14,8 @@ def test_request(self) -> None: questionFrontendId boundTopicId title + frequency + freqBar content translatedTitle isPaidOnly @@ -21,6 +23,7 @@ def test_request(self) -> None: likes dislikes isLiked + isFavor similarQuestions contributors { username @@ -43,6 +46,7 @@ def test_request(self) -> None: __typename } stats + acRate codeDefinition hints solution { @@ -50,6 +54,8 @@ def test_request(self) -> None: canSeeDetail __typename } + hasSolution + hasVideoSolution status sampleTestCase enableRunCode @@ -83,6 +89,8 @@ def test_request(self) -> None: assert question.question_frontend_id == "1" assert question.bound_topic_id is None assert question.title == "Two Sum" + assert question.frequency == 0.0 + assert question.freq_bar > 0 assert len(question.content) > 10 assert question.translated_title is None assert question.is_paid_only is False @@ -90,6 +98,7 @@ def test_request(self) -> None: assert question.likes > 0 assert question.dislikes > 0 assert question.is_liked is None + assert question.is_favor in (True, False) assert json.loads(question.similar_questions)[0]["difficulty"] in ( "Easy", "Medium", @@ -126,6 +135,8 @@ def test_request(self) -> None: assert int(stats["totalAcceptedRaw"]) > 0 assert int(stats["totalSubmissionRaw"]) > 0 + assert question.ac_rate > 0 + code_definition = json.loads(question.code_definition)[0] assert len(code_definition["value"]) > 0 @@ -144,6 +155,9 @@ def test_request(self) -> None: assert solution["canSeeDetail"] in (True, False) assert int(solution["id"]) > 0 + assert question.has_solution in (True, False) + assert question.has_video_solution in (True, False) + assert question.status in ("ac", "not_started", "tried") assert len(question.sample_test_case) > 0