Exemplo n.º 1
0
    def test_edit_post_not_ajax_does_not_chane_data(self):
        """/edit/ post not ajax request must change UserProfile if its valid"""
        self.client.login(username='******', password='******')

        data = user_data.copy()
        data['name'] = 'Nigel'

        self.client.post(reverse('edit'), data)

        self.assertNotEquals(UserProfile.objects.first().name, data['name'])
Exemplo n.º 2
0
    def test_edit_post_not_ajax_does_not_chane_data(self):
        """/edit/ post not ajax request must change UserProfile if its valid"""
        self.client.login(username='******', password='******')

        data = user_data.copy()
        data['name'] = 'Nigel'

        self.client.post(reverse('edit'), data)

        self.assertNotEquals(UserProfile.objects.first().name, data['name'])
Exemplo n.º 3
0
    def test_edit_post_ajax_changes_UserProfile(self):
        """ /edit/ post ajax request must change UserProfile if its valid"""
        self.client.login(username='******', password='******')

        data = user_data.copy()
        data['name'] = 'Nigel'

        response = self.client.post(reverse('edit'), data,
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest')

        self.assertEquals(UserProfile.objects.first().name, data['name'])
        self.assertEquals(json.loads(response.content)['success'], True)
Exemplo n.º 4
0
    def test_edit_post_with_invalid_data(self):
        """/edit/ post request with invalid data"""
        self.client.login(username='******', password='******')

        data = user_data.copy()
        data['email'] = 'dasdasdasd'

        response = self.client.post(reverse('edit'), data,
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest')

        self.assertEquals(json.loads(response.content)['success'], False)
        self.assertEquals(json.loads(response.content)['err_msg']['email'][0],
                          'Enter a valid email address.')
Exemplo n.º 5
0
    def test_edit_post_ajax_changes_UserProfile(self):
        """ /edit/ post ajax request must change UserProfile if its valid"""
        self.client.login(username='******', password='******')

        data = user_data.copy()
        data['name'] = 'Nigel'

        response = self.client.post(reverse('edit'),
                                    data,
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest')

        self.assertEquals(UserProfile.objects.first().name, data['name'])
        self.assertEquals(json.loads(response.content)['success'], True)
Exemplo n.º 6
0
    def test_edit_post_with_invalid_data(self):
        """/edit/ post request with invalid data"""
        self.client.login(username='******', password='******')

        data = user_data.copy()
        data['email'] = 'dasdasdasd'

        response = self.client.post(reverse('edit'),
                                    data,
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest')

        self.assertEquals(json.loads(response.content)['success'], False)
        self.assertEquals(
            json.loads(response.content)['err_msg']['email'][0],
            'Enter a valid email address.')