Esempio n. 1
0
 def test_creating_a_user_given_all_valid_arguments_then_user_is_created(self):
     self.assertEquals(len(self.users), 7)
     Project.command('create user [email protected] new test-user ta 1112223333 \"test st\"')
     self.assertEquals(len(self.users), 8)
Esempio n. 2
0
 def test_given_invalid_body_argument_then_error_is_thrown(self):
     with self.assertRaises(ValueError):
         Project.command("notify [email protected] \"subject\" 1234")
Esempio n. 3
0
 def test_given_user_is_already_logged_in__then_user_is_logged_out(self):
     Project.command('login [email protected] test')
     msg = Project.command('logout')
     self.assertEqual(msg, 'Goodbye, ta one')
Esempio n. 4
0
 def test_given_a_supervisor_tries_emailing_someone_then_email_is_sent(
         self):
     msg = Project.command("notify [email protected] \"subject\" \"body\"")
     self.assertEqual(msg, "Notification sent")
Esempio n. 5
0
 def test_given_too_many_arguments_then_an_error_message_is_displayed(self):
     msg = Project.command(
         "notify [email protected] \"subject\" \"body\" invalid")
     self.assertEqual(msg, "Too much info for one email")
Esempio n. 6
0
 def test_given_a_new_user_logging_in_for_the_first_time__then_the_user_is_greeted_and_told_to_enter_new_password(
         self):
     msg = Project.command('login [email protected]')
     self.assertEqual(msg,
                      'Welcome new user. Please enter your new password:')
Esempio n. 7
0
 def test_given_too_many_arguments__then_user_is_not_logged_in(self):
     msg = Project.command('login [email protected] tests hello')
     self.assertEqual(
         msg, 'Sorry, but that is too much information for one user')
Esempio n. 8
0
 def test_delete_a_user_given_user_does_not_exist_then_error_is_displayed(self):
     msg = Project.command('delete user [email protected]')
     self.assertEquals(msg, 'That user does not exist')
Esempio n. 9
0
 def test_editing_another_user_given_valid_arguments_then_user_is_edited(self):
     Project.command('edit user [email protected] firstName:\"newName\"')
     self.assertEquals(self.users[0]['firstName'], 'newName')
Esempio n. 10
0
 def test_creating_a_user_given_too_many_arguments(self):
     msg = Project.command('create user [email protected] new test-user ta 1112223333 \"test st\" too-many-arguments')
     self.assertEquals(msg, 'Too many arguments to create a user')
Esempio n. 11
0
 def test_delete_a_user_given_user_exists_then_user_is_removed(self):
     self.assertEquals(len(self.users), 7)
     Project.command('delete user [email protected]')
     self.assertEquals(len(self.users), 6)
Esempio n. 12
0
 def test_creating_a_user_given_too_few_arguments(self):
     msg = Project.command('create user [email protected] new test-user ta \"test st\"')
     self.assertEquals(msg, 'Too few arguments to create a user')
Esempio n. 13
0
 def test_creating_a_user_given_phone_number_has_special_characters_then_value_error_is_thrown(self):
     with self.assertRaises(ValueError):
         Project.command('create user [email protected] new test-user ta 111-222-3333 \"test st\"')
Esempio n. 14
0
 def test_creating_a_user_given_address_is_missing_quotes_then_value_error_is_thrown(self):
     with self.assertRaises(ValueError):
         Project.command('create user [email protected] new test-user ta 111-222-3333 test')
Esempio n. 15
0
 def test_given_invalid_email__then_user_is_not_logged_in(self):
     msg = Project.command('login [email protected] test')
     self.assertEqual(msg, INVALID_LOGIN_MESSAGE)
Esempio n. 16
0
 def test_editing_another_user_given_attribute_that_does_not_exist_then_error_is_displayed(self):
     msg = Project.command('edit user [email protected] invalid:\"newName\"')
     self.assertEquals(msg, 'That attribute does not exist')
Esempio n. 17
0
 def test_given_valid_login_and_then_another_login_attempt__then_user_notified_there_is_already_someone_logged_in(
         self):
     Project.command('login [email protected] test')
     msg = Project.command('login [email protected] test')
     self.assertEqual(msg, 'Sorry, there is already someone logged in.')
Esempio n. 18
0
 def setUp(self):
     Project.command('login [email protected] test')
     with open(user_data, 'r') as u_data:
         self.users = json.load(u_data)
Esempio n. 19
0
 def test_given_too_few_arguments_with_an_old_user__then_user_is_not_logged_in(
         self):
     msg = Project.command('login [email protected]')
     self.assertEqual(msg, INVALID_LOGIN_MESSAGE)
Esempio n. 20
0
 def test_editing_own_information_given_valid_arguments_then_user_info_is_edited(self):
     Project.command('edit firstName:\"newName\"')
     self.assertEquals(self.users[4]['firstName'], 'newName')
Esempio n. 21
0
 def setUp(self):
     Project.command("login [email protected] test")
Esempio n. 22
0
 def test_editing_own_information_given_invalid_arguments_then_error_is_displayed(self):
     msg = Project.command('edit invalid:\"newName\"')
     self.assertEquals(msg, 'That attribute does not exist')
Esempio n. 23
0
 def test_given_a_supervisor_tries_emailing_an_invalid_email_then_email_is_sent(
         self):
     msg = Project.command("notify [email protected] \"subject\" \"body\"")
     self.assertEqual(msg, "no@email is an invalid email")
Esempio n. 24
0
 def test_try_editing_other_users_info_then_error_is_displayed(self):
     msg = Project.command('edit user [email protected] firstName:\"newName\"')
     self.assertEquals(msg, 'You do not have permission to edit another user')
Esempio n. 25
0
 def test_given_too_few_arguments_then_an_error_message_is_displayed(self):
     msg = Project.command("notify [email protected] \"subject\"")
     self.assertEqual(msg, "Not enough info for an email")
Esempio n. 26
0
 def test_given_valid_login__then_user_is_logged_in(self):
     msg = Project.command('login [email protected] test')
     self.assertEqual(msg, 'Welcome ta one')
Esempio n. 27
0
 def test_given_a_ta_tries_emailing_someone_then_error_message_is_displayed(
         self):
     Project.command("login [email protected] test")
     msg = Project.command("notify [email protected] \"subject\" \"body\"")
     self.assertEqual(msg, "TAs cannot send notifications")
Esempio n. 28
0
 def test_given_valid_email_and_invalid_password__then_user_is_not_logged_in(
         self):
     msg = Project.command('login [email protected] hello')
     self.assertEqual(msg, INVALID_LOGIN_MESSAGE)
Esempio n. 29
0
 def test_given_user_is_not_logged_in__then_error_message_is_displayed(
         self):
     msg = Project.command('logout')
     self.assertEqual(msg, 'There are no users to sign out')
Esempio n. 30
0
 def test_assigning_a_lab_to_an_instructor_then_error_is_displayed(self):
     msg = Project.command('assign lab \"course with ta\" \"lab1\" [email protected]')
     self.assertEquals(msg, 'Only TAs can be assigned to labs')