-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_starwars.py
More file actions
54 lines (36 loc) · 1.06 KB
/
Copy pathtest_starwars.py
File metadata and controls
54 lines (36 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import os
import unittest
import pytest
import starwars
@pytest.fixture()
def api_fixture():
with open("some_file.txt", "w") as fout:
fout.write("hello")
yield "some_file.txt"
os.remove("some_file.txt")
class StarWarsTest(unittest.TestCase):
def setUp(self):
self.api_key = "..."
def test_list_people_when_api_is_working_returns_star_wars_characters(self):
# Arrange
# Act
actual = starwars.list_people()
# Assert
self.assertTrue(len(actual) > 1000)
# self.assertGreater(len(actual), 1000)
def test_list_people_when_api_is_working_returns_star_wars_characters(api_fixture):
api_token = api_fixture
# Arrange
# Act
actual = starwars.list_people()
# Assert
assert len(actual) > 0
@pytest.mark.integration
def test_list_people_when_api_is_working_returns_star_wars_characters_has_this_word():
# Arrange
# Act
actual = starwars.list_people()
# Assert
for item in actual["results"]:
print(item['name'])
assert len(actual) > 1000