petter2025 commited on
Commit
590ac0a
·
1 Parent(s): da70460

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. tests/test_routes_onchain.py +10 -4
tests/test_routes_onchain.py CHANGED
@@ -27,16 +27,22 @@ class TestPersistRationale:
27
  assert resp.json() == {"status": "recorded", "rationale_hash": VALID_HASH}
28
 
29
  def test_posting_the_same_hash_and_text_again_is_a_no_op(self, client):
30
- first = _post(client)
 
 
 
 
 
31
  assert first.status_code == 201
32
- second = _post(client)
33
  assert second.status_code == 200
34
  assert second.json()["status"] == "already_recorded"
35
 
36
  def test_the_same_hash_with_different_text_is_refused(self, client):
37
- first = _post(client)
 
38
  assert first.status_code == 201
39
- second = _post(client, rationale="a different reason entirely")
40
  assert second.status_code == 409
41
 
42
  def test_a_malformed_hash_is_rejected(self, client):
 
27
  assert resp.json() == {"status": "recorded", "rationale_hash": VALID_HASH}
28
 
29
  def test_posting_the_same_hash_and_text_again_is_a_no_op(self, client):
30
+ # A hash of its own -- the `client` fixture is session-scoped against
31
+ # a real, persistent Postgres with no truncation between tests, so
32
+ # reusing VALID_HASH here would collide with whichever other test in
33
+ # this file claims it first.
34
+ hash_ = "0x" + "22" * 32
35
+ first = _post(client, rationale_hash=hash_)
36
  assert first.status_code == 201
37
+ second = _post(client, rationale_hash=hash_)
38
  assert second.status_code == 200
39
  assert second.json()["status"] == "already_recorded"
40
 
41
  def test_the_same_hash_with_different_text_is_refused(self, client):
42
+ hash_ = "0x" + "33" * 32
43
+ first = _post(client, rationale_hash=hash_)
44
  assert first.status_code == 201
45
+ second = _post(client, rationale_hash=hash_, rationale="a different reason entirely")
46
  assert second.status_code == 409
47
 
48
  def test_a_malformed_hash_is_rejected(self, client):