Skip to content

Commit 3572b34

Browse files
committed
add test
1 parent e768f17 commit 3572b34

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

tests/integration/test_disksaver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_disk_saver_nowrite(tmpdir, mockbin_request_url):
2020
fname = str(tmpdir.join("synopsis.yaml"))
2121
with vcr.use_cassette(fname) as cass:
2222
urlopen(mockbin_request_url).read()
23-
assert cass.play_count == 0
23+
assert cass.play_count == 1
2424
last_mod = os.path.getmtime(fname)
2525

2626
with vcr.use_cassette(fname) as cass:
@@ -41,7 +41,7 @@ def test_disk_saver_write(tmpdir, mockbin_request_url):
4141
fname = str(tmpdir.join("synopsis.yaml"))
4242
with vcr.use_cassette(fname) as cass:
4343
urlopen(mockbin_request_url).read()
44-
assert cass.play_count == 0
44+
assert cass.play_count == 1
4545
last_mod = os.path.getmtime(fname)
4646

4747
# Make sure at least 1 second passes, otherwise sometimes
@@ -51,7 +51,7 @@ def test_disk_saver_write(tmpdir, mockbin_request_url):
5151
with vcr.use_cassette(fname, record_mode=vcr.mode.ANY) as cass:
5252
urlopen(mockbin_request_url).read()
5353
urlopen(mockbin_request_url + "/get").read()
54-
assert cass.play_count == 1
54+
assert cass.play_count == 2
5555
assert cass.dirty
5656
last_mod2 = os.path.getmtime(fname)
5757

tests/unit/test_cassettes.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def test_cassette_append():
5555
a.append("foo", "bar")
5656
assert a.requests == ["foo"]
5757
assert a.responses == ["bar"]
58+
assert a.play_count == 1
5859

5960

6061
def test_cassette_len():
@@ -72,6 +73,7 @@ def _mock_requests_match(request1, request2, matchers):
7273
def test_cassette_contains():
7374
a = Cassette("test")
7475
a.append("foo", "bar")
76+
a.rewind()
7577
assert "foo" in a
7678

7779

@@ -93,6 +95,7 @@ def test_cassette_get_missing_response():
9395
def test_cassette_cant_read_same_request_twice():
9496
a = Cassette("test")
9597
a.append("foo", "bar")
98+
a.rewind()
9699
a.play_response("foo")
97100
with pytest.raises(UnhandledHTTPRequestError):
98101
a.play_response("foo")
@@ -143,13 +146,15 @@ def function():
143146
def test_cassette_not_all_played():
144147
a = Cassette("test")
145148
a.append("foo", "bar")
149+
a.rewind()
146150
assert not a.all_played
147151

148152

149153
@mock.patch("vcr.cassette.requests_match", _mock_requests_match)
150154
def test_cassette_all_played():
151155
a = Cassette("test")
152156
a.append("foo", "bar")
157+
a.rewind()
153158
a.play_response("foo")
154159
assert a.all_played
155160

@@ -159,6 +164,7 @@ def test_cassette_allow_playback_repeats():
159164
a = Cassette("test", allow_playback_repeats=True)
160165
a.append("foo", "bar")
161166
a.append("other", "resp")
167+
a.rewind()
162168
for _ in range(10):
163169
assert a.play_response("foo") == "bar"
164170
assert a.play_count == 10
@@ -183,6 +189,7 @@ def test_cassette_allow_playback_repeats():
183189
def test_cassette_rewound():
184190
a = Cassette("test")
185191
a.append("foo", "bar")
192+
a.rewind()
186193
a.play_response("foo")
187194
assert a.all_played
188195

tests/unit/test_unittest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def _get_cassette_library_dir(self):
180180
test = run_testcase(MyTest)[0][0]
181181
assert b"illustrative examples" in test.response
182182
assert len(test.cassette.requests) == 1
183-
assert test.cassette.play_count == 0
183+
assert test.cassette.play_count == 1
184184

185185
# Second test reads from cassette.
186186

0 commit comments

Comments
 (0)