add: register test
This commit is contained in:
		
							
								
								
									
										31
									
								
								src/tests.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/tests.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,31 @@
 | 
			
		||||
import Client
 | 
			
		||||
from urls import *
 | 
			
		||||
 | 
			
		||||
from uuid import uuid4
 | 
			
		||||
 | 
			
		||||
def test(value, expected_value, title, description):
 | 
			
		||||
    if (value == expected_value):
 | 
			
		||||
        print(title, "[OK]")
 | 
			
		||||
        return
 | 
			
		||||
    print (title, "[ERROR]")
 | 
			
		||||
    print ("expected", expected_value, ", got", value)
 | 
			
		||||
    if not description is None:
 | 
			
		||||
        print (description)
 | 
			
		||||
 | 
			
		||||
def test_accounts_register():
 | 
			
		||||
    username = uuid4()
 | 
			
		||||
    password = uuid4()
 | 
			
		||||
    
 | 
			
		||||
    client = Client.Client("http://0.0.0.0:8000/")
 | 
			
		||||
 | 
			
		||||
    print ("REGISTER")
 | 
			
		||||
 | 
			
		||||
    test(client.register(username, password), b'ok: user added', 'normal register', None)
 | 
			
		||||
 | 
			
		||||
    print()
 | 
			
		||||
 | 
			
		||||
def tests():
 | 
			
		||||
    test_accounts_register()
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
    tests()
 | 
			
		||||
		Reference in New Issue
	
	Block a user