예제 #1
0
 def test_send_email(self):
     with patch("smtplib.SMTP") as mock_smtp:
         payload = []
         payload.append(
             notif.KidsClass("frank", "poop", "*****@*****.**"))
         result = notif.send_text(payload)
         error = {credentials.LOGIN_EMAIL: (200, "Success")}
         self.assertEqual(result, error)
예제 #2
0
    def test_refused(self, mock_smtp):
        to_addresses = ["*****@*****.**", "*****@*****.**"]

        error = {
            to_addresses[0]:
            (450, "Requested mail action not taken: mailbox unavailable")
        }
        instance = mock_smtp.return_value
        instance.notif.send_text.return_value = error
        payload = []
        payload.append(notif.KidsClass("frank", "poop", "*****@*****.**"))
        # currently not returning anything here
        result = instance.notif.send_text(payload)
        self.assertIsInstance(result, dict)
        self.assertEqual(result, error)
예제 #3
0
def main():
    """our main to get into home access center"""
    all_grades = []
    with requests.Session() as session:
        site = session.get(credentials.HOME_ACCESS_POST)
        bs_content = BeautifulSoup(site.content, "html.parser")
        token = bs_content.find(
            "input", {"name": "__RequestVerificationToken"})["value"]
        login_data = {
            "__RequestVerificationToken": token,
            "Database": 10,
            "LogOnDetails.UserName": credentials.USERNAME,
            "LogOnDetails.Password": credentials.PASSWORD
        }

        session.post(credentials.HOME_ACCESS_POST, login_data)
        response = session.get(credentials.HOME_ACCESS_WEEK_VIEW)

        if response.status_code != 200:
            print(response.status_code)
            print(response.reason)
            print('initial get failed')
            sys.exit(1)

        middle = notif.KidsClass(notif.Kids.middle.value,
                                 message.get_grades(response),
                                 credentials.SEND_MIDDLE_EMAIL)

        all_grades.append(middle)

        # switch kid profile
        session.post(credentials.HOME_ACCESS_PICKER,
                     data=credentials.SWITCH_PAYLOAD)
        response = session.get(credentials.HOME_ACCESS_REQUEST)
        if response.status_code != 200:
            print(response.status_code)
            print(response.reason)
            print('first switch failed')
            sys.exit(1)

        oldest = notif.KidsClass(notif.Kids.oldest.value,
                                 message.get_grades(response),
                                 credentials.SEND_OLDEST_EMAIL)

        all_grades.append(oldest)

        # now let's grab the third kid:
        session.post(credentials.HOME_ACCESS_PICKER,
                     data=credentials.FINAL_SWITCH_PAYLOAD)
        response = session.get(credentials.HOME_ACCESS_REQUEST)
        if response.status_code != 200:
            print(response.status_code)
            print(response.reason)
            print('second switch failed')
            sys.exit(1)

        youngest = notif.KidsClass(notif.Kids.youngest.value,
                                   message.get_grades(response),
                                   credentials.SEND_YOUNGEST_EMAIL)

        all_grades.append(youngest)
        notif.send_text(all_grades)
예제 #4
0
 def test_createMessage(self):
     middle = notif.KidsClass("frank", "poop", "*****@*****.**")
     result = middle.create_message(middle, "test@email")
     self.assertIsNotNone(result)
예제 #5
0
 def test_init(self):
     middle = notif.KidsClass("frank", "poop", "*****@*****.**")
     self.assertIsNotNone(middle)