-
-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89b638e
commit 373df46
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_res_users |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class TestBasePhone(TransactionCase): | ||
def setUp(self): | ||
super().setUp() | ||
self.user = self.env["res.users"].create( | ||
{ | ||
"name": "Demos User", | ||
"login": "[email protected]", | ||
"password": "1234", | ||
} | ||
) | ||
self.asterisk_chan_type = "PJSIP" | ||
self.resource = "6001" | ||
|
||
self.server = self.env["asterisk.server"].create( | ||
{ | ||
"name": "Akretion Server", | ||
"ip_address": "172.17.0.1", | ||
"port": 8088, | ||
"login": "username", | ||
"password": "password", | ||
"context": "from-internal", | ||
} | ||
) | ||
|
||
def test_compute_asterisk_name(self): | ||
self.assertFalse(self.user.asterisk_chan_name) | ||
|
||
self.user.asterisk_chan_type = self.asterisk_chan_type | ||
self.user.resource = self.resource | ||
|
||
self.assertEqual( | ||
self.user.asterisk_chan_name, f"{self.asterisk_chan_type}/{self.resource}" | ||
) | ||
|
||
def test_get_assigned_server_from_user(self): | ||
self.assertFalse(self.user.asterisk_server_id) | ||
|
||
self.user.asterisk_server_id = self.server.id | ||
|
||
server_id = self.user.get_asterisk_server_from_user() | ||
|
||
self.assertEqual(server_id.ip_address, self.server.ip_address) | ||
self.assertEqual(server_id.port, self.server.port) | ||
self.assertEqual(server_id.login, self.server.login) | ||
self.assertEqual(server_id.password, self.server.password) | ||
self.assertEqual(server_id.context, self.server.context) | ||
|
||
def test_get_not_assigned_server_from_user(self): | ||
self.env["asterisk.server"].search( | ||
[("name", "=", "Akretion Asterisk IPBX")] | ||
).unlink() | ||
self.assertFalse(self.user.asterisk_server_id) | ||
|
||
server_id = self.user.get_asterisk_server_from_user() | ||
|
||
self.assertEqual(server_id.ip_address, self.server.ip_address) | ||
self.assertEqual(server_id.port, self.server.port) | ||
self.assertEqual(server_id.login, self.server.login) | ||
self.assertEqual(server_id.password, self.server.password) | ||
self.assertEqual(server_id.context, self.server.context) | ||
self.assertFalse(self.user.asterisk_server_id) |