forked from paktek123/testdriven-loadbalancer-tdd-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_models.py
More file actions
34 lines (23 loc) · 785 Bytes
/
test_models.py
File metadata and controls
34 lines (23 loc) · 785 Bytes
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
import pytest
import responses
from models import Server
@pytest.fixture
def server():
server = Server('localhost:5555')
yield server
@responses.activate
def test_server_healthcheck_pass(server):
responses.add(responses.GET, 'http://localhost:5555/healthcheck', status=200)
server.healthcheck_and_update_status()
assert server.healthy
@responses.activate
def test_server_healthcheck_fail(server):
responses.add(responses.GET, 'http://localhost:5555/healthcheck', status=500)
server.healthcheck_and_update_status()
assert not server.healthy
def test_server_equal(server):
another = Server('localhost:5554')
assert server != another
def test_server_not_equal(server):
another = Server('localhost:5555')
assert server == another