This commit is contained in:
		
							
								
								
									
										6
									
								
								consumer_api/tests/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								consumer_api/tests/__init__.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
			
		||||
import os
 | 
			
		||||
 | 
			
		||||
# Setup environment variables for testing
 | 
			
		||||
os.environ["INITIAL_SERVERS"] = "192.168.111.22"
 | 
			
		||||
os.environ["LOCAL_UUID"] = "d8b2e5e2-f675-4194-9324-af58e4b70c54"
 | 
			
		||||
os.environ["REDIS_URL"] = "redis://192.168.111.121/0"
 | 
			
		||||
							
								
								
									
										29
									
								
								consumer_api/tests/consumers_view_test.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								consumer_api/tests/consumers_view_test.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,29 @@
 | 
			
		||||
import pytest
 | 
			
		||||
 | 
			
		||||
from flask import current_app
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@pytest.fixture
 | 
			
		||||
def client():
 | 
			
		||||
    current_app.config["TESTING"] = True
 | 
			
		||||
 | 
			
		||||
    with current_app.test_client() as client:
 | 
			
		||||
        yield client
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_access_denied(client):
 | 
			
		||||
    r = client.get('/api/user')
 | 
			
		||||
 | 
			
		||||
    assert r.status_code == 401
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_access_denied2(client):
 | 
			
		||||
    r = client.get('/api/user', headers = { "Authorization": "invalidkey" })
 | 
			
		||||
 | 
			
		||||
    assert r.status_code == 401
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_empty_database(client):
 | 
			
		||||
    r = client.get('/api/user', headers = { "Authorization": "testkey" })
 | 
			
		||||
 | 
			
		||||
    assert len(r.json) == 0
 | 
			
		||||
		Reference in New Issue
	
	Block a user