File: //home/arjun/projects/buyercall_forms/buyercall/buyercall/tests/mobile/test_models.py
from buyercall.blueprints.agents.models import Agent
from buyercall.blueprints.mobile.models import Endpoint, Domain
from buyercall.blueprints.phonenumbers import Phone
from buyercall.blueprints.user.models import User
class TestEndpoint(object):
def test_endpoint_create(self, mobiles):
"""test creating a new Endpoint."""
user_account = User.query.filter(User.email == 'admin@localhost.com').first()
phone = Phone.query.first()
agent = Agent.query.first()
domain = Domain.query.first()
if user_account and phone and agent and domain:
params = ('description', 'provider', 'provider_id', 'sip_uri',
'sip_username', 'sip_password', True, phone.id, agent.id,
user_account.partnership_account_id, domain.id, False)
result = Endpoint.create(*params)
assert result
else:
assert False
def test_endpoint_update(self):
"""Test updating a Endpoint."""
endpoint = Endpoint.query.first()
if endpoint:
result = Endpoint.update(
endpoint.id, endpoint.partnership_account_id, 'edited_password',
True, endpoint.agent_id
)
assert result
edited_endpoint = Endpoint.query.filter(Endpoint.id == endpoint.id).first()
assert edited_endpoint.sip_password == 'edited_password'
else:
assert False
def test_api_username_check(self):
"""Test api username check."""
endpoint = Endpoint.query.first()
if endpoint:
result = Endpoint.api_username_check(endpoint.sip_username)
assert result
else:
assert False
def test_deactivate(self):
"""Test endpoint deactivate."""
endpoint = Endpoint.query.first()
if endpoint:
result = Endpoint.deactivate(endpoint.id, endpoint.partnership_account_id)
assert result
deactivated_endpoint = Endpoint.query.filter(Endpoint.id == endpoint.id).first()
assert deactivated_endpoint.is_deactivated == True
else:
assert False