Example #1
0
 def test_save_user(self):
     new_name = "Testy"
     test_user = cT.user_by_id(self.user)
     test_user.firstName = new_name
     cT.save_user(test_user)
     mod_user = cT.user_by_id(self.user)
     self.assertEqual(mod_user.firstName, new_name)
Example #2
0
 def add_one_user(self):
     self.deactivate_buttons()
     temp_id = int(self.id_entry.get())
     e_mail = self.em_entry.get()
     first_name = self.fn_entry.get()
     last_name = self.ln_entry.get()
     # Checks that all the fields are filled in.
     if temp_id != "" and e_mail != "" and first_name != "" and last_name != "":
         # Checks that user has not been previously added
         if cT.user_by_id(temp_id) is None:
             curr_user = cT.create_single_user(temp_id, first_name,
                                               last_name, e_mail)[0]
             curr_vm = cT.get_vm_object(curr_user.assigned_VM)
             curr_vm.is_instance_ready()
             curr_vm.stop_instance()
         else:
             messagebox.showinfo("User Error",
                                 "This user already exist",
                                 parent=self)
     else:
         messagebox.showinfo(
             "Missing Requirements",
             "ID, eMail, First Name, and Last Name fields must be filled.",
             parent=self)
     self.clear_single_user_fields()
     self.activate_buttons()
Example #3
0
    def create_multi_user(self):
        cs_file = self.csv_entry.get()
        self.deactivate_buttons()
        if cs_file != "":
            user_csv_list = []
            with open(cs_file, 'r', newline='') as CSV_FILE:
                reader = csv.reader(CSV_FILE)
                next(reader)
                for user_list in reader:
                    user_csv_list.append(user_list)

            # Sets up the progress bar
            self.csv_progress['maximum'] = len(user_csv_list) * 2
            bar = 0

            # Creates user and assigns vm
            for new_user in user_csv_list:
                if new_user:
                    if cT.user_by_id(int(new_user[0])) is None:
                        success = cT.create_single_user(
                            new_user[0].strip(), new_user[1].strip(),
                            new_user[2].strip(), new_user[3].strip())
                        if not success[1]:
                            messagebox.showinfo(
                                "Warning",
                                "Unable to notify user {0} of their account's password."
                                .format(new_user[0]),
                                parent=self)
                bar += 1
                self.csv_progress["value"] = bar
                self.csv_progress.update()

            # waits for all machines to finish loading and shuts them down
            for curr_user in cT.get_list_users():
                if curr_user.isTeacher is False:
                    curr_vm = cT.get_vm_object(curr_user.assigned_VM)
                    curr_vm.is_instance_ready()
                    curr_vm.stop_instance()
                    bar += 1
                self.csv_progress["value"] = bar
                self.csv_progress.update()

            messagebox.showinfo("Done", "Process completed.", parent=self)
            self.csv_progress["value"] = 0
            self.csv_progress.update()
        else:
            messagebox.showinfo(
                "Missing Info",
                "You need to first load a .csv file and provide a valid AMI.",
                parent=self)
        self.clear_multi_user_fields()
        self.activate_buttons()
 def verify_login(self):
     user_id = int(self.unEntry.get())
     if cT.verify_user(user_id, self.pwEntry.get()):
         user = cT.user_by_id(user_id)
         if user.isTeacher is False:
             if user.isSuspended is False:
                 self.controller.vm = cT.get_vm_object(user.assigned_VM)
                 self.controller.vm.start_instance()
                 self.controller.user = user
                 self.controller.show_frame("StudentPage")
             else:
                 messagebox.showinfo(
                     "Warning",
                     "Your Account Has Been Suspended. Please Contact Instructor",
                     parent=self)
         else:
             self.controller.show_frame("TeacherPage")
     else:
         messagebox.showinfo(
             "Warning",
             "Please Check Your Username And Password Then Try Again",
             parent=self)
Example #5
0
 def test_vm_created(self):
     test_user = cT.user_by_id(self.user)
     self.assertIsNotNone(cT.get_vm_object(test_user.assigned_VM))
Example #6
0
 def test_user_created(self):
     test_user = cT.user_by_id(self.user)
     self.assertEqual(test_user.firstName, self.name)
Example #7
0
 def tearDown(self) -> None:
     test_user = cT.user_by_id(self.user)
     test_vm = cT.get_vm_object(test_user.assigned_VM)
     cT.del_user(test_user)
     cT.del_vm(test_vm)