def setUp(self): super(BulkResultTestCase, self).setUp() self.url = reverse('simpl_bulk_api:result-list') print(self.url) self.period = PeriodFactory() self.role = RoleFactory() self.view = bulk_views.BulkResultViewSet()
def test_rewind(self, mock_method): # URL pattern: ^scenarios/{pk}/rewind/$ Name: 'scenario-rewind' url = reverse('simpl_api:scenario-rewind', kwargs={'pk': self.scenario.pk}) # add period1 and period2 to scenario period1 = PeriodFactory.create(scenario=self.scenario) period1.order = 1 period2 = PeriodFactory.create(scenario=self.scenario, order=2) period2.order = 2 # add decision to period1 decision = DecisionFactory.create(period=period1) # add result to period1 result = ResultFactory.create(period=period1) payload = { 'period_order': 1, 'delete_period_decisions': False, 'delete_result_decisions': True } # Does this api work without auth? response = self.client.post(url, payload, format='json') self.assertEqual(response.status_code, 401) # Does this api work with auth? self.login(self.user) # 'twould appear factory objects are not useful for testing rewind response = self.client.post(url, payload, format='json') self.assertEqual(response.status_code, 204) # should have fired 8 webhooks - including one for user self.assertTrue(mock_method.called) self.assertEqual(mock_method.call_count, 8)
def test_create(self): url = reverse('simpl_api:period-list') scenario = ScenarioFactory() obj = PeriodFactory.build(scenario=scenario) payload = serializers.PeriodSerializer(obj).data # Does this api work without auth? response = self.client.post(url, payload, format='json') self.assertEqual(response.status_code, 401) # Does this api work with auth? with self.login(self.user): response = self.client.post(url, payload, format='json') self.assertEqual(response.status_code, 201) self.assertNotEqual(len(response.data), 0)
def setUp(self): super(PeriodTestCase, self).setUp() self.period = PeriodFactory()
def setUp(self): super(BulkDecisionTestCase, self).setUp() self.url = reverse('simpl_bulk_api:decision-list') self.period = PeriodFactory() self.role = RoleFactory() self.view = bulk_views.BulkDecisionViewSet()