Exemple #1
0
class TestEmails(unittest.TestCase):
    def setUp(self):
        self.test_email = '*****@*****.**'
        self.auth = MyGit(config.BASE_URL,
                          name=config.USERNAME,
                          password=config.PASSWORD)
        self.auth.add_email_address([self.test_email])

    def test_check_email(self):
        emails = self.auth.get_email_addresses()
        emails_list = [mail['email'] for mail in emails.json()]

        self.assertEqual(200, emails.status_code)
        self.assertIn(self.test_email, emails_list)

    def test_primary_email_visibility(self):
        emails = self.auth.get_email_addresses()
        mail_visibility = [
            mail['visibility'] for mail in emails.json()
            if mail['email'] == self.test_email
        ]

        self.assertEqual(None, mail_visibility[0])

    def test_toggle_primary_email_visibility(self):
        self.auth.toggle_primary_email_visibility([self.test_email])
        emails = self.auth.get_email_addresses()
        mail_visibility = [
            mail['visibility'] for mail in emails.json()
            if mail['email'] == self.test_email
        ]

        self.assertEqual(True, mail_visibility[0])

    def tearDown(self):
        self.auth.delete_email_address([self.test_email])
Exemple #2
0
 def setUp(self):
     self.test_email = '*****@*****.**'
     self.auth = MyGit(config.BASE_URL,
                       name=config.USERNAME,
                       password=config.PASSWORD)
     self.auth.add_email_address([self.test_email])
Exemple #3
0
    def test_auth_incorrect_password(self):
        auth = MyGit(config.BASE_URL,
                     name=config.USERNAME,
                     password='******')

        self.assertEqual(401, auth.responce.status_code)
Exemple #4
0
    def test_auth_incorrect_name(self):
        auth = MyGit(config.BASE_URL,
                     name='incorrect_name',
                     password=config.PASSWORD)

        self.assertEqual(401, auth.responce.status_code)
Exemple #5
0
    def test_auth_ok(self):
        auth = MyGit(config.BASE_URL,
                     name=config.USERNAME,
                     password=config.PASSWORD)

        self.assertEqual(200, auth.responce.status_code)
Exemple #6
0
class TestEmailsNegative(unittest.TestCase):
    def setUp(self):
        self.auth = MyGit(config.BASE_URL,
                          name=config.USERNAME,
                          password=config.PASSWORD)

    def test_add_several_emails(self):
        test_email_1 = '*****@*****.**'
        test_email_2 = '*****@*****.**'
        self.auth.add_email_address([test_email_1, test_email_2])
        emails = self.auth.get_email_addresses()
        emails_list = [mail['email'] for mail in emails.json()]

        self.assertEqual(200, emails.status_code)
        self.assertIn(test_email_1, emails_list)
        self.assertIn(test_email_2, emails_list)

    def test_add_empty_email(self):
        test_email = ''
        self.auth.add_email_address([test_email])
        emails = self.auth.get_email_addresses()
        emails_list = [mail['email'] for mail in emails.json()]

        self.assertEqual(200, emails.status_code)
        self.assertNotIn(test_email, emails_list)

    def test_delete_several_emails(self):
        test_email_1 = '*****@*****.**'
        test_email_2 = '*****@*****.**'
        self.auth.add_email_address([test_email_1, test_email_2])
        emails = self.auth.get_email_addresses()
        emails_list = [mail['email'] for mail in emails.json()]

        self.auth.delete_email_address([test_email_1, test_email_2])

        self.assertEqual(200, emails.status_code)
        self.assertNotIn(test_email_1, emails_list)
        self.assertNotIn(test_email_2, emails_list)

    def test_delete_non_exist_email(self):
        test_email = '*****@*****.**'
        emails = self.auth.get_email_addresses()
        emails_list = [mail['email'] for mail in emails.json()]

        self.assertEqual(200, emails.status_code)
        self.assertNotIn(test_email, emails_list)

        self.auth.delete_email_address([test_email])
        self.assertEqual(200, emails.status_code)

    def test_add_incorrect_email(self):
        test_email = '@example.com'
        self.auth.add_email_address([test_email])
        emails = self.auth.get_email_addresses()
        emails_list = [mail['email'] for mail in emails.json()]

        self.assertEqual(200, emails.status_code)
        self.assertNotIn(test_email, emails_list)

    def tearDown(self):
        pass
Exemple #7
0
 def setUp(self):
     self.auth = MyGit(config.BASE_URL,
                       name=config.USERNAME,
                       password=config.PASSWORD)