예제 #1
0
    def test_web_invite(self):
        try:
            contact_ids = []
            with mock.patch(
                    "contactstore.openinviter.get_contacts") as mock_importer:
                mock_importer.return_value = self.data_list
                imported_contacts = import_contacts(self.importing,
                                                    self.importing.email,
                                                    IMPORTER_PASSWORD)
                contact_ids += [contact["id"] for contact in imported_contacts]

            self.assertTrue(
                self.client.login(username=self.importing.username,
                                  password=IMPORTER_PASSWORD))

            invite_url = url_reverse("contactstore.views.create_invites")
            data = urllib.urlencode({"contact_id": contact_ids}, doseq=True)
            response = self.client.post(
                invite_url,
                data=data,
                content_type="application/x-www-form-urlencoded")
            self.assertEquals(response.status_code, 200)

            invites = EmailInvite.objects.filter(contact__id__in=contact_ids)
            self.assertEquals(len(invites), len(contact_ids))

        finally:
            pass
예제 #2
0
    def setUp(self):
        """Set up

        make the user that will import
        
        make a list of unique emails to import

        make the imported contacts through a mock importer
        """
        unittest.TestCase.setUp(self)
        self.importing = _make_user()

        self.email1 = _make_names("user1")
        self.email2 = _make_names("user2")
        self.email3 = _make_names("user3")

        self.data_list = [(self.email1, "U Ser1"), (self.email2, "U Ser2"),
                          (self.email3, "U Ser3")]

        self.imported_contacts = []
        with mock.patch(
                "contactstore.openinviter.get_contacts") as mock_importer:
            mock_importer.return_value = self.data_list
            self.imported_contacts = import_contacts(self.importing,
                                                     self.importing.email,
                                                     IMPORTER_PASSWORD)
예제 #3
0
    def test_web_invite(self):
        try:
            contact_ids = []
            with mock.patch("contactstore.openinviter.get_contacts") as mock_importer:
                mock_importer.return_value = self.data_list
                imported_contacts = import_contacts(
                    self.importing, 
                    self.importing.email, 
                    IMPORTER_PASSWORD
                    )
                contact_ids += [contact["id"] for contact in imported_contacts]

            self.assertTrue(self.client.login(
                    username=self.importing.username, 
                    password=IMPORTER_PASSWORD
                    ))

            invite_url = url_reverse("contactstore.views.create_invites")
            data = urllib.urlencode({
                    "contact_id": contact_ids
                    }, doseq=True)
            response = self.client.post(
                invite_url, 
                data=data, 
                content_type="application/x-www-form-urlencoded"
                )
            self.assertEquals(response.status_code, 200)
            
            invites = EmailInvite.objects.filter(contact__id__in=contact_ids)
            self.assertEquals(len(invites), len(contact_ids))

        finally:
            pass
예제 #4
0
    def setUp(self):
        """Set up

        make the user that will import
        
        make a list of unique emails to import

        make the imported contacts through a mock importer
        """
        unittest.TestCase.setUp(self)
        self.importing = _make_user()

        self.email1 = _make_names("user1")
        self.email2 = _make_names("user2")
        self.email3 = _make_names("user3")
        
        self.data_list = [
            (self.email1, "U Ser1" ),
            (self.email2, "U Ser2" ),
            (self.email3, "U Ser3" )
            ] 

        self.imported_contacts = []
        with mock.patch("contactstore.openinviter.get_contacts") as mock_importer:
            mock_importer.return_value = self.data_list
            self.imported_contacts = import_contacts(
                self.importing, 
                self.importing.email, 
                IMPORTER_PASSWORD
                )
예제 #5
0
            "error_message": e.get_message()
        })
        response = render_to_response("share.xslt", ctx)
        response.status_code = 401
        return response
    else:
        try:
            #with mock.patch("contactstore.openinviter.get_contacts") as mock_importer:
            #    mock_importer.return_value = [
            #        ("*****@*****.**", "user 1"),
            #        ("*****@*****.**", "user 2"),
            #        ("*****@*****.**", "user 3"),
            #        ]

            importer_contacts = tools.import_contacts(
                request.user, form.cleaned_data["email"],
                form.cleaned_data["password"])
        except LoginException, e:
            return HttpResponseServerError("bad login")
        except Exception, e:
            # FIXME
            logger.exception(e)
            return HttpResponse("no contacts")
        else:
            # FIXME - use the new xmlify stuff
            contacts = xmlifyiter(
                importer_contacts,
                "{http://djangoproject.com/template/xslt}contact",
                id="id",
                contact_name="name",
                email="email")
예제 #6
0
                })
        response = render_to_response("share.xslt", ctx)
        response.status_code = 401
        return response
    else:
        try:
            #with mock.patch("contactstore.openinviter.get_contacts") as mock_importer:
            #    mock_importer.return_value = [
            #        ("*****@*****.**", "user 1"),
            #        ("*****@*****.**", "user 2"),
            #        ("*****@*****.**", "user 3"),
            #        ]

            importer_contacts = tools.import_contacts(
                request.user,
                form.cleaned_data["email"],
                form.cleaned_data["password"]
                )
        except LoginException, e:
            return HttpResponseServerError("bad login")
        except Exception, e:
            # FIXME
            logger.exception(e)
            return HttpResponse("no contacts")
        else:
            # FIXME - use the new xmlify stuff
            contacts = xmlifyiter(
                importer_contacts, 
                "{http://djangoproject.com/template/xslt}contact",
                id="id",
                contact_name="name",