|
18 | 18 | get_access_token_model, |
19 | 19 | ) |
20 | 20 |
|
21 | | -from apps.test import BaseApiTest, flag_is_active |
| 21 | +from apps.test import BaseApiTest |
22 | 22 | from apps.authorization.models import ( |
23 | 23 | DataAccessGrant, |
24 | 24 | ArchivedDataAccessGrant, |
25 | 25 | check_grants, |
26 | 26 | update_grants, |
27 | 27 | ) |
28 | | -from waffle import get_waffle_flag_model |
29 | | -from waffle.testutils import override_flag, override_switch |
| 28 | +from waffle.testutils import override_switch |
30 | 29 |
|
31 | 30 | Application = get_application_model() |
32 | 31 | AccessToken = get_access_token_model() |
@@ -95,66 +94,14 @@ def test_create_update_delete(self): |
95 | 94 | # Verify expiration_date copied OK. |
96 | 95 | self.assertEqual("2030-01-15 00:00:00+00:00", str(arch_dag.expiration_date)) |
97 | 96 |
|
98 | | - @override_flag("limit_data_access", active=False) |
99 | | - def test_thirteen_month_app_type_without_switch_limit_data_access(self): |
100 | | - assert not flag_is_active("limit_data_access") |
101 | | - |
102 | | - # 1. Create bene and app for tests |
103 | | - dev_user = self._create_user("developer_test", "123456") |
104 | | - bene_user = self._create_user("test_beneficiary", "123456") |
105 | | - test_app = self._create_application( |
106 | | - "test_app", user=dev_user, data_access_type="THIRTEEN_MONTH" |
107 | | - ) |
108 | | - |
109 | | - flag = get_waffle_flag_model().get("limit_data_access") |
110 | | - assert flag.id is None or flag.is_active_for_user(dev_user) is False |
111 | | - |
112 | | - # 2. Create grant with expiration date in future. |
113 | | - dag = DataAccessGrant.objects.create( |
114 | | - application=test_app, beneficiary=bene_user |
115 | | - ) |
116 | | - |
117 | | - # 3. Test expiration_date not set |
118 | | - self.assertEqual(dag.expiration_date, None) |
119 | | - # Test has_expired() with None is false |
120 | | - self.assertEqual(dag.has_expired(), False) |
121 | | - |
122 | | - # 4. Test has_expired() true for -1 hour ago is false w/o switch enabled |
123 | | - dag.expiration_date = datetime.now().replace(tzinfo=pytz.UTC) + relativedelta( |
124 | | - hours=-1 |
125 | | - ) |
126 | | - self.assertEqual(dag.has_expired(), False) |
127 | | - |
128 | | - # 5. Test has_expired() false for +1 hour in future. |
129 | | - dag.expiration_date = datetime.now().replace(tzinfo=pytz.UTC) + relativedelta( |
130 | | - hours=+1 |
131 | | - ) |
132 | | - self.assertEqual(dag.has_expired(), False) |
133 | | - |
134 | | - # 6. Test has_expired() false for ONE_TIME type |
135 | | - test_app.data_access_type = "ONE_TIME" |
136 | | - test_app.save() |
137 | | - self.assertEqual(dag.has_expired(), False) |
138 | | - |
139 | | - # 7. Test has_expired() false for RESEARCH_STUDY type |
140 | | - test_app.data_access_type = "RESEARCH_STUDY" |
141 | | - test_app.save() |
142 | | - self.assertEqual(dag.has_expired(), False) |
143 | | - |
144 | | - @override_flag("limit_data_access", active=True) |
145 | 97 | def test_thirteen_month_app_type_with_switch_limit_data_access(self): |
146 | | - assert flag_is_active("limit_data_access") |
147 | | - |
148 | 98 | # 1. Create bene and app for tests |
149 | 99 | dev_user = self._create_user("developer_test", "123456") |
150 | 100 | bene_user = self._create_user("test_beneficiary", "123456") |
151 | 101 | test_app = self._create_application( |
152 | 102 | "test_app", user=dev_user, data_access_type="THIRTEEN_MONTH" |
153 | 103 | ) |
154 | 104 |
|
155 | | - flag = get_waffle_flag_model().get("limit_data_access") |
156 | | - assert flag.id is not None and flag.is_active_for_user(dev_user) |
157 | | - |
158 | 105 | # 2. Create grant with expiration date in future. |
159 | 106 | dag = DataAccessGrant.objects.create( |
160 | 107 | application=test_app, beneficiary=bene_user |
@@ -463,40 +410,3 @@ def test_permission_deny_on_app_or_org_disabled(self): |
463 | 410 | # set back app and user to active - not to affect other tests |
464 | 411 | application.active = True |
465 | 412 | application.save() |
466 | | - |
467 | | - def test_thirteen_month_app_needs_limit_data_access_set(self): |
468 | | - |
469 | | - # 1. Create benes |
470 | | - dev_user = self._create_user("developer_test", "123456") |
471 | | - bene_user = self._create_user("test_beneficiary", "123456") |
472 | | - flag_bene_user = self._create_user("flag_beneficiary", "123456") |
473 | | - test_app = self._create_application( |
474 | | - "test_app", user=dev_user, data_access_type="THIRTEEN_MONTH" |
475 | | - ) |
476 | | - |
477 | | - # 2. Create flag and show is not set for dev_user |
478 | | - flag = get_waffle_flag_model().objects.create(name="limit_data_access") |
479 | | - assert flag.id is not None |
480 | | - assert not flag.is_active_for_user(dev_user) |
481 | | - |
482 | | - # 3. Create grant and expire expiration to show it doesn't matter |
483 | | - dag = DataAccessGrant.objects.create( |
484 | | - application=test_app, beneficiary=bene_user |
485 | | - ) |
486 | | - # 4. Test has_expired() true for -1 hour ago |
487 | | - dag.expiration_date = datetime.now().replace(tzinfo=pytz.UTC) + relativedelta( |
488 | | - hours=-1 |
489 | | - ) |
490 | | - self.assertEqual(dag.has_expired(), False) |
491 | | - |
492 | | - # 4. Add dev_user to flag |
493 | | - flag.users.add(dev_user) |
494 | | - |
495 | | - # 5. Create new grant and show expiration is working |
496 | | - flag_dag = DataAccessGrant.objects.create( |
497 | | - application=test_app, beneficiary=flag_bene_user |
498 | | - ) |
499 | | - flag_dag.expiration_date = datetime.now().replace( |
500 | | - tzinfo=pytz.UTC |
501 | | - ) + relativedelta(hours=-1) |
502 | | - self.assertEqual(dag.has_expired(), True) |
0 commit comments