-
Notifications
You must be signed in to change notification settings - Fork 0
Remove records in Airatable for test #42
base: main
Are you sure you want to change the base?
Remove records in Airatable for test #42
Conversation
なぜ動名詞? |
失礼しました。修正しました。 |
Codecov Report
@@ Coverage Diff @@
## main #42 +/- ##
==========================================
+ Coverage 79.88% 80.00% +0.11%
==========================================
Files 5 5
Lines 169 175 +6
Branches 19 19
==========================================
+ Hits 135 140 +5
Misses 26 26
- Partials 8 9 +1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
細かいですが、修正をお願いします。
tests/test_airtable_client.py
Outdated
@@ -43,10 +43,18 @@ def test_register(airtable_client): | |||
"""Testing whether a dictionary with the proper field names can be registered correctly.""" | |||
|
|||
assert airtable_client.register_asset(registerable_asset) | |||
assert airtable_client.delete_asset("title", registerable_asset.title) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
このテストの名前だけど、test_register_asset_and_delete_asset_success()
とか、対応しているメソッドを使ってちゃんとした方が良い
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なるほどですね。承知しました。修正します。
airtable_client.py
Outdated
""" | ||
|
||
try: | ||
return self.airtable_client.delete_by_field(field_name, field_value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これって何が返ってくるのか。Docstringに追記してほしいです
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
失礼しました。追記しておきます。
tests/test_airtable_client.py
Outdated
@@ -43,10 +43,18 @@ def test_register(airtable_client): | |||
"""Testing whether a dictionary with the proper field names can be registered correctly.""" | |||
|
|||
assert airtable_client.register_asset(registerable_asset) | |||
assert airtable_client.delete_asset("title", registerable_asset.title) | |||
|
|||
|
|||
def test_register_non_existent_key(airtable_client): | |||
"""Testing an instance of the Airtable data class is an argument.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この英文、どういう意味?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Airtableデータクラスが引数になっているかのテスト、という意味でしたが間違えているので修正します。
Co-authored-by: Tomoya KASHIMADA <[email protected]>
Co-authored-by: Tomoya KASHIMADA <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
airtable_client.py
Outdated
@@ -36,3 +36,22 @@ def register_asset(self, asset: Asset): | |||
except TypeError as te: | |||
app.logger.error(te) | |||
raise te | |||
|
|||
def delete_asset(self, field_name: str, field_value: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
このメソッドの存在意義がわからない。
引数でもらったものをそのまま self.airtable_client.delete_by_field(field_name, field_value)
するだけなら、要らないじゃん。
そもそも Airtable field names.
にどんなものがあるか覚えてないと使えないのも意味がわからない。
これなら、 delete_asset_by_title(self, value: str) -> Dict:
で return self.airtable_client.delete_by_field("title", value)
したほうがいいじゃん。
なんで共同開発者に無駄な負担かけさせるの?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そうですね。
Airtable
のfield name
を意識させずに書くべきでした。
title
はメソッドに持たせます。
無駄な負担をかけてしまいました。
修正します。
tests/test_airtable_client.py
Outdated
"""Testing whether a dictionary with the proper field names can be registered correctly.""" | ||
|
||
assert airtable_client.register_asset(registerable_asset) | ||
assert airtable_client.delete_asset("title", registerable_asset.title) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
テストで追加したいものを消したいんだよね?
テストで追加したものと同名のものを消したいんじゃないよね。
なんで airtable_client.register_asset()
の返り値からID拾って airtable_client.delete(id)
しないの?
そっちの方が楽だし素直じゃん。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そうですね。
こちらもその通りです。
こちらはIDで直接消せるように修正します。
tests/test_airtable_client.py
Outdated
assert airtable_client.register_asset(registerable_asset) | ||
register_asset = airtable_client.register_asset(registerable_asset) | ||
assert register_asset | ||
assert airtable_client.airtable_client.delete(register_asset["id"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete
できたことも assert
する?悪いことはないか。
あ、わかった。
このテストの名前は、
test_register_asset_success
だけでよくて、
test_delete_asset_by_title_success
というテストが別に必要なんじゃない?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
わかりました。ちょっとやってみます。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
でもここは本当はIDで消したいですよね。
タイトルで削除、というのは仮に今後PlayStation 5 (CFI-1000A01)
を登録したいときに困っちゃう可能性がありますね。
やっぱりIDで消したい気もします。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
とりあえずは修正しました。
tests/test_airtable_client.py
Outdated
|
||
with pytest.raises(TypeError): | ||
airtable_client.register_asset({"test": "test"}) | ||
|
||
|
||
def test_delete_asset_failure(airtable_client): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
で、こちらのテストの名前が、test_delete_asset_by_title_failure
になって対になるじゃない?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そうですね、やってみます。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ダブルクォートとシングルクォートの混用もいいかげん修正してください。
@@ -87,6 +88,7 @@ def test_POST_register_airtable_success(test_client): | |||
test_client.post("/registration", data={"asin": "B07XB5WX89"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
たとえば、このファイル中に B07XB5WX89
が3回も書かれている、つまりDRYじゃない。
@@ -87,6 +88,7 @@ def test_POST_register_airtable_success(test_client): | |||
test_client.post("/registration", data={"asin": "B07XB5WX89"}) | |||
response = test_client.post("/register_airtable", data=imd, follow_redirects=True) | |||
assert b"Registration completed!" in response.data | |||
AirtableClient().delete_asset_by_title("テンマクデザイン サーカス TC DX") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ん?だからなんで登録したテストデータのIDで消さないの?
Describe the PR
To close #25 .
Added the ability to remove items registered in the test.
Screenshots
Detail of the change
airtable_client.py
Create delete_asset method:
test_main.py, test_airtable_client.py
Add the code to remove the registered items.
Anticipated impacts
None.
To reproduce
Steps to check the behavior:
Python
environmentpython3 -m venv venv
source venv/bin/activate
pytest -vv .
Additional context
None.