-
Notifications
You must be signed in to change notification settings - Fork 20
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
Showing
7 changed files
with
179 additions
and
21 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 |
---|---|---|
|
@@ -69,3 +69,4 @@ services: | |
- CHARGEBEE_SITE_API_KEY=test_31lcdE7L3grqdkGcvy24ik3lmlJrnA0Ez | ||
- CHARGEBEE_SITE=toladata-test | ||
- TOLA_TRACK_SYNC_ENABLED=False | ||
- [email protected] |
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
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
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,36 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.3 on 2018-03-02 16:14 | ||
from __future__ import unicode_literals | ||
|
||
from decimal import Decimal | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('workflow', '0017_auto_20180226_0031'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='budget', | ||
name='actual_value', | ||
field=models.DecimalField(blank=True, decimal_places=2, default=Decimal('0.00'), help_text='Monetary value positive or negative', max_digits=12, verbose_name='Actual'), | ||
), | ||
migrations.AlterField( | ||
model_name='budget', | ||
name='proposed_value', | ||
field=models.DecimalField(blank=True, decimal_places=2, default=Decimal('0.00'), help_text='Approximate value if not a monetary fund', max_digits=12, verbose_name='Budget'), | ||
), | ||
migrations.AlterField( | ||
model_name='historicalbudget', | ||
name='actual_value', | ||
field=models.DecimalField(blank=True, decimal_places=2, default=Decimal('0.00'), help_text='Monetary value positive or negative', max_digits=12, verbose_name='Actual'), | ||
), | ||
migrations.AlterField( | ||
model_name='historicalbudget', | ||
name='proposed_value', | ||
field=models.DecimalField(blank=True, decimal_places=2, default=Decimal('0.00'), help_text='Approximate value if not a monetary fund', max_digits=12, verbose_name='Budget'), | ||
), | ||
] |
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
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
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
from chargebee import Addon, Subscription | ||
except ImportError: | ||
pass | ||
from django.core import mail | ||
from django.test import TestCase, override_settings, tag | ||
from mock import Mock, patch | ||
|
||
|
@@ -109,7 +110,7 @@ def __init__(self, values): | |
|
||
addon = Addon(values) | ||
addon.id = 'user' | ||
addon.quantity = 0 | ||
addon.quantity = 1 | ||
self.subscription.addons = [addon] | ||
|
||
def setUp(self): | ||
|
@@ -216,6 +217,34 @@ def test_check_seats_save_team_org_admin(self): | |
organization = Organization.objects.get(pk=self.org.id) | ||
self.assertEqual(organization.chargebee_used_seats, 1) | ||
|
||
@override_settings(DEFAULT_REPLY_TO='[email protected]') | ||
def test_check_seats_save_team_exceed_notify(self): | ||
self.tola_user.user.groups.add(self.group_org_admin) | ||
self.tola_user.user.save() | ||
self.org = Organization.objects.get(pk=self.org.id) | ||
user = factories.User(first_name='John', last_name='Lennon') | ||
tolauser = factories.TolaUser(user=user, organization=self.org) | ||
|
||
external_response = self.ExternalResponse(None) | ||
Subscription.retrieve = Mock(return_value=external_response) | ||
wflvl1 = factories.WorkflowLevel1(name='WorkflowLevel1') | ||
factories.WorkflowTeam(workflow_user=tolauser, | ||
workflowlevel1=wflvl1, | ||
role=self.group_program_admin) | ||
|
||
# It should notify the OrgAdmin | ||
organization = Organization.objects.get(pk=self.org.id) | ||
self.assertEqual(organization.chargebee_used_seats, 2) | ||
self.assertEqual(len(mail.outbox), 1) | ||
self.assertIn('Exceeded the number of editors', mail.outbox[0].subject) | ||
self.assertEqual(mail.outbox[0].to, [user.email]) | ||
self.assertEqual(mail.outbox[0].reply_to, ['[email protected]']) | ||
self.assertEqual(mail.outbox[0].body, | ||
'The number of editors has exceeded the amount of ' | ||
'users set in your Subscription. Please check it ' | ||
'out!\nCurrent amount of editors: 2.\nSelected ' | ||
'amount of editors: 1.') | ||
|
||
|
||
class CheckSeatsDeleteWFTeamsTest(TestCase): | ||
class ExternalResponse: | ||
|
@@ -225,7 +254,7 @@ def __init__(self, values): | |
|
||
addon = Addon(values) | ||
addon.id = 'user' | ||
addon.quantity = 0 | ||
addon.quantity = 1 | ||
self.subscription.addons = [addon] | ||
|
||
def setUp(self): | ||
|
@@ -251,7 +280,7 @@ def test_check_seats_delete_team_decrease(self): | |
organization = Organization.objects.get(pk=self.org.id) | ||
self.assertEqual(organization.chargebee_used_seats, 0) | ||
|
||
def test_check_seats_save_team_not_decrease(self): | ||
def test_check_seats_delete_team_not_decrease(self): | ||
external_response = self.ExternalResponse(None) | ||
Subscription.retrieve = Mock(return_value=external_response) | ||
wflvl1_1 = factories.WorkflowLevel1(name='WorkflowLevel1_1') | ||
|
@@ -310,7 +339,7 @@ def __init__(self, values): | |
|
||
addon = Addon(values) | ||
addon.id = 'user' | ||
addon.quantity = 0 | ||
addon.quantity = 1 | ||
self.subscription.addons = [addon] | ||
|
||
def setUp(self): | ||
|
@@ -378,6 +407,32 @@ def test_check_seats_save_user_groups_demo(self, mock_tsync): | |
organization = Organization.objects.get(pk=self.org.id) | ||
self.assertEqual(organization.chargebee_used_seats, 0) | ||
|
||
@override_settings(DEFAULT_REPLY_TO='[email protected]') | ||
def test_check_seats_save_user_groups_exceed_notify(self): | ||
external_response = self.ExternalResponse(None) | ||
Subscription.retrieve = Mock(return_value=external_response) | ||
self.tola_user.user.groups.add(self.group_org_admin) | ||
self.tola_user.user.save() | ||
|
||
self.org = Organization.objects.get(pk=self.org.id) | ||
user = factories.User(first_name='John', last_name='Lennon') | ||
tolauser = factories.TolaUser(user=user, organization=self.org) | ||
tolauser.user.groups.add(self.group_org_admin) | ||
tolauser.user.save() | ||
|
||
# It should notify the OrgAdmin | ||
organization = Organization.objects.get(pk=self.org.id) | ||
self.assertEqual(organization.chargebee_used_seats, 2) | ||
self.assertEqual(len(mail.outbox), 1) | ||
self.assertIn('Exceeded the number of editors', mail.outbox[0].subject) | ||
self.assertEqual(mail.outbox[0].to, [user.email]) | ||
self.assertEqual(mail.outbox[0].reply_to, ['[email protected]']) | ||
self.assertEqual(mail.outbox[0].body, | ||
'The number of editors has exceeded the amount of ' | ||
'users set in your Subscription. Please check it ' | ||
'out!\nCurrent amount of editors: 2.\nSelected ' | ||
'amount of editors: 1.') | ||
|
||
|
||
class SignalSyncTrackTest(TestCase): | ||
def setUp(self): | ||
|