Beispiel #1
0
def login():
    username = input("Username: "******"Usename: ")
            trial += 1
    else:
        password = input("Password: "******"Password: "******"Invalid Credentials")
            else:
                print(
                    "\nTo View Existing todo? Enter 'View'\nTo Add New Todo? Enter 'New'\n"
                )
                userInput = input("Type here..... ")
                userInput = userInput.capitalize()

                if userInput == "View":
                    viewtask(current_user)
                elif userInput == "New":
                    Newtask(current_user)
                else:
                    wrongOption()
    def test_copy_email(self):
        '''
        Test to confirm that we are copying the email address from a found login
        '''

        self.new_user.save_login()
        Login.copy_email("0711223344")

        self.assertEqual(self.new_user.email, pyperclip.paste())
 def test_find_login_by_number(self):
     '''
     test to check if we can find a user by phone number and display information
     '''
     self.new_user.save_login()
     test_login = Login("Test", "User", "07111223344", "*****@*****.**",
                        "password")
     test_login.save_login()
     found_login = Login.find_by_number("07111223344")
     self.assertEqual(found_login.email, test_login.email)
 def test_save_multiple_login(self):
     '''
     test_save_multiple_login to check if we can save multiple login
     objects to our login_list
     '''
     self.new_user.save_login()
     test_login = Login("Test", "user", "0711223344", "*****@*****.**",
                        "password")
     test_login.save_login()
     self.assertEqual(len(Login.login_list), 2)
    def test_delete_login(self):
        '''
        test_delete_login to test if we can remove a login from our login list
        '''
        self.new_user.save_login()
        test_login = Login("Test", "user", "0711223344", "*****@*****.**",
                           "password")
        test_login.save_login()

        self.new_user.delete_login()
        self.assertEqual(len(Login.login_list), 1)
    def test_login_exists(self):
        '''
        test to check if we can return a Boolean  if we cannot find the contact.
        '''

        self.new_user.save_login()
        test_login = Login("Test", "user", "0711223344", "*****@*****.**",
                           "password")
        test_login.save_login()

        login_exists = Login.login_exist("0711223344")

        self.assertTrue(login_exists)
Beispiel #7
0
def registroexitoso():
    if request.method == 'POST':
        dni = request.form['dni']
        if dni.isdigit() != True:
            return render_template(
                'error.html',
                error='ERROR: El DNI va escrito sólo en números.',
                band='Registro')
        nom = request.form['name']
        if nom.isalpha() != True:
            nombre = nom.split()
            if nombre[0].isalpha() != True:
                return render_template(
                    'error.html',
                    error='ERROR: El nombre se escribe solo con letras.',
                    band='Registro')
            elif nombre[1].isalpha() != True:
                return render_template(
                    'error.html',
                    error='ERROR: El nombre se escribe solo con letras.',
                    band='Registro')
        conEncriptada = hashlib.md5(
            bytes(request.form['password'], encoding='utf-8'))
        cla = conEncriptada.hexdigest()
        tip = request.form['tipo']
        usuario = Usuario(DNI=dni, Nombre=nom, Clave=cla, Tipo=tip)
        db.session.add(usuario)
        db.session.commit()
        mensaje = 'Registrado con éxito!'
        if usuario.Tipo == 'Operario':
            Login(usuario)
            return render_template('vistaOperario.html', msj=mensaje)
        elif usuario.Tipo == 'Cliente':
            Login(usuario)
            return render_template('vistaCliente.html', msj=mensaje)
        else:
            return render_template(
                'error.html',
                error=
                'ERROR: El tipo de usuario no coincide con los registrados.')
    else:
        return render_template('registro.html')
Beispiel #8
0
def aplicacion():
    if request.method == 'POST':
        if not request.form['dni'] or not request.form['password']:
            return render_template(
                'error.html', error='Por favor ingrese los datos requeridos.')
        else:
            if (request.form['dni']).isdigit() != True:
                return render_template(
                    'error.html',
                    error='ERROR: El DNI va escrito sólo en números.')
            else:
                usuario_actual = Usuario.query.filter_by(
                    DNI=request.form['dni']).first()
                if usuario_actual is None:
                    return render_template(
                        'error.html',
                        error='ERROR: El DNI no esta registrado.')
                else:
                    conEncriptada = hashlib.md5(
                        bytes(request.form['password'], encoding='utf-8'))
                    clave = conEncriptada.hexdigest()
                    if usuario_actual.Clave == clave:
                        if usuario_actual.Tipo == 'Operario':
                            Login(usuario_actual)
                            return render_template('vistaOperario.html')
                        elif usuario_actual.Tipo == 'Cliente':
                            Login(usuario_actual)
                            return render_template('vistaCliente.html')
                        else:
                            return render_template(
                                'error.html',
                                error=
                                'ERROR: El tipo de usuario no coincide con los registrados.'
                            )
                    else:
                        return render_template(
                            'error.html',
                            error='ERROR: La contraseña no es valida.')
    else:
        return render_template('inicio.html')
Beispiel #9
0
def display_accounts():
    '''
    Function that returns all the saved login
    '''
    return Login.display_login()
Beispiel #10
0
def create_login(fname, lname, phone, email, password):
    '''
    Function to create a new login#
    '''
    new_login = Login(fname, lname, phone, email, password)
    return new_login
    def test_display_all_logins(self):
        '''
        method that returns a list of all login saved
        '''

        self.assertEqual(Login.display_login(), Login.login_list)
class TestLogin(unittest.TestCase):
    '''
    Test class that defines test cases for the login class behaviours.

    Args:
        unittest.TestCase: TestCase class that helps in creating test cases
    '''
    def setUp(self):
        '''
        Set up method to run before each test cases.
        '''
        self.new_user = Login("Sally", "Wanjiru", "0711223344",
                              "*****@*****.**", "1234")

    def tearDown(self):
        '''
            tearDown method that does clean up after each test case has run.
            '''
        Login.login_list = []

    def test_init(self):
        '''
        test_init test case to test if the object is initialized properly
        '''
        self.assertEqual(self.new_user.first_name, "Sally")
        self.assertEqual(self.new_user.last_name, "Wanjiru")
        self.assertEqual(self.new_user.phone_number, "0711223344")
        self.assertEqual(self.new_user.email, "*****@*****.**")
        self.assertEqual(self.new_user.password, "1234")

    def test_save_login(self):
        '''
        test_save_login test case to test if the login object is saved into
         the login list
        '''
        self.new_user.save_login()
        self.assertEqual(len(Login.login_list), 1)

    def test_save_multiple_login(self):
        '''
        test_save_multiple_login to check if we can save multiple login
        objects to our login_list
        '''
        self.new_user.save_login()
        test_login = Login("Test", "user", "0711223344", "*****@*****.**",
                           "password")
        test_login.save_login()
        self.assertEqual(len(Login.login_list), 2)

    def test_delete_login(self):
        '''
        test_delete_login to test if we can remove a login from our login list
        '''
        self.new_user.save_login()
        test_login = Login("Test", "user", "0711223344", "*****@*****.**",
                           "password")
        test_login.save_login()

        self.new_user.delete_login()
        self.assertEqual(len(Login.login_list), 1)

    def test_find_login_by_number(self):
        '''
        test to check if we can find a user by phone number and display information
        '''
        self.new_user.save_login()
        test_login = Login("Test", "User", "07111223344", "*****@*****.**",
                           "password")
        test_login.save_login()
        found_login = Login.find_by_number("07111223344")
        self.assertEqual(found_login.email, test_login.email)

    def test_login_exists(self):
        '''
        test to check if we can return a Boolean  if we cannot find the contact.
        '''

        self.new_user.save_login()
        test_login = Login("Test", "user", "0711223344", "*****@*****.**",
                           "password")
        test_login.save_login()

        login_exists = Login.login_exist("0711223344")

        self.assertTrue(login_exists)

    def test_display_all_logins(self):
        '''
        method that returns a list of all login saved
        '''

        self.assertEqual(Login.display_login(), Login.login_list)

    def test_copy_email(self):
        '''
        Test to confirm that we are copying the email address from a found login
        '''

        self.new_user.save_login()
        Login.copy_email("0711223344")

        self.assertEqual(self.new_user.email, pyperclip.paste())
 def setUp(self):
     '''
     Set up method to run before each test cases.
     '''
     self.new_user = Login("Sally", "Wanjiru", "0711223344",
                           "*****@*****.**", "1234")
Beispiel #14
0
from cardDrawer import CardBox, Card
from player import PlayerInfo
from user import Login

# User intent to login
print("------ Please Login ------ ")
verify = Login()

# -------------- Part 2 Black Jack Game ------------------
if verify:
    # Start Input
    # print("""********THIS IS A BLACK JACK GAME************
    # The Game Rule:                      """)

    gameStart = input(
        "Entry \"y\" for game Start \"n\" for game end: ").strip()

    if gameStart is "y":

        while True:
            try:
                playerNum = eval(input("Please input the player number : "))
                break
            except:
                print("Player Number have to be a number.")
        # Initialize the Card Box and Player Info
        card = CardBox(playerNum)

        while True:
            # Draw Card
            # H for hint S for stand