started test case enhancements
This commit is contained in:
parent
5f1d7026f1
commit
47b84b267b
10 changed files with 324 additions and 116 deletions
|
|
@ -119,7 +119,7 @@ class AccountsUpdateUrlTestCase(AccountCreateTest, TestCase):
|
|||
'/accounts/' + str(self.account.id) + '/edit/')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def tst_accounts_update_html(self):
|
||||
def test_accounts_update_html(self):
|
||||
response = self.client.get(
|
||||
'/accounts/' + str(self.account.id) + '/edit/')
|
||||
self.assertTemplateUsed(response, 'create_account.html')
|
||||
|
|
|
|||
101
cases/tests.py
101
cases/tests.py
|
|
@ -2,16 +2,23 @@ from django.test import TestCase
|
|||
from cases.models import Case
|
||||
from contacts.models import Contact
|
||||
from accounts.models import Account
|
||||
from common.models import Address, Comment,Attachments
|
||||
from common.models import Address, Comment, Attachments
|
||||
from common.models import User
|
||||
|
||||
|
||||
class CaseCreation(object):
|
||||
def setUp(self):
|
||||
self.address = Address.objects.create(street="6th phase", city="hyderabad", postcode="506344",
|
||||
country='IN')
|
||||
self.address = Address.objects.create(
|
||||
street="6th phase",
|
||||
city="hyderabad",
|
||||
postcode="506344",
|
||||
country='IN')
|
||||
|
||||
self.user = User.objects.create(first_name="raghu", username='raghu', email='r@mp.com', role="ADMIN")
|
||||
self.user = User.objects.create(
|
||||
first_name="raghu",
|
||||
username='raghu',
|
||||
email='r@mp.com',
|
||||
role="ADMIN")
|
||||
self.user.set_password('raghu')
|
||||
self.user.save()
|
||||
self.client.login(email='r@mp.com', password='raghu')
|
||||
|
|
@ -27,10 +34,13 @@ class CaseCreation(object):
|
|||
|
||||
self.contacts = Contact.objects.create(
|
||||
first_name="contact", email="contact@gmail.com", phone="12345",
|
||||
account=self.account, description="contact", address=self.address, created_by=self.user)
|
||||
account=self.account, description="contact",
|
||||
address=self.address, created_by=self.user
|
||||
)
|
||||
|
||||
self.case = Case.objects.create(
|
||||
name="raghu", case_type="Problem", status="New", account=self.account,
|
||||
name="raghu", case_type="Problem", status="New",
|
||||
account=self.account,
|
||||
priority="Low", description="something",
|
||||
created_by=self.user, closed_on="2016-05-04")
|
||||
self.comment = Comment.objects.create(
|
||||
|
|
@ -39,7 +49,7 @@ class CaseCreation(object):
|
|||
)
|
||||
self.attachment = Attachments.objects.create(
|
||||
attachment='image.png', case=self.case,
|
||||
created_by=self.user,account=self.account
|
||||
created_by=self.user, account=self.account
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -64,17 +74,23 @@ class CaseViewTestCase(CaseCreation, TestCase):
|
|||
|
||||
class CaseCreationUrlTestCase(CaseCreation, TestCase):
|
||||
def test_create_cases(self):
|
||||
response = self.client.post('/cases/create/', {'name': 'new case', 'case_type': 'Problem', 'status': 'New',
|
||||
'account': self.account, 'contacts': [self.contacts.id],
|
||||
'priority': "Low",
|
||||
'description': "something"})
|
||||
response = self.client.post('/cases/create/', {
|
||||
'name': 'new case', 'case_type': 'Problem',
|
||||
'status': 'New',
|
||||
'account': self.account, 'contacts': [self.contacts.id],
|
||||
'priority': "Low", 'description': "something"
|
||||
})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_create_cases_html(self):
|
||||
response = self.client.post('/cases/create/', {'name': 'new case', 'case_type': 'Problem', 'status': 'New',
|
||||
'account': self.account, 'contacts': [self.contacts.id],
|
||||
'priority': "Low",
|
||||
'description': "something"})
|
||||
response = self.client.post('/cases/create/', {
|
||||
'name': 'new case',
|
||||
'case_type': 'Problem',
|
||||
'status': 'New',
|
||||
'account': self.account,
|
||||
'contacts': [self.contacts.id],
|
||||
'priority': "Low",
|
||||
'description': "something"})
|
||||
self.assertTemplateUsed(response, 'create_cases.html')
|
||||
|
||||
|
||||
|
|
@ -99,21 +115,28 @@ class CaseRemoveTestCase(CaseCreation, TestCase):
|
|||
self.assertEqual(response['location'], '/cases/list/')
|
||||
|
||||
def test_case_delete(self):
|
||||
response = self.client.post('/cases/'+ str(self.case.id) + '/remove/', {'case_id':self.case.id})
|
||||
response = self.client.post(
|
||||
'/cases/' + str(self.case.id) + '/remove/',
|
||||
{'case_id': self.case.id})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
class CaseUpdateTestCase(CaseCreation, TestCase):
|
||||
def test_update_case_view(self):
|
||||
response = self.client.get('/cases/' + str(self.case.id) + '/edit_case/')
|
||||
response = self.client.get(
|
||||
'/cases/' + str(self.case.id) + '/edit_case/')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_case_update(self):
|
||||
response = self.client.post('/cases/' + str(self.case.id) + '/edit_case/', {'hiddenval': self.case.id})
|
||||
response = self.client.post(
|
||||
'/cases/' + str(self.case.id) + '/edit_case/',
|
||||
{'hiddenval': self.case.id})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_case_update_html(self):
|
||||
response = self.client.post('/cases/' + str(self.case.id) + '/edit_case/', {'hiddenval': self.case.id})
|
||||
response = self.client.post(
|
||||
'/cases/' + str(self.case.id) + '/edit_case/',
|
||||
{'hiddenval': self.case.id})
|
||||
self.assertTemplateUsed(response, 'create_cases.html')
|
||||
|
||||
|
||||
|
|
@ -128,47 +151,61 @@ class CaseFormTestCase(CaseCreation, TestCase):
|
|||
|
||||
def test_case_creation_same_name(self):
|
||||
response = self.client.post('/cases/create/',
|
||||
{'name': 'raghu', 'case_type': 'type', 'status': 'status',
|
||||
'account': self.account, 'contacts': [self.contacts.id],
|
||||
{'name': 'raghu',
|
||||
'case_type': 'type',
|
||||
'status': 'status',
|
||||
'account': self.account,
|
||||
'contacts': [self.contacts.id],
|
||||
'priority': 'priority',
|
||||
'description': 'testingskdjf'})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_case_create_valid(self):
|
||||
response = self.client.post('/cases/create/',
|
||||
{'name': 'name', 'case_type': 'case', 'status': 'status',
|
||||
'account': self.account, 'contacts': [self.contacts.id],
|
||||
{'name': 'name',
|
||||
'case_type': 'case',
|
||||
'status': 'status',
|
||||
'account': self.account,
|
||||
'contacts': [self.contacts.id],
|
||||
'priority': 'priotiy',
|
||||
'description': 'tejkskjdsa'
|
||||
})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_close_case(self):
|
||||
response = self.client.post('/cases/close_case/', {'case_id': self.case.id})
|
||||
response = self.client.post(
|
||||
'/cases/close_case/', {'case_id': self.case.id})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_comment_add(self):
|
||||
response = self.client.post('/cases/comment/add/', {'caseid': self.case.id})
|
||||
response = self.client.post(
|
||||
'/cases/comment/add/', {'caseid': self.case.id})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_comment_edit(self):
|
||||
response = self.client.post('/cases/comment/edit/', {'commentid': self.comment.id})
|
||||
response = self.client.post(
|
||||
'/cases/comment/edit/', {'commentid': self.comment.id})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_comment_delete(self):
|
||||
response = self.client.post('/cases/comment/remove/', {'comment_id': self.comment.id})
|
||||
response = self.client.post(
|
||||
'/cases/comment/remove/', {'comment_id': self.comment.id})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
class AttachmentTestCase(CaseCreation,TestCase):
|
||||
|
||||
class AttachmentTestCase(CaseCreation, TestCase):
|
||||
def test_attachment_add(self):
|
||||
response = self.client.post('/cases/attachment/add/', {'caseid': self.case.id})
|
||||
response = self.client.post(
|
||||
'/cases/attachment/add/', {'caseid': self.case.id})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_attachment_delete(self):
|
||||
response = self.client.post('/cases/attachment/remove/', {'attachment_id': self.attachment.id})
|
||||
response = self.client.post(
|
||||
'/cases/attachment/remove/', {'attachment_id': self.attachment.id})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
class SelectViewTestCase(CaseCreation,TestCase):
|
||||
|
||||
class SelectViewTestCase(CaseCreation, TestCase):
|
||||
def test_select_contact(self):
|
||||
response = self.client.get('/cases/select_contacts/')
|
||||
self.assertEqual(response.status_code,200)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
|
|
|||
115
common/tests.py
115
common/tests.py
|
|
@ -2,6 +2,7 @@ from django.test import TestCase
|
|||
from django.test import Client
|
||||
|
||||
from common.models import User, Team, Document
|
||||
from common.forms import *
|
||||
|
||||
|
||||
class ObjectsCreation(object):
|
||||
|
|
@ -11,9 +12,15 @@ class ObjectsCreation(object):
|
|||
is_staff=True, is_admin=True, is_superuser=True, is_active=True)
|
||||
self.user.set_password('admin123')
|
||||
self.user.save()
|
||||
self.user = User.objects.create(first_name="pavan", username='pavan', email='pavan@micropyramid.com',
|
||||
is_staff=True, is_admin=True, is_superuser=True, is_active=False)
|
||||
self.user.set_password('pavan123')
|
||||
self.user.save()
|
||||
# self.user
|
||||
user_login = self.client.login(
|
||||
username='admin@micropyramid.com', password='admin123')
|
||||
self.document = Document.objects.create(title="abc",document_file="1.png",created_by=self.user)
|
||||
self.document = Document.objects.create(
|
||||
title="abc", document_file="1.png", created_by=self.user)
|
||||
|
||||
|
||||
class TestHomePage(ObjectsCreation, TestCase):
|
||||
|
|
@ -23,6 +30,12 @@ class TestHomePage(ObjectsCreation, TestCase):
|
|||
if response.status_code == 200:
|
||||
self.assertIn("Micro", str(response.content))
|
||||
|
||||
# def test_404_page(self):
|
||||
# # print("34792837471239407123742374")
|
||||
# response = self.client.get('/sldkf')
|
||||
# # print(response)
|
||||
# self.assertEqual(response.status_code, 404)
|
||||
|
||||
|
||||
class CommonModelTest(ObjectsCreation, TestCase):
|
||||
|
||||
|
|
@ -44,10 +57,14 @@ class UserCreateTestCase(ObjectsCreation, TestCase):
|
|||
# self.assertEqual(response.status_code,200)
|
||||
|
||||
def test_user_create_invalid(self):
|
||||
response = self.client.post('/users/create/',{'email': 'admin@micropyramid.com', 'first_name': '',
|
||||
'last_name': '', 'username': '', 'role': 'r',
|
||||
'profile_pic': None})
|
||||
self.assertEqual(response.status_code,200)
|
||||
response = self.client.post('/users/create/', {
|
||||
'email': 'admin@micropyramid.com',
|
||||
'first_name': '',
|
||||
'last_name': '',
|
||||
'username': '',
|
||||
'role': 'r',
|
||||
'profile_pic': None})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
class PasswordChangeTestCase(ObjectsCreation, TestCase):
|
||||
|
|
@ -79,7 +96,8 @@ class ForgotPasswordViewTestCase(ObjectsCreation, TestCase):
|
|||
|
||||
|
||||
class LoginViewTestCase(ObjectsCreation, TestCase):
|
||||
|
||||
# user2 = User.objects.create(first_name="pavan", username='pavan', email='pavan@micropyramid.com',
|
||||
# is_staff=True, is_admin=True, is_superuser=True, is_active=False)
|
||||
def test_login_post(self):
|
||||
self.client.logout()
|
||||
data = {"email": "admin@micropyramid.com", "password": "admin123"}
|
||||
|
|
@ -94,7 +112,11 @@ class LoginViewTestCase(ObjectsCreation, TestCase):
|
|||
|
||||
def test_login_inactive(self):
|
||||
self.client.logout()
|
||||
data = {"email": "admin@micropyramid.com", "password": "admin123",'is_active':False}
|
||||
data = {
|
||||
"email": "admin@micropyramid.com",
|
||||
"password": "admin123",
|
||||
'is_active': False
|
||||
}
|
||||
response = self.client.post('/login/', data)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
|
|
@ -102,8 +124,7 @@ class LoginViewTestCase(ObjectsCreation, TestCase):
|
|||
self.client.logout()
|
||||
data = {"email": "abc@abc.com", "password": "123"}
|
||||
response = self.client.post('/login/', data)
|
||||
self.assertEqual(response.status_code,200)
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_logout(self):
|
||||
self.client = Client()
|
||||
|
|
@ -115,11 +136,21 @@ class LoginViewTestCase(ObjectsCreation, TestCase):
|
|||
|
||||
class UserTestCase(ObjectsCreation, TestCase):
|
||||
def test_user_create_url(self):
|
||||
response = self.client.get('/users/create/', {'first_name': 'meghana', 'last_name': "reddy", 'username': 'meghana', 'email': 'meghana@micropyramid.com','password':'meghana123'})
|
||||
response = self.client.get('/users/create/', {
|
||||
'first_name': 'meghana',
|
||||
'last_name': "reddy",
|
||||
'username': 'meghana',
|
||||
'email': 'meghana@micropyramid.com',
|
||||
'password': 'meghana123'})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_user_create_html(self):
|
||||
response = self.client.get('/users/create/', {'first_name': 'meghana', 'last_name': "", 'username': 'meghana', 'email': '','password':'meghana123'})
|
||||
response = self.client.get('/users/create/', {
|
||||
'first_name': 'meghana',
|
||||
'last_name': "",
|
||||
'username': 'meghana',
|
||||
'email': '',
|
||||
'password': 'meghana123'})
|
||||
|
||||
self.assertTemplateUsed(response, 'create.html')
|
||||
|
||||
|
|
@ -129,6 +160,9 @@ class UserListTestCase(ObjectsCreation, TestCase):
|
|||
def test_users_list(self):
|
||||
self.users = User.objects.all()
|
||||
response = self.client.get('/users/list/')
|
||||
# get_img_url = self.users.filter()
|
||||
get_user = User.objects.get(email='admin@micropyramid.com')
|
||||
self.assertEqual(get_user.email, get_user.__unicode__())
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed(response, 'list.html')
|
||||
|
||||
|
|
@ -140,6 +174,7 @@ class UserListTestCase(ObjectsCreation, TestCase):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed(response, 'list.html')
|
||||
|
||||
|
||||
class UserRemoveTestCase(ObjectsCreation, TestCase):
|
||||
def test_users_remove(self):
|
||||
response = self.client.get('/users/' + str(self.user.id) + '/delete/')
|
||||
|
|
@ -150,15 +185,21 @@ class UserRemoveTestCase(ObjectsCreation, TestCase):
|
|||
# response = self.client.get('/users/list/')
|
||||
# self.assertEqual(response.status_code, 302)
|
||||
|
||||
class UserUpdateTestCase(ObjectsCreation,TestCase):
|
||||
|
||||
class UserUpdateTestCase(ObjectsCreation, TestCase):
|
||||
def test_users_update(self):
|
||||
response = self.client.get('/users/' + str(self.user.id) + '/edit/', {
|
||||
'first_name': "admin",'user_name':'admin', 'email': "admin@micropyramid" })
|
||||
'first_name': "admin",
|
||||
'user_name': 'admin',
|
||||
'email': "admin@micropyramid"})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed(response, 'create.html')
|
||||
|
||||
def test_accounts_update_post(self):
|
||||
response = self.client.post('/users/' + str(self.user.id) + '/edit/', {'first_name': "meghana",'user_name':'meghana', 'email': "abc@micropyramid", 'role':"USER",'is_superuser':False })
|
||||
response = self.client.post('/users/' + str(self.user.id) + '/edit/',
|
||||
{'first_name': "meghana", 'user_name': 'meghana',
|
||||
'email': "abc@micropyramid",
|
||||
'role': "USER", 'is_superuser': False})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed(response, 'create.html')
|
||||
|
||||
|
|
@ -182,20 +223,50 @@ class UserUpdateTestCase(ObjectsCreation,TestCase):
|
|||
# repsonse = self.client.post(url,data)
|
||||
# self.assertEqual(response.status_code,200)
|
||||
|
||||
class ProfileViewTestCase(ObjectsCreation,TestCase):
|
||||
|
||||
class ProfileViewTestCase(ObjectsCreation, TestCase):
|
||||
def test_profile_view(self):
|
||||
url = "/profile/"
|
||||
response = self.client.get(url)
|
||||
self.assertEqual(response.status_code,200)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
class UserDetailView(ObjectsCreation,TestCase):
|
||||
|
||||
class UserDetailView(ObjectsCreation, TestCase):
|
||||
def test_user_detail(self):
|
||||
url = "/users/"+str(self.user.id)+"/view/"
|
||||
url = "/users/" + str(self.user.id) + "/view/"
|
||||
response = self.client.get(url)
|
||||
self.assertEqual(response.status_code,200)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
class DocumentDetailView(ObjectsCreation,TestCase):
|
||||
|
||||
class DocumentDetailView(ObjectsCreation, TestCase):
|
||||
def test_document_detail(self):
|
||||
url = "/documents/"+str(self.document.id)+"/view/"
|
||||
url = "/documents/" + str(self.document.id) + "/view/"
|
||||
repsonse = self.client.get(url)
|
||||
self.assertEqual(repsonse.status_code,200)
|
||||
get_title = Document.objects.get(title='abc')
|
||||
self.assertEqual(get_title.title, str(self.document))
|
||||
# print('-----------------',self.document.title)
|
||||
self.assertEqual(repsonse.status_code, 200)
|
||||
|
||||
|
||||
class CreateCommentFile(TestCase):
|
||||
def test_invalid_user_form(self):
|
||||
fields = ['email', 'first_name', 'last_name',
|
||||
'username', 'role', 'profile_pic']
|
||||
user1 = User.objects.create(username='teja',
|
||||
first_name='teja',
|
||||
last_name='reddy',
|
||||
email='tr@mp.com',
|
||||
role='USER',
|
||||
profile_pic="",
|
||||
password='123')
|
||||
data = {'email': user1.email, 'first_name': user1.first_name,
|
||||
'last_name': user1.last_name,
|
||||
'username': user1.username, 'role': user1.role,
|
||||
'profile_pic': user1.profile_pic,
|
||||
'password': user1.password}
|
||||
form = UserForm(data=data)
|
||||
userr = User.objects.get(username='teja')
|
||||
# print(userr)
|
||||
self.assertEqual(len(userr.password), 3)
|
||||
self.assertFalse(form.is_valid())
|
||||
# self.assertTrue(form.)
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ class Migration(migrations.Migration):
|
|||
('teams', models.ManyToManyField(to='common.Team')),
|
||||
],
|
||||
),
|
||||
|
||||
# migrations.AlterUniqueTogether(
|
||||
# name='contact',
|
||||
# unique_together={('email',)},
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from django.test import TestCase
|
||||
from contacts.models import Contact
|
||||
from accounts.models import Account
|
||||
from common.models import Address, User,Comment, Attachments
|
||||
from common.models import Address, User, Comment, Attachments
|
||||
from cases.models import Case
|
||||
from django.test import Client
|
||||
from django.urls import reverse
|
||||
|
|
@ -10,28 +10,52 @@ from django.urls import reverse
|
|||
class ContactObjectsCreation(object):
|
||||
def setUp(self):
|
||||
self.client = Client()
|
||||
self.user = User.objects.create(first_name="navaneetha", username='navaneetha', email="n@mp.com", role="ADMIN")
|
||||
self.user = User.objects.create(
|
||||
first_name="navaneetha",
|
||||
username='navaneetha',
|
||||
email="n@mp.com",
|
||||
role="ADMIN")
|
||||
self.user.set_password('navi123')
|
||||
self.user.save()
|
||||
self.address = Address.objects.create(street="kphb 5th phase", city="hyd", state="telanagana", postcode=502279, country="AD")
|
||||
self.address = Address.objects.create(
|
||||
street="kphb 5th phase",
|
||||
city="hyd",
|
||||
state="telanagana",
|
||||
postcode=502279, country="AD")
|
||||
self.account = Account.objects.create(
|
||||
name="account", email="account@gmail.com", phone="12345", billing_address=self.address,
|
||||
shipping_address=self.address, website="account.com", industry="IT", description="account", created_by=self.user)
|
||||
name="account",
|
||||
email="account@gmail.com",
|
||||
phone="12345",
|
||||
billing_address=self.address,
|
||||
shipping_address=self.address,
|
||||
website="account.com",
|
||||
industry="IT",
|
||||
description="account",
|
||||
created_by=self.user)
|
||||
self.contact = Contact.objects.create(
|
||||
first_name="contact", email="contact@gmail.com", phone="12345", account=self.account,
|
||||
address=self.address, description="contact", created_by=self.user)
|
||||
first_name="contact",
|
||||
email="contact@gmail.com",
|
||||
phone="12345", account=self.account,
|
||||
address=self.address,
|
||||
description="contact",
|
||||
created_by=self.user)
|
||||
self.contact.assigned_to.add(self.user)
|
||||
self.case = Case.objects.create(
|
||||
name="raghu", case_type="Problem", status="New", account=self.account,
|
||||
priority="Low", description="something",
|
||||
created_by=self.user, closed_on="2016-05-04")
|
||||
name="raghu",
|
||||
case_type="Problem",
|
||||
status="New",
|
||||
account=self.account,
|
||||
priority="Low",
|
||||
description="something",
|
||||
created_by=self.user,
|
||||
closed_on="2016-05-04")
|
||||
self.comment = Comment.objects.create(
|
||||
comment='testikd', case=self.case,
|
||||
commented_by=self.user
|
||||
)
|
||||
self.attachment = Attachments.objects.create(
|
||||
attachment='image.png', case=self.case,
|
||||
created_by=self.user,account=self.account
|
||||
created_by=self.user, account=self.account
|
||||
)
|
||||
self.client.login(username='n@mp.com', password='navi123')
|
||||
|
||||
|
|
@ -56,7 +80,8 @@ class ContactViewsTestCase(ContactObjectsCreation, TestCase):
|
|||
response = self.client.get('/contacts/list/')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
if response.status_code == 200:
|
||||
self.assertEqual(response.context['contact_obj_list'][0].id, self.contact.id)
|
||||
self.assertEqual(
|
||||
response.context['contact_obj_list'][0].id, self.contact.id)
|
||||
self.assertTrue(response.context['contact_obj_list'])
|
||||
|
||||
def test_contacts_list_html(self):
|
||||
|
|
@ -65,14 +90,22 @@ class ContactViewsTestCase(ContactObjectsCreation, TestCase):
|
|||
|
||||
def test_contacts_create(self):
|
||||
response = self.client.post('/contacts/create/', {
|
||||
'first_name': 'contact','last_name':'reddy', 'email': 'meg@gmail.com', 'phone': '+917898901234',
|
||||
'account': self.account.id, 'address': self.address.id, 'description': 'contact', 'created_by': self.user})
|
||||
'first_name': 'contact',
|
||||
'last_name': 'reddy',
|
||||
'email': 'meg@gmail.com',
|
||||
'phone': '+917898901234',
|
||||
'account': self.account.id,
|
||||
'address': self.address.id,
|
||||
'description': 'contact',
|
||||
'created_by': self.user})
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
def test_contacts_create_html(self):
|
||||
response = self.client.post('/contacts/create/', {
|
||||
'name': 'contact', 'email': 'contact@gmail.com', 'phone': '12345',
|
||||
'account': self.account.id, 'address': self.address, 'description': 'contact'})
|
||||
'account': self.account.id,
|
||||
'address': self.address,
|
||||
'description': 'contact'})
|
||||
self.assertTemplateUsed(response, 'create_contact.html')
|
||||
|
||||
def test_contacts_delete(self):
|
||||
|
|
@ -81,34 +114,50 @@ class ContactViewsTestCase(ContactObjectsCreation, TestCase):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_contacts_delete_location_checking(self):
|
||||
response = self.client.post('/contacts/'+ str(self.contact.id) +'/delete/')
|
||||
response = self.client.post(
|
||||
'/contacts/' + str(self.contact.id) + '/delete/')
|
||||
self.assertEqual(response['location'], '/contacts/list/')
|
||||
|
||||
def test_contacts_edit(self):
|
||||
response = self.client.post('/contacts/'+ str(self.contact.id) +'/edit/', {
|
||||
'name': 'priya', 'email': 'contact@gmail.com', 'phone': '12345',
|
||||
'pk': self.contact.id, 'account': self.account.id, 'address': self.address.id})
|
||||
response = self.client.post(
|
||||
'/contacts/' + str(self.contact.id) + '/edit/', {
|
||||
'name': 'priya',
|
||||
'email': 'contact@gmail.com',
|
||||
'phone': '12345',
|
||||
'pk': self.contact.id,
|
||||
'account': self.account.id,
|
||||
'address': self.address.id})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_contacts_edit_html(self):
|
||||
response = self.client.post('/contacts/'+ str(self.contact.id) +'/edit/', {
|
||||
'name': 'priya', 'email': 'contact@gmail.com', 'phone': '12345',
|
||||
'pk': self.contact.id, 'account': self.account.id, 'address': self.address.id})
|
||||
response = self.client.post(
|
||||
'/contacts/' + str(self.contact.id) + '/edit/', {
|
||||
'name': 'priya',
|
||||
'email': 'contact@gmail.com',
|
||||
'phone': '12345',
|
||||
'pk': self.contact.id,
|
||||
'account': self.account.id,
|
||||
'address': self.address.id})
|
||||
self.assertTemplateUsed(response, 'create_contact.html')
|
||||
|
||||
def test_contacts_view(self):
|
||||
response = self.client.get('/contacts/'+ str(self.contact.id) +'/view/')
|
||||
response = self.client.get(
|
||||
'/contacts/' + str(self.contact.id) + '/view/')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.context['contact_record'].id, self.contact.id)
|
||||
self.assertEqual(
|
||||
response.context['contact_record'].id, self.contact.id)
|
||||
|
||||
def test_contacts_view_html(self):
|
||||
response = self.client.get('/contacts/'+ str(self.contact.id) +'/view/')
|
||||
response = self.client.get(
|
||||
'/contacts/' + str(self.contact.id) + '/view/')
|
||||
self.assertTemplateUsed(response, 'view_contact.html')
|
||||
|
||||
def test_contacts_edit_post(self):
|
||||
response = self.client.get('/contacts/'+ str(self.contact.id) +'/edit/')
|
||||
response = self.client.get(
|
||||
'/contacts/' + str(self.contact.id) + '/edit/')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
class ContactsListTestCase(ContactObjectsCreation, TestCase):
|
||||
|
||||
def test_contacts_list(self):
|
||||
|
|
@ -120,34 +169,47 @@ class ContactsListTestCase(ContactObjectsCreation, TestCase):
|
|||
def test_contacts_list_queryset(self):
|
||||
self.account = Account.objects.all()
|
||||
data = {'fist_name': 'contact',
|
||||
'city': "hyd", 'phone':'12345','email':"contact@gmail.com"}
|
||||
'city': "hyd", 'phone': '12345', 'email': "contact@gmail.com"}
|
||||
response = self.client.post('/contacts/list/', data)
|
||||
# get_contact = Contact.objects.get(first_name__ic='contact')
|
||||
# get_id = Account.objects.get(id=get_contact.account_id)
|
||||
# # print(get_contact.account_id, "22")
|
||||
# self.assertEqual(get_contact.account_id, get_id.id)
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed(response, 'contacts.html')
|
||||
|
||||
|
||||
class CommentTestCase(ContactObjectsCreation, TestCase):
|
||||
def test_comment_add(self):
|
||||
response = self.client.post('/contacts/comment/add/', {'contactid': self.contact.id})
|
||||
response = self.client.post(
|
||||
'/contacts/comment/add/', {'contactid': self.contact.id})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_comment_edit(self):
|
||||
response = self.client.post('/contacts/comment/edit/', {'commentid': self.comment.id})
|
||||
response = self.client.post(
|
||||
'/contacts/comment/edit/', {'commentid': self.comment.id})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_comment_delete(self):
|
||||
response = self.client.post('/contacts/comment/remove/', {'comment_id': self.comment.id})
|
||||
response = self.client.post(
|
||||
'/contacts/comment/remove/', {'comment_id': self.comment.id})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
class AttachmentTestCase(ContactObjectsCreation,TestCase):
|
||||
|
||||
class AttachmentTestCase(ContactObjectsCreation, TestCase):
|
||||
def test_attachment_add(self):
|
||||
response = self.client.post('/contacts/attachment/add/', {'contactid': self.contact.id})
|
||||
response = self.client.post(
|
||||
'/contacts/attachment/add/', {'contactid': self.contact.id})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_attachment_valid(self):
|
||||
response = self.client.post('/contacts/attachment/add/', {'contactid': self.contact.id})
|
||||
response = self.client.post(
|
||||
'/contacts/attachment/add/', {'contactid': self.contact.id})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_attachment_delete(self):
|
||||
response = self.client.post('/contacts/attachment/remove/', {'attachment_id': self.attachment.id})
|
||||
response = self.client.post(
|
||||
'/contacts/attachment/remove/',
|
||||
{'attachment_id': self.attachment.id})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,40 +2,72 @@ from django.test import TestCase
|
|||
from django.test import Client
|
||||
from common.models import User
|
||||
from emails.models import Email
|
||||
|
||||
from emails.forms import EmailForm
|
||||
|
||||
|
||||
class UserCreation(TestCase):
|
||||
def setUp(self):
|
||||
self.client = Client()
|
||||
self.user = User.objects.create(first_name="navaneetha", username='navaneetha', email="n@mp.com", role="ADMIN")
|
||||
self.user = User.objects.create(
|
||||
first_name="navaneetha", username='navaneetha', email="n@mp.com", role="ADMIN")
|
||||
self.user.set_password('navi123')
|
||||
self.user.save()
|
||||
self.email = Email.objects.create(from_email = "admin@micropyramid.com", to_email = "meghana@micropyramid.com",subject="wish",message="haii")
|
||||
self.email = Email.objects.create(
|
||||
from_email="admin@micropyramid.com", to_email="meghana@micropyramid.com", subject="wish", message="haii",
|
||||
important=False)
|
||||
self.client.login(username='n@mp.com', password='navi123')
|
||||
|
||||
class EmailListTestCase(UserCreation,TestCase):
|
||||
|
||||
class EmailSentEdit(UserCreation, TestCase):
|
||||
def test_edit_form_valid(self):
|
||||
form = EmailForm(data={'from_email': "abc@mp.com",
|
||||
'to_email': "xyz@mp.com",
|
||||
'subject': "hello hi",
|
||||
'message': 'simple mail'})
|
||||
print('yes')
|
||||
self.assertTrue(form.is_valid())
|
||||
|
||||
def test_edit_form_invalid(self):
|
||||
form = EmailForm(data={'from_email': "abc@mp.com",
|
||||
'to_email': "",
|
||||
'subject': "hello hi",
|
||||
'message': 'simple mail'})
|
||||
print('yes2')
|
||||
self.assertFalse(form.is_valid())
|
||||
|
||||
|
||||
class EmailListTestCase(UserCreation, TestCase):
|
||||
def test_email_list(self):
|
||||
url = "/emails/list/"
|
||||
response = self.client.get(url)
|
||||
self.assertEqual(response.status_code,200)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
class EmailTestCase(UserCreation, TestCase):
|
||||
def test_email_send(self):
|
||||
url = "/emails/compose/"
|
||||
data = {'from_email':"abc@micropyramid.com", 'to_email':"meg@gmail.com",'subject':'act','message':"Hello"}
|
||||
response = self.client.post(url,data)
|
||||
self.assertEqual(response.status_code,302)
|
||||
data = {
|
||||
'from_email': "abc@micropyramid.com", 'to_email': "meg@gmail.com",
|
||||
'subject': 'act', 'message': "Hello"
|
||||
}
|
||||
response = self.client.post(url, data)
|
||||
get_email = Email.objects.get(subject="wish")
|
||||
# boo = Email.objects.get(important=True)
|
||||
# print('yes')
|
||||
self.assertFalse(get_email.important)
|
||||
self.assertEqual(get_email.subject, get_email.__unicode__())
|
||||
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
def test_email_sent(self):
|
||||
url = "/emails/email_sent/"
|
||||
response = self.client.get(url)
|
||||
self.assertEqual(response.status_code,200)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_email_trash(self):
|
||||
url = "/emails/email_trash/"
|
||||
response = self.client.get(url)
|
||||
self.assertEqual(response.status_code,200)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# def test_email_trash_del(self):
|
||||
# url = "/emails/trash_delete/"+str(self.email.pk)+"/$"
|
||||
|
|
|
|||
|
|
@ -10,27 +10,21 @@ from accounts.models import Tags
|
|||
|
||||
|
||||
class Lead(models.Model):
|
||||
title = models.CharField(
|
||||
pgettext_lazy("Treatment Pronouns for the customer", "Title"),
|
||||
max_length=64, blank=True, null=True)
|
||||
title = models.CharField(pgettext_lazy("Treatment Pronouns for the customer", "Title"), max_length=64, blank=True, null=True)
|
||||
first_name = models.CharField(("First name"), max_length=255)
|
||||
last_name = models.CharField(("Last name"), max_length=255)
|
||||
email = models.EmailField()
|
||||
phone = PhoneNumberField(null=True, blank=True)
|
||||
account = models.ForeignKey(Account, related_name='Leads', on_delete=models.CASCADE, blank=True, null=True)
|
||||
status = models.CharField(_("Status of Lead"), max_length=255,
|
||||
blank=True, null=True, choices=LEAD_STATUS)
|
||||
source = models.CharField(_("Source of Lead"), max_length=255,
|
||||
blank=True, null=True, choices=LEAD_SOURCE)
|
||||
status = models.CharField(_("Status of Lead"), max_length=255, blank=True, null=True, choices=LEAD_STATUS)
|
||||
source = models.CharField(_("Source of Lead"), max_length=255, blank=True, null=True, choices=LEAD_SOURCE)
|
||||
address = models.ForeignKey(Address, related_name='leadaddress', on_delete=models.CASCADE, null=True, blank=True)
|
||||
website = models.CharField(_("Website"), max_length=255, blank=True, null=True)
|
||||
description = models.TextField(blank=True, null=True)
|
||||
assigned_to = models.ManyToManyField(User, related_name='lead_assigned_users')
|
||||
teams = models.ManyToManyField(Team)
|
||||
account_name = models.CharField(max_length=255, null=True, blank=True)
|
||||
opportunity_amount = models.DecimalField(
|
||||
_("Opportunity Amount"), decimal_places=2, max_digits=12,
|
||||
blank=True, null=True)
|
||||
opportunity_amount = models.DecimalField(_("Opportunity Amount"), decimal_places=2, max_digits=12, blank=True, null=True)
|
||||
created_by = models.ForeignKey(User, related_name='lead_created_by', on_delete=models.CASCADE)
|
||||
created_on = models.DateTimeField(_("Created on"), auto_now_add=True)
|
||||
is_active = models.BooleanField(default=False)
|
||||
|
|
@ -38,7 +32,7 @@ class Lead(models.Model):
|
|||
tags = models.ManyToManyField(Tags, blank=True)
|
||||
|
||||
class Meta:
|
||||
ordering =['-created_on']
|
||||
ordering = ['-created_on']
|
||||
|
||||
def __str__(self):
|
||||
return self.first_name + self.last_name
|
||||
|
|
|
|||
|
|
@ -84,6 +84,9 @@ class LeadsPostrequestTestCase(TestLeadModel, TestCase):
|
|||
|
||||
def test_leads_list(self):
|
||||
self.lead = Lead.objects.all()
|
||||
get_name = Lead.objects.get(first_name='anjali')
|
||||
# print(get_name.first_name+get_name.last_name,str(get_name))
|
||||
self.assertEqual(get_name.first_name + get_name.last_name, str(get_name))
|
||||
response = self.client.get('/leads/list/')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
|
|
|||
|
|
@ -129,6 +129,12 @@ class OpportunityListView(OpportunityModel,TestCase):
|
|||
data = {'name': 'madhurima','stage': 'city',
|
||||
'lead_source': 'Call', 'accounts':self.account}
|
||||
response = self.client.post('/opportunities/list/', data)
|
||||
get_opp_val = Opportunity.objects.get(lead_source='Call')
|
||||
self.assertEqual(get_opp_val.lead_source,'Call')
|
||||
self.assertEqual(get_opp_val.name,str(get_opp_val))
|
||||
get_contact = Contact.objects.get(last_name="s")
|
||||
self.assertEqual(get_contact.last_name,"s")
|
||||
# self.assertEqual(get_opp_val.lead_source,'call')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed(response, 'opportunity.html')
|
||||
|
||||
|
|
@ -136,6 +142,8 @@ class ContactGetViewTestCase(OpportunityModel,TestCase):
|
|||
def test_get_contact(self):
|
||||
url = '/opportunities/contacts/'
|
||||
response = self.client.get(url)
|
||||
get_contact = Contact.objects.get(last_name="s")
|
||||
self.assertEqual(get_contact.last_name,"s")
|
||||
self.assertEqual(response.status_code,200)
|
||||
|
||||
class CommentTestCase(OpportunityModel, TestCase):
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# import datetime
|
||||
# from django.utils import timezone
|
||||
# from django.test import TestCase
|
||||
# from planner.models import Event
|
||||
# from django.contrib.auth.models import User
|
||||
import datetime
|
||||
from django.utils import timezone
|
||||
from django.test import TestCase
|
||||
from planner.models import Event
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
# class EventObjects(object):
|
||||
|
|
|
|||
Loading…
Reference in a new issue