예제 #1
0
    def test_save_history_id(self, get_http_mock):
        """
        Test the GmailConnector in saving the updated historty id to the email account.
        """
        get_http_mock.return_value = HttpMock('lily/messaging/email/tests/data/get_history_archived.json',
                                              {'status': '200'})

        email_account = EmailAccount.objects.first()

        connector = GmailConnector(email_account)
        # First do a history update, so a new history id is retreived.
        connector.get_history()
        # Save the history id to the email account.
        connector.save_history_id()

        # Verify that the history is indeed saved on the email account.
        email_account.refresh_from_db()
        self.assertEqual(email_account.history_id, 8170)
예제 #2
0
    def test_save_history_id(self, get_http_mock):
        """
        Test the GmailConnector in saving the updated historty id to the email account.
        """
        get_http_mock.return_value = HttpMock(
            'lily/messaging/email/tests/data/get_history_archived.json',
            {'status': '200'})

        email_account = EmailAccount.objects.first()

        connector = GmailConnector(email_account)
        # First do a history update, so a new history id is retreived.
        connector.get_history()
        # Save the history id to the email account.
        connector.save_history_id()

        # Verify that the history is indeed saved on the email account.
        email_account.refresh_from_db()
        self.assertEqual(email_account.history_id, 8170)
예제 #3
0
    def test_get_history(self, get_http_mock):
        """
        Test the GmailConnector in retrieving the history updates.
        """
        get_http_mock.return_value = HttpMock('lily/messaging/email/tests/data/get_history_archived.json',
                                              {'status': '200'})

        email_account = EmailAccount.objects.first()

        connector = GmailConnector(email_account)
        response = connector.get_history()

        # Verify that the service call returned the correct json object.
        with open('lily/messaging/email/tests/data/get_history_archived.json') as infile:
            json_obj = json.load(infile)
            self.assertEqual(response, json_obj['history'])

        # Verify that the history is updated with the one from the API response.
        self.assertEqual(connector.history_id, u'8170')
예제 #4
0
    def test_get_history(self, get_http_mock):
        """
        Test the GmailConnector in retrieving the history updates.
        """
        get_http_mock.return_value = HttpMock(
            'lily/messaging/email/tests/data/get_history_archived.json',
            {'status': '200'})

        email_account = EmailAccount.objects.first()

        connector = GmailConnector(email_account)
        response = connector.get_history()

        # Verify that the service call returned the correct json object.
        with open('lily/messaging/email/tests/data/get_history_archived.json'
                  ) as infile:
            json_obj = json.load(infile)
            self.assertEqual(response, json_obj['history'])

        # Verify that the history is updated with the one from the API response.
        self.assertEqual(connector.history_id, u'8170')