Ejemplo n.º 1
0
    def test_spinner_getters_setters(self):
        """Test spinner getters and setters.
        """
        spinner = Halo()
        self.assertEqual(spinner.text, '')
        self.assertIsNone(spinner.text_color, None)
        self.assertEqual(spinner.color, 'cyan')
        self.assertIsNone(spinner.spinner_id)

        spinner.spinner = 'dots12'
        spinner.text = 'bar'
        spinner.text_color = 'red'
        spinner.color = 'red'

        self.assertEqual(spinner.text, 'bar')
        self.assertEqual(spinner.text_color, 'red')
        self.assertEqual(spinner.color, 'red')

        if is_supported():
            self.assertEqual(spinner.spinner, Spinners['dots12'].value)
        else:
            self.assertEqual(spinner.spinner, default_spinner)

        spinner.spinner = 'dots11'
        if is_supported():
            self.assertEqual(spinner.spinner, Spinners['dots11'].value)
        else:
            self.assertEqual(spinner.spinner, default_spinner)

        spinner.spinner = 'foo_bar'
        self.assertEqual(spinner.spinner, default_spinner)

        # Color is None
        spinner.text_color = None
        spinner.color = None
        spinner.start()
        spinner.stop()

        self.assertIsNone(spinner.text_color)
        self.assertIsNone(spinner.color)
Ejemplo n.º 2
0
from uuid import uuid4
from halo import Halo
import json
spinner = Halo(text_color="blue")
spinner.start()
try:
    spinner.info(text="initializing test")
    #User test
    SessionID = str(uuid4())
    spinner.info(text="Creating User => ")
    user = User(name="usertest",
                email="*****@*****.**",
                password="******",
                SessionID=SessionID)
    user.add_user()
    spinner.text_color = "green"
    spinner.succeed(text="passed")
    print('+++++++++++++++++++++++++')
    spinner.text_color = "blue"
    spinner.info(text="Recovering User =>")
    document = user.find_user_by_SessionID(SessionID)
    document['_id'] = str(document['_id'])
    print(json.dumps(document, indent=4, sort_keys=True))
    spinner.text_color = "green"
    spinner.succeed(text="passed")
    print('+++++++++++++++++++++++++')
    spinner.text_color = "blue"
    spinner.info(text="Loging User =>")
    print(user.login(SessionID))
    spinner.text_color = "green"
    spinner.succeed(text="passed")
Ejemplo n.º 3
0
# -*- coding: utf-8 -*-
"""Example for doge spinner ;)
"""
from __future__ import unicode_literals
import os
import sys
import time

sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from halo import Halo

spinner = Halo(text='Such Spins', text_color= 'cyan', color='green', spinner='dots')

try:
    spinner.start()
    time.sleep(2)
    spinner.text = 'Much Colors'
    spinner.color = 'magenta'
    spinner.text_color = 'green'
    time.sleep(2)
    spinner.text = 'Very emojis'
    spinner.spinner = 'hearts'
    spinner.text_color = 'magenta'
    time.sleep(2)
    spinner.stop_and_persist(symbol='🦄'.encode('utf-8'), text='Wow!')
except (KeyboardInterrupt, SystemExit):
    spinner.stop()