def test_batch_update_does_not_change_contact_with_no_linked_in_profile(self):
        joyce = Contact(given_name="Joyce", family_name="Kgatlwane")
        joyce.save()

        response = self.do_batch_update_and_return_response()

        matches = Contact.objects.filter(given_name="Joyce")
        self.assertEquals(1, len(matches))

        batch_report = response.context["batch_report"]
        self.assertEquals([{"Joyce Kgatlwane": "No LinkedIn Profile"}], batch_report)
 def test_batch_update_does_not_change_contact_with_no_linked_in_profile(self):
     joyce = Contact(given_name="Joyce", family_name="Kgatlwane")
     joyce.save()
     
     response = self.do_batch_update_and_return_response()
     
     matches = Contact.objects.filter(given_name="Joyce")
     self.assertEquals(1, len(matches))
     
     batch_report = response.context['batch_report']
     self.assertEquals([{"Joyce Kgatlwane" : "No LinkedIn Profile"}],
                       batch_report)
示例#3
0
 def createContacts(self):
     self.contact1 = Contact(given_name="My", family_name="Name", phone="(12345) 678910",
                email="[email protected]", address_line_1="123 A Road Name, Somewhere", 
                role="Head of Surgery", tags="Hospital, Medicine, Surgeon", organization="London Teaching Hospital",
                note="Note Very Important")
     self.contact1.save()
     self.contact2 = Contact(
                given_name="Anew", family_name="Person", phone="(54321) 123456",
                email="[email protected]", address_line_1="456 A Road, Through the Looking Glass",
                role="Pharmacist", tags="Medicine", organization="Selby's Pharmacy"
                )
     self.contact2.save()
     self.contact3 = Contact(given_name="Aptivate", family_name="Employee", phone="(32543) 523566",
                email="[email protected]", address_line_1="999 Letsbe Avenue", tags="academia", note="Death Note",
                role="Researcher", organization="Imperial College"
                )
     self.contact3.save()
示例#4
0
 def createContacts(self):
     self.contact1 = Contact(given_name="My",
                             family_name="Name",
                             phone="(12345) 678910",
                             email="[email protected]",
                             address_line_1="123 A Road Name, Somewhere",
                             role="Head of Surgery",
                             tags="Hospital, Medicine, Surgeon",
                             organization="London Teaching Hospital",
                             note="Note Very Important")
     self.contact1.save()
     self.contact2 = Contact(
         given_name="Anew",
         family_name="Person",
         phone="(54321) 123456",
         email="[email protected]",
         address_line_1="456 A Road, Through the Looking Glass",
         role="Pharmacist",
         tags="Medicine",
         organization="Selby's Pharmacy")
     self.contact2.save()
     self.contact3 = Contact(given_name="Aptivate",
                             family_name="Employee",
                             phone="(32543) 523566",
                             email="[email protected]",
                             address_line_1="999 Letsbe Avenue",
                             tags="academia",
                             note="Death Note",
                             role="Researcher",
                             organization="Imperial College")
     self.contact3.save()
class ContactListTestCase(TestCase):
    def delete_contacts(self):
        # pylint: disable-msg=E1101
        Contact.objects.all().delete()
    
    def create_contacts(self):
        self.contact1 = Contact(given_name="My", family_name="Name", phone="(12345) 678910",
                   email="[email protected]", address_line_1="123 A Road Name, Somewhere", 
                   role="Head of Surgery", tags="Hospital, Medicine, Surgeon", organization="London Teaching Hospital",
                   note="Note Very Important")
        self.contact1.save()
        self.contact2 = Contact(
                   given_name="Anew", family_name="Person", phone="(54321) 123456",
                   email="[email protected]", address_line_1="456 A Road, Through the Looking Glass",
                   role="Pharmacist", tags="Medicine", organization="Selby's Pharmacy"
                   )
        self.contact2.save()
        self.contact3 = Contact(given_name="Aptivate", family_name="Employee", phone="(32543) 523566",
                   email="[email protected]", address_line_1="999 Letsbe Avenue", tags="academia", note="Death Note",
                   role="Researcher", organization="Imperial College"
                   )
        self.contact3.save()
    
    def rebuild_search_index(self):
        rebuild_index.Command().handle(verbosity=0, interactive=False)
示例#6
0
class ContactListTestCase(TestCase):
    def delete_contacts(self):
        # pylint: disable-msg=E1101
        Contact.objects.all().delete()

    def create_contacts(self):
        self.contact1 = Contact(given_name="My",
                                family_name="Name",
                                phone="(12345) 678910",
                                email="[email protected]",
                                address_line_1="123 A Road Name, Somewhere",
                                role="Head of Surgery",
                                tags="Hospital, Medicine, Surgeon",
                                organization="London Teaching Hospital",
                                note="Note Very Important")
        self.contact1.save()
        self.contact2 = Contact(
            given_name="Anew",
            family_name="Person",
            phone="(54321) 123456",
            email="[email protected]",
            address_line_1="456 A Road, Through the Looking Glass",
            role="Pharmacist",
            tags="Medicine",
            organization="Selby's Pharmacy")
        self.contact2.save()
        self.contact3 = Contact(given_name="Aptivate",
                                family_name="Employee",
                                phone="(32543) 523566",
                                email="[email protected]",
                                address_line_1="999 Letsbe Avenue",
                                tags="academia",
                                note="Death Note",
                                role="Researcher",
                                organization="Imperial College")
        self.contact3.save()

    def rebuild_search_index(self):
        rebuild_index.Command().handle(verbosity=0, interactive=False)
示例#7
0
class SimpleTest(TestCase):
    login_user = None

    def login(self, client):
        if self.login_user is None:
            self.login_user = User.objects.create_user(
                'admin', '*****@*****.**', password='******')
            self.assertTrue(client.login(username='******',
                                         password='******'))

    def setUp(self):
        self.createContacts()

    def createContacts(self):
        self.contact1 = Contact(given_name="My",
                                family_name="Name",
                                phone="(12345) 678910",
                                email="[email protected]",
                                address_line_1="123 A Road Name, Somewhere",
                                role="Head of Surgery",
                                tags="Hospital, Medicine, Surgeon",
                                organization="London Teaching Hospital",
                                note="Note Very Important")
        self.contact1.save()
        self.contact2 = Contact(
            given_name="Anew",
            family_name="Person",
            phone="(54321) 123456",
            email="[email protected]",
            address_line_1="456 A Road, Through the Looking Glass",
            role="Pharmacist",
            tags="Medicine",
            organization="Selby's Pharmacy")
        self.contact2.save()
        self.contact3 = Contact(given_name="Aptivate",
                                family_name="Employee",
                                phone="(32543) 523566",
                                email="[email protected]",
                                address_line_1="999 Letsbe Avenue",
                                tags="academia",
                                note="Death Note",
                                role="Researcher",
                                organization="Imperial College")
        self.contact3.save()

    def test_search_by_given_name(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/', {'search_term': "My"})
        self.assertContains(response, 'My Name')

    def test_search_by_family_name(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/', {'search_term': "Person"})
        self.assertContains(response, 'Anew Person')

    def test_search_by_note_for_name(self):
        client = self.client
        self.login(client)

        response = client.post('/contacts/',
                               {'search_term': "Note Very Important"})
        self.assertContains(response, 'My Name')

    def test_search_has_note(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/', {'search_term': "Note"})
        self.assertContains(response, 'My Name')
        self.assertContains(response, 'Aptivate Employee')
        self.assertNotContains(response, 'Anew Person')

    def test_search_for_role(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/',
                               {'search_term': "Head of Surgery"})
        self.assertContains(response, 'My Name')
        self.assertNotContains(response, 'Aptivate Employee')
        self.assertNotContains(response, 'Anew Person')

    def test_search_for_organization(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/',
                               {'search_term': "London Teaching Hospital"})
        self.assertContains(response, 'My Name')
        self.assertNotContains(response, 'Aptivate Employee')
        self.assertNotContains(response, 'Anew Person')

    def test_search_for_name_has_role(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/', {'search_term': "My Name"})
        self.assertContains(response, "Head of Surgery")
        self.assertNotContains(response, "Pharmacist")
        self.assertNotContains(response, "Researcher")

    def test_search_for_name_has_organization(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/', {'search_term': "My Name"})
        self.assertContains(response, "Head of Surgery")
        self.assertNotContains(response, "Selby's Pharmacy")
        self.assertNotContains(response, "Imperial College")

    def test_no_results(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/', {'search_term': "Invalid String"})
        self.assertContains(response, 'No Results found.')

    def test_search_by_tag(self):
        client = self.client
        self.login(client)
        hospital_tag_id = Tag.objects.get(name='Hospital').id
        response = client.post('/contacts/', {
            'search_term': "My",
            "tags": [hospital_tag_id]
        })
        self.assertContains(response, 'My Name')

    def test_search_by_not_tag(self):
        client = self.client
        self.login(client)

        unused_tag = Tag(name="Unused")
        unused_tag.save()
        response = client.post('/contacts/', {
            'search_term': "My",
            "tags": [unused_tag.id]
        })

        self.assertContains(response, 'No Results found.')

    def test_search_by_tag_faux(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/', {'search_term': "My Medicine"})
        self.assertContains(response, 'My Name')

    def test_search_by_not_tag_faux(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/', {'search_term': "My academia"})
        self.assertContains(response, 'No Results found.')

    def test_contact_view_tag_presence(self):
        client = self.client
        self.login(client)
        response = client.post(self.get_contacts_url(self.contact1), {})
        self.assertContains(response, "Medicine</a></li>")

    def test_contact_view_tag_absence(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/3/')
        self.assertNotContains(response, "Medicine</a></li>")

    def test_tag_view_presence(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/tags/Medicine/')
        self.assertContains(response, "My Name")

    def test_tag_view_absence(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/tags/Medicine/')
        self.assertNotContains(response, "Aptivate")

    def test_multiple_tag_select(self):
        client = self.client
        self.login(client)

        hospital_tag_id = Tag.objects.get(name='Hospital').id
        medicine_tag_id = Tag.objects.get(name='Medicine').id
        surgeon_tag_id = Tag.objects.get(name='Surgeon').id

        tag_ids = [hospital_tag_id, medicine_tag_id, surgeon_tag_id]

        response = client.post('/contacts/', {"tags": tag_ids})
        self.assertContains(response, 'My Name')
        self.assertNotContains(response, "Aptivate")

    def get_contacts_url(self, contact):
        return "/contacts/%d/" % contact.id
示例#8
0
class SimpleTest(TestCase):
    login_user = None
    def login(self, client):
        if self.login_user is None:
            self.login_user = User.objects.create_user(
                            'admin',
                            '*****@*****.**',
                            password='******'
                        )
            self.assertTrue(client.login(
                            username='******',
                            password='******'))
    def setUp(self):
        self.createContacts()
    
    def createContacts(self):
        self.contact1 = Contact(given_name="My", family_name="Name", phone="(12345) 678910",
                   email="[email protected]", address_line_1="123 A Road Name, Somewhere", 
                   role="Head of Surgery", tags="Hospital, Medicine, Surgeon", organization="London Teaching Hospital",
                   note="Note Very Important")
        self.contact1.save()
        self.contact2 = Contact(
                   given_name="Anew", family_name="Person", phone="(54321) 123456",
                   email="[email protected]", address_line_1="456 A Road, Through the Looking Glass",
                   role="Pharmacist", tags="Medicine", organization="Selby's Pharmacy"
                   )
        self.contact2.save()
        self.contact3 = Contact(given_name="Aptivate", family_name="Employee", phone="(32543) 523566",
                   email="[email protected]", address_line_1="999 Letsbe Avenue", tags="academia", note="Death Note",
                   role="Researcher", organization="Imperial College"
                   )
        self.contact3.save()
    
    def test_search_by_given_name(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/', {'search_term':"My"})
        self.assertContains(response, 'My Name')
    
    def test_search_by_family_name(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/', {'search_term':"Person"})
        self.assertContains(response, 'Anew Person')
    
    def test_search_by_note_for_name(self):
        client = self.client
        self.login(client)
        
        response = client.post('/contacts/', {'search_term':"Note Very Important"})
        self.assertContains(response, 'My Name')
    
    def test_search_has_note(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/', {'search_term':"Note"})
        self.assertContains(response, 'My Name')
        self.assertContains(response, 'Aptivate Employee')
        self.assertNotContains(response, 'Anew Person')
        
    def test_search_for_role(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/', {'search_term':"Head of Surgery"})
        self.assertContains(response, 'My Name')
        self.assertNotContains(response, 'Aptivate Employee')
        self.assertNotContains(response, 'Anew Person')
    
    def test_search_for_organization(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/', {'search_term':"London Teaching Hospital"})
        self.assertContains(response, 'My Name')
        self.assertNotContains(response, 'Aptivate Employee')
        self.assertNotContains(response, 'Anew Person')
    
    def test_search_for_name_has_role(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/', {'search_term':"My Name"})
        self.assertContains(response, "Head of Surgery")
        self.assertNotContains(response, "Pharmacist")
        self.assertNotContains(response, "Researcher")
    
    def test_search_for_name_has_organization(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/', {'search_term':"My Name"})
        self.assertContains(response, "Head of Surgery")
        self.assertNotContains(response, "Selby's Pharmacy")
        self.assertNotContains(response, "Imperial College")
    
    def test_no_results(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/', {'search_term':"Invalid String"})
        self.assertContains(response, 'No Results found.')
    
    def test_search_by_tag(self):
        client = self.client
        self.login(client)
        hospital_tag_id = Tag.objects.get(name='Hospital').id
        response = client.post('/contacts/', {'search_term':"My",
                                              "tags":[hospital_tag_id]})
        self.assertContains(response, 'My Name')
    
    def test_search_by_not_tag(self):
        client = self.client
        self.login(client)
        
        unused_tag = Tag(name="Unused")
        unused_tag.save()
        response = client.post('/contacts/', {'search_term':"My",
                                              "tags":[unused_tag.id]})
        
        self.assertContains(response, 'No Results found.')
    
    def test_search_by_tag_faux(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/', {'search_term':"My Medicine"})
        self.assertContains(response, 'My Name')
    
    def test_search_by_not_tag_faux(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/', {'search_term':"My academia"})
        self.assertContains(response, 'No Results found.')
    
    def test_contact_view_tag_presence(self):
        client = self.client
        self.login(client)
        response = client.post(self.get_contacts_url(self.contact1),{})
        self.assertContains(response,"Medicine</a></li>")
    
    def test_contact_view_tag_absence(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/3/')
        self.assertNotContains(response,"Medicine</a></li>")
    
    def test_tag_view_presence(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/tags/Medicine/')
        self.assertContains(response, "My Name")
    
    def test_tag_view_absence(self):
        client = self.client
        self.login(client)
        response = client.post('/contacts/tags/Medicine/')
        self.assertNotContains(response, "Aptivate")
    
    def test_multiple_tag_select(self):
        client = self.client
        self.login(client)
        
        hospital_tag_id = Tag.objects.get(name='Hospital').id
        medicine_tag_id = Tag.objects.get(name='Medicine').id
        surgeon_tag_id = Tag.objects.get(name='Surgeon').id
        
        tag_ids = [hospital_tag_id, medicine_tag_id, surgeon_tag_id]
        
        response = client.post('/contacts/',{"tags":tag_ids})
        self.assertContains(response, 'My Name')
        self.assertNotContains(response, "Aptivate")
        
    def get_contacts_url(self, contact):
        return "/contacts/%d/" % contact.id