# Path: bashhub/bashhub_setup.py
# def handle_system_information(username, password, attempts=0):
# 
#     mac = get_mac_address()
#     system = rest_client.get_system_information(mac)
#     system_name = None
#     # Register a new System if this one isn't recognized
#     if system is None:
#         hostname = socket.gethostname()
#         name_input = input("What do you want to call this system? " +
#                                "For example Home, File Server, ect. [%s]: " %
#                                hostname)
# 
#         name = name_input or hostname
#         system_name = rest_client.register_system(RegisterSystem(
#             name, mac, hostname, __version__))
#         if system_name:
#             print("Registered a new system " + name)
#         else:
#             if attempts < 3:
#                 print("Looks like registering your system failed. Lets retry.")
#                 return handle_system_information(username, password, attempts + 1)
#             else:
#                 return (None, None)
# 
#     # Login with this new system
#     access_token = rest_client.login_user(LoginForm(username, password, mac))
# 
#     if access_token is None:
#         print("Failed to login with system.")
#         return (None, None)
# 
#     # If this system is already registered
#     if system is not None:
#         system_name = system.name
#         print("Welcome back! Looks like this box is already registered as " +
#               system.name + ".")
# 
#     return (access_token, system_name)
# 
# Path: bashhub/bashhub_setup.py
# def query_yes_no(question, default="yes"):
# def get_new_user_information():
# def get_user_information_and_login(username=None, password=None, attempts=0):
# def get_mac_address():
# def update_system_info():
# def handle_system_information(username, password, attempts=0):
# def main():


import uuid
import socket
import unittest
from bashhub.bashhub_setup import  handle_system_information
from bashhub import bashhub_setup
    from unittest.mock import patch, MagicMock
    from mock import patch, MagicMock


try:
except ImportError:

def randomnode():
	return 1 << 40
def getnode():
	return 1


class BashhubSetupTest(unittest.TestCase):

	def test_get_mac_addresss(self):
		# Assuming uuid works
		test_mac = bashhub_setup.get_mac_address()
		assert str(uuid.getnode()) == test_mac

		# with uuid returning random
		uuid.getnode = randomnode

# Path: bashhub/bashhub_setup.py
# def handle_system_information(username, password, attempts=0):
# 
#     mac = get_mac_address()
#     system = rest_client.get_system_information(mac)
#     system_name = None
#     # Register a new System if this one isn't recognized
#     if system is None:
#         hostname = socket.gethostname()
#         name_input = input("What do you want to call this system? " +
#                                "For example Home, File Server, ect. [%s]: " %
#                                hostname)
# 
#         name = name_input or hostname
#         system_name = rest_client.register_system(RegisterSystem(
#             name, mac, hostname, __version__))
#         if system_name:
#             print("Registered a new system " + name)
#         else:
#             if attempts < 3:
#                 print("Looks like registering your system failed. Lets retry.")
#                 return handle_system_information(username, password, attempts + 1)
#             else:
#                 return (None, None)
# 
#     # Login with this new system
#     access_token = rest_client.login_user(LoginForm(username, password, mac))
# 
#     if access_token is None:
#         print("Failed to login with system.")
#         return (None, None)
# 
#     # If this system is already registered
#     if system is not None:
#         system_name = system.name
#         print("Welcome back! Looks like this box is already registered as " +
#               system.name + ".")
# 
#     return (access_token, system_name)
# 
# Path: bashhub/bashhub_setup.py
# def query_yes_no(question, default="yes"):
# def get_new_user_information():
# def get_user_information_and_login(username=None, password=None, attempts=0):
# def get_mac_address():
# def update_system_info():
# def handle_system_information(username, password, attempts=0):
# def main():


# Path: tests/test_bashhub_setup.py
import uuid
import socket
import unittest
from bashhub.bashhub_setup import  handle_system_information
from bashhub import bashhub_setup
    from unittest.mock import patch, MagicMock
    from mock import patch, MagicMock



try:
except ImportError:

def randomnode():
	return 1 << 40
def getnode():
	return 1


class BashhubSetupTest(unittest.TestCase):

	def test_get_mac_addresss(self):
		# Assuming uuid works
		test_mac = bashhub_setup.get_mac_address()
		assert str(uuid.getnode()) == test_mac

		# with uuid returning random
		uuid.getnode = randomnode

		hostname_mac = bashhub_setup.get_mac_address()