Esempio n. 1
0
    def setUp(self):
        self.managers = [
            Manager("Bill", "Gates", 1000, 10),
            Manager("Mark", "Zuckerberg", 900, 3),
            Manager("Sergey", "Brin", 900, 1),
            Manager("Steve", "Jobs", 800, 8)
        ]
        self.depart = Department(self.managers)

        self.employees = [
            Designer("tom",
                     "taylor",
                     800,
                     10,
                     self.managers[0],
                     effect_coeff=0.5),
            Developer("dev1", "java", 500, 2, self.managers[0]),
            Developer("dev2", "js", 500, 6, self.managers[0]),
            Designer("armani",
                     "jeans",
                     1200,
                     3,
                     self.managers[1],
                     effect_coeff=1),
            Designer("dolce", "gabbana", 800, 6, self.managers[1]),
            Developer("dev3", "basic", 500, 0.5, self.managers[1]),
            Developer("dev4", "python", 500, 6)
        ]
        self.employees_salary_expected = [730, 500, 1100]
        self.managers_salary_expected = [1870]
        self.wrong_list = ["vasya", "petya", "kolya", 15, True]
Esempio n. 2
0
def main():
    dev_1 = Developer('John', 'Smith', 50000, "Python")
    dev_2 = Developer('Test', 'User', 50000, "Java")

    mgr_1 = Manager('Guy', 'Kustin', 90000, [dev_1])

    mgr_1.print_emps()

    print("using __add__ : {}".format(
        dev_1 + dev_2))  # uses the __add__ method in Employee

    print(mgr_1.pay_per_months(2))
Esempio n. 3
0
def main():

    managers = [
        Manager("Bill", "Gates", 1000, 10),
        Manager("Mark", "Zuckerberg", 900, 3),
        Manager("Sergey", "Brin", 900, 1),
        Manager("Steve", "Jobs", 800, 8)
        ]

    employees = [
        Designer("tom", "taylor", 800, 10, managers[0], effect_coeff=0.5),
        Developer("dev1", "java", 500, 2, managers[0]),
        Developer ("dev2", "js", 500, 6, managers[0]),

        Designer("armani", "jeans", 1200, 3, managers[1], effect_coeff=1),
        Designer("dolce", "gabbana", 800, 6, managers[1]),
        Developer ("dev3", "basic", 500, 0.5, managers[1]),

        Developer ("dev4", "python", 500, 6)
        ]

    depart = Department(managers)

    wrong_list = ["vasya","petya","kolya", 15, True]

    depart.give_salary()

    depart.add_team_members(managers[-1], employees[-1::]) # employees[-1].set_manager(managers[-1])
    depart.give_salary()

    depart.add_team_members(managers[-2], employees[-1::])  #employees[-1].set_manager(managers[-2])
    depart.give_salary()

    depart.add_team_members(managers[1], employees[-1::]) # employees[-1].set_manager()
    depart.give_salary()

    depart.add_team_members(managers[0], employees)
    depart.give_salary()

    depart.add_team_members(managers[-1], [])
    depart.give_salary()

    depart.add_team_members(managers[-1], wrong_list)
    depart.give_salary()

    wrong_list.extend(employees[-1::])
    depart.add_team_members(managers[-1], wrong_list)
    depart.give_salary()

    depart.add_team_members(managers[-1], managers[:-1:])
    depart.give_salary()
Esempio n. 4
0
 def random_employee(employee_type):
     if employee_type == 'developer':
         return Developer(**Developer.random_attrs())
     if employee_type == 'sales':
         return Sales(**Sales.random_attrs())
     if employee_type == 'project_manager':
         return ProjectManager(**ProjectManager.random_attrs())
     if employee_type == 'support':
         return Support(**Support.random_attrs())
     err_msg = (
         '{} employee type is not supported.\n'.format(type),
         'Allowed values are: \'developer\', \'project_manager\', \'sales\' or \'support\'',
     )
     raise ValueError(err_msg)
Esempio n. 5
0
def openInput(name):
    # Open text file and store bag of lines
    file_contents = open(input_files[name], 'r')
    with file_contents as fc:
        content = fc.readlines()

    # Parse first line into a Map object
    width, height = content[0].split(' ')
    office = Office(name, width, height, content[1:int(height) + 1])

    num_devs = int(content[int(height) + 1])
    developers = [
        Developer(line)
        for line in content[int(height) + 2:int(height) + 2 + num_devs]
    ]
    developers = developers.sort(
        key=lambda developers:
        (developers.ci, developers.bi, developers.num_s),
        reverse=True)

    manager_start = int(height) + 1 + num_devs + 1
    num_managers = int(content[manager_start])

    managers = [Manager(line) for line in content[manager_start + 1:]]
    managers = managers.sort(key=lambda managers: (managers.ci, managers.bi),
                             reverse=True)

    # Return both Map and Customer objects
    return office, developers, managers
Esempio n. 6
0
 def developer(self, instance):
     home_screen = APP.root.current_screen
     from developer import Developer
     self.developer = Developer()
     APP.root.add_widget(self.developer)
     APP.root.current = "developer"
     APP.root.remove_widget(home_screen)
Esempio n. 7
0
class Home(QMainWindow):

    def __init__(self):
        """Inicializador de la clase Home."""  
        QMainWindow.__init__(self)
        self.ui = Ui_Home()
        self.ui.setupUi(self)  
        """Coneccion de senales."""       
        self.ui.btnJugar    .clicked.connect(self.onBtnJugarClicked)
        self.ui.btnDesarrolladores.clicked.connect(self.onBtnDesarrolladoresClicked)
        self.ui.btnEstadistica.clicked.connect(self.onBtnEstadisticaClicked)

        """Inicializacion de MainWindow.""" 
        self.mainWindow = MainWindow()
        self.mainWindow.setHomeWindow(self)
        self.developersWindow = Developer()
        self.developersWindow.setHomeWindow(self)
        self.highscoresWindow = Estadistica()
        self.highscoresWindow.setHomeWindow(self)
        
    def onBtnJugarClicked(self):
        """Funcion que permite seleccionar un nivel de juego""" 
        """Nivel facil 36 celdas vacias.""" 
        if self.ui.radioButtonFacil.isChecked():
            difficulty = 1
            """Nivel intermedio 36+9 = 45 celdas vacias."""
        elif self.ui.radioButtonIntermedio.isChecked():
            difficulty = 2
            """Nivel dificil 36+9+9 = 63 celdas vacias."""
        elif self.ui.radioButtonDificil.isChecked():
            difficulty = 3
        else:
            difficulty = 1           
        self.setVisible(False)
        self.mainWindow.show()
        self.mainWindow.setDifficulty(difficulty)
        self.mainWindow.newGame(self.ui.txtNombre.text())

    def onBtnDesarrolladoresClicked(self):   
        """Funcion que permite mostrar la ventana de desarrolladores"""        
        self.developersWindow.show()
        self.close()
              
    def onBtnEstadisticaClicked(self):
        """Funcion que permite mostrar la ventana de estadisticas"""     
        self.highscoresWindow.show()
        self.setVisible(False)
Esempio n. 8
0
class TestDeveloper(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        print('\nsetupClass')

    @classmethod
    def tearDownClass(self):
        print('\nteardownClass')

    def setUp(self):

        self.dev_1 = Developer('Radek', 'Warowny', 5000, 'Python')
        self.dev_2 = Developer('Tina', 'Reid', 8000, 'Java')

    def tearDown(self):
        pass

    def test_email(self):
        print('\nemail_test')

        self.assertEqual(self.dev_1.email, '*****@*****.**')

        self.dev_1.first = 'Connor'

        self.assertEqual(self.dev_1.email, '*****@*****.**')

    def test_info(self):
        print('\ninfo_test')

        self.assertEqual(
            self.dev_1.info(),
            'Radek Warowny is using Python programming language.')

        self.dev_1.prog_lang = 'C#'

        self.assertEqual(self.dev_1.info(),
                         'Radek Warowny is using C# programming language.')

    def test_apply_raise(self):
        print('\napply_raise_test')

        self.assertEqual(self.dev_1.pay, 5000)

        self.dev_1.apply_raise()

        self.assertEqual(self.dev_1.pay, 5500)
Esempio n. 9
0
def main():
    manager_one = Manager("Georgi", 4000)
    manager_two = Manager("Tsvetomir", 5000)
    manager_three = Manager("Spasimir The Boss", 7000)
    developer_one = Developer("Atanas", 2500)
    developer_two = Developer("Ivan", 3000)
    developer_three = Developer("Petar", 3500)
    developer_four = Developer("Anastas", 4000)
    developer_five = Developer("Evgeni", 4000)

    manager_one.add(developer_one)
    manager_one.add(developer_two)
    manager_two.add(developer_three)
    manager_two.add(developer_four)
    manager_three.add(developer_five)
    manager_three.add(manager_one)
    manager_three.add(manager_two)

    manager_three.print_data()
Esempio n. 10
0
 def do_add_developer(self, args):
     if len(args.split(" ")) < 3:
         print("Specify name, age and oss projects")
     else:
         print("Adding new developer to our list...")
         devs.append(
             Developer(
                 args.split(" ")[0],
                 args.split(" ")[1],
                 args.split(" ")[2]))
         self.do_show_list(devs)
Esempio n. 11
0
    def __init__(self):
        """Inicializador de la clase Home."""  
        QMainWindow.__init__(self)
        self.ui = Ui_Home()
        self.ui.setupUi(self)  
        """Coneccion de senales."""       
        self.ui.btnJugar    .clicked.connect(self.onBtnJugarClicked)
        self.ui.btnDesarrolladores.clicked.connect(self.onBtnDesarrolladoresClicked)
        self.ui.btnEstadistica.clicked.connect(self.onBtnEstadisticaClicked)

        """Inicializacion de MainWindow.""" 
        self.mainWindow = MainWindow()
        self.mainWindow.setHomeWindow(self)
        self.developersWindow = Developer()
        self.developersWindow.setHomeWindow(self)
        self.highscoresWindow = Estadistica()
        self.highscoresWindow.setHomeWindow(self)
Esempio n. 12
0
class TestDeveloper(unittest.TestCase):

    def setUp(self):
        self.dev1 = Developer('tim')
        self.dev2 = Developer('tom')
        self.dev3 = Developer('tina')

    def test_equality(self):
        self.assertEqual(self.dev1, self.dev2)
        self.dev1.change_karma(self.dev2, 5)
        self.dev2.change_karma(self.dev1, 5)
        self.assertEqual(self.dev1, self.dev2)

    def test_gt_lt(self):
        self.dev1.change_karma(self.dev2, 1)
        self.assertGreater(self.dev1, self.dev2)
        self.dev2.change_karma(self.dev1, 2)
        self.assertGreater(self.dev2, self.dev1)
        self.dev3.change_karma(self.dev2, 3)
        self.assertLess(self.dev2, self.dev3)

    def test_typecheck(self):
        with self.assertRaises(ValueError):
            self.dev1.change_karma(self.dev2, 'string')
        with self.assertRaises(ValueError):
            self.dev1.change_karma(self.dev1, 5)

    def test_repr_str(self):
        expected = "Developer('tim')"
        self.assertEqual(repr(self.dev1), expected)
        self.dev1.change_karma(self.dev3, 5)
        expected = 'Developer tim with 5 karma'
        self.assertEqual(str(self.dev1), expected)

    def test_karma_change(self):
        self.dev1.change_karma(self.dev2, 5)
        self.assertEqual(self.dev1.karma, 5)
        self.dev1.change_karma(self.dev2, -3)
        self.assertEqual(self.dev1.karma, 2)
        self.dev1.change_karma(self.dev2, -4)
        self.assertEqual(self.dev1.karma, -2)
        logmsg = "tim's karma changed to -2"
        self.assertEqual(self.dev1.log[-1], logmsg)

    def test_karma_boundaries(self):
        self.dev1.change_karma(self.dev3, MAX_POINTS+1)
        self.assertEqual(self.dev1.karma, 5)
        self.assertIn('generous', self.dev1.log[-2])
        self.dev1.change_karma(self.dev3, -MAX_POINTS-1)
        self.assertEqual(self.dev1.karma, 0)
        self.assertIn('mean', self.dev1.log[-2])

    def test_greatest_fan_and_call(self):
        self.dev1.change_karma(self.dev2, 1)
        self.dev1.change_karma(self.dev3, 4)
        self.dev1.change_karma(self.dev2, 4)
        self.assertEqual(self.dev1.greatest_fan, 'tom')
        self.dev1.change_karma(self.dev3, 2)
        self.assertEqual(self.dev1.greatest_fan, 'tina')
        self.assertEqual(self.dev1.karma, 11)
        report = self.dev1()
        self.assertRegex(report[2], r'^tina\s+6$')
        self.assertRegex(report[3], r'^tom\s+5$')
Esempio n. 13
0
 def develop_details(self):
     self.app = Developer(self.root, self.id)
Esempio n. 14
0
def test_should_always_grab_a_positive_number_of_maxibons( name, mtg ):
    developer = Developer( name, mtg )
    assert developer.maxibonsToGrab() >= 0
Esempio n. 15
0
    def setUp(self):

        self.dev_1 = Developer('Radek', 'Warowny', 5000, 'Python')
        self.dev_2 = Developer('Tina', 'Reid', 8000, 'Java')
Esempio n. 16
0
            self.employees = employees

    def add_empl(self, emp):
        if emp not in self.employees:
            self.employees.append(emp)

    def remove_emp(self, emp):
        if emp in self.employees:
            self.employees.remove(emp)

    def print_emps(self):
        for emp in self.employees:
            print('-->', emp.full_name)


if __name__ == "__main__":
    dev_1 = Developer("John", "Doe", 80000, "Python")
    dev_2 = Developer("Jane", "Doe", 150000, "JavaScript")
    mgr_1 = Manager("Josefine", "Lopez", 200000, [dev_1])
    print(mgr_1.email)
    print("==================")
    mgr_1.add_empl(dev_2)
    mgr_1.print_emps()
    print("==================")
    mgr_1.remove_emp(dev_1)
    mgr_1.print_emps()
    print(isinstance(mgr_1, Employee))
    print(isinstance(dev_1, Employee))
    print(isinstance(mgr_1, Developer))
    print(issubclass(Manager, Employee))
Esempio n. 17
0
def test_assign_the_name_of_the_developer_in_construction( name ):
    developer = Developer( name )
    assert developer.name == name
 def mutate(self, scrum_team) -> None:
     developer = Developer(self.__dict__["name"])
     for skill in self.__dict__["skills"]:
         developer.learn(skill)
     scrum_team._developers.append(developer)
Esempio n. 19
0
        if employees is None:
            self._employees = []
        else:
            self._employees = employees

    def addEmp(self, emp):
        if emp not in self._employees:
            self._employees.append(emp)

    def remEmp(self, emp):
        if emp in self._employees:
            self._employees.remove(emp)

    def displayEmp(self):
        for emp in self._employees:
            print("<-- ", emp.fullName())


dev_1 = Developer("Amin", "Balad", "15000", "Facebook", "PHP")
dev_2 = Developer("Arab", "Dahir", "80000", "Facebook", "C++")
mn1 = Manager('Hassan', 'Mohamed', '88000', 'Facebook', [dev_1])
mn1.addEmp(dev_2)
mn1.remEmp(dev_1)

if __name__ == "__main__":
    pass
    print(mn1.displayEmp())
    # We can take advantage with built in functions -isinstance and issubclass
    print(isinstance(Manager, Developer))
    print(issubclass(Manager, Employee))
 def developer_data(self):
     self.new_window = Toplevel(self.root)
     self.app = Developer(self.new_window)
Esempio n. 21
0
print('Employee 2 New Raise Amount: ', emp_2.raise_amount)
emp_2.apply_raise()
print('Employee 2 New Pay: ', emp_2.pay)
print('\n')

print('Number of Employees Created: ', Employee.num_of_employees)

# =============================================================================
print('\n')
print('-' * 100)
print('Developer Sub Class Example')
print('-' * 100)
print('\n')

# Instantiating instances
dev_1 = Developer('Arin', 'Blue', 40000, 'Python')

print('---------- Developer 1 ----------')
print(dev_1.get_full_name())
print(dev_1.email)
print('Developer 1 Pay: ', dev_1.pay)
print('Developer 1 Raise Amount: ', dev_1.raise_amount)
dev_1.apply_raise()
print('Developer 1 New Pay: ', dev_1.pay)
print('\n')

# =============================================================================
print('\n')
print('-' * 100)
print('Manager Sub Class Example')
print('-' * 100)
from manager import Manager
from developer import Developer

dev1 = Developer("rox", 34000, "Java")
dev2 = Developer("bob", 50000, "java")
dev3 = Developer("tim", 7000,  "Python")
dev4 = Developer("nina", 7000,  "java")
dev5 = Developer("hana", 7000,  "Python")

devs = [dev1, dev2, dev3, dev4, dev5]

mgr = Manager("Mo", 70000, devs)

print("Java Developers:")
java_devs = mgr.all_java_devs()
for dev in java_devs:
    print(dev.name)

print()

print("Python Developers:")
python_devs = mgr.all_python_devs()
for dev in python_devs:
    print(dev.name)
Esempio n. 23
0
 def setUp(self):
     self.dev1 = Developer('tim')
     self.dev2 = Developer('tom')
     self.dev3 = Developer('tina')
Esempio n. 24
0
        filters = args.split(" ")
        if 'DESC' in filters[args_len - 1]:
            reverse = True
            filters.remove('DESC')
        else:
            reverse = False

        print("==============================")
        self.do_show_list(self.sort_by_attributes(devs, filters, reverse))

    def sort_by_attributes(self, devs, filters, reverse):
        sorted_devs = []
        sorted_devs = sorted(devs, key=attrgetter(*filters), reverse=reverse)
        return sorted_devs


if __name__ == '__main__':
    print("Setting up initial list...")
    devs = [
        Developer("John", 29, 3),
        Developer("Linda", 29, 5),
        Developer("Robert", 24, 1),
        Developer("Amanda", 21, 8),
        Developer("Lawrence", 32, 2),
        Developer("Steven", 24, 4)
    ]
    prompt = MyPrompt()
    prompt.do_show_list(devs)
    prompt.prompt = '> '
    prompt.cmdloop('Starting prompt... Type help for list of commands')
        n_pages = pages_repos['n_pages']
        repos_url = pages_repos['last_page']
        
        for page in range(1,n_pages):
            page_num = page + 1 # Já pegamos a primeira página
            repos_url_page = re.sub("page=\d+", "page=%s" % page_num, repos_url)
    
            r_repos = requests.get(repos_url_page, auth=(gh_user, gh_pass))
            j_repos = r_repos.json()
            # Não precisa mais de headers, pois já sabemos quantas páginas temos que verificar
    
            for repos in j_repos:
                stars += repos['watchers']
                n_repos += 1
    
        # Finalmente temos tudo do desenvolvedor individual. Seu nome, avatar, seguidores, estrelas,
        # contribuições no repositório de interesse e o número de repositórios do qual é dono.
        developers.append(Developer(name, followers, stars, commits, n_repos, avatar))
        
# Temos agora todos os desenvolvedores, contribuidores do repositório de interesse. Precisamos 
# agora armazenar essas informações em um banco de dados.

if os.path.isfile(db_name):
    os.remove(db_name)
    
Developer.init_db(db_name)
for dev in developers:
    dev.insert_to_db()
    
exit(0) # No error.
from employeedetails import Employee_spec
from developer import Developer

emp1 = Developer('tom','jones', 4, 'Python')
Tom = Employee_spec("tom", "jones", 5)

print emp1.details()