def test_login( self ): url_login = reverse( 'user:user-login', kwargs={ 'format': 'json' } ) url_register = reverse( 'user:user-list', kwargs={ 'format': 'json' } ) email = sp_random.generate_email() username = sp_random.generate_string() password = sp_random.generate_string() response = self.client.post( url_register, { 'email': email, 'username': username, 'password': password, }, format='json' ) self.assertEqual( response.status_code, status.HTTP_201_CREATED, "El status code deberia de ser 201 en lugar de {} :: detail {}"\ .format( response.status_code, response.data ) ) response = self.client.post( url_login, { 'username': username, 'password': password, }, format='json' ) self.assertEqual( response.status_code, status.HTTP_200_OK, "El status code deberia de ser 200 en lugar de {} :: detail {}"\ .format( response.status_code, response.data ) ) self.assertNotEqual( response.data[ 'token' ], None, "El login no regreso el token" )
def create_superuser_test( self, username=None, email=None, password=None ): """ Crea un super usuairo para las pruebas """ if not username: username = sp_random.generate_string() if not email: email = sp_random.generate_email() if not password: password = '******' user = self.create_superuser( username, email, password ) return user
def test_array_of_dict( self ): string_test = sp_random.generate_string( 100 ) self.assertTrue( isinstance( string_test, str ) ) self.assertEqual( len( string_test ), 100 )