def test_ignore_post_save_signal(self):
        dataset = DatasetFactory()
        unexpected_signals = Dataset.after_save, Dataset.on_update

        with assert_not_emit(*unexpected_signals), assert_emit(post_save):
            dataset.title = 'New title'
            dataset.save(signal_kwargs={'ignores': ['post_save']})
Beispiel #2
0
    def test_ignore_post_save_signal(self):
        dataset = DatasetFactory()
        unexpected_signals = Dataset.after_save, Dataset.on_update

        with assert_not_emit(*unexpected_signals), assert_emit(post_save):
            dataset.title = 'New title'
            dataset.save(signal_kwargs={'ignores': ['post_save']})
    def test_ignore_post_save_signal(self):
        resource = ResourceFactory()
        DatasetFactory(resources=[resource])
        unexpected_signals = Dataset.after_save, Dataset.on_update

        with assert_not_emit(*unexpected_signals), assert_emit(post_save):
            resource.title = 'New title'
            resource.save(signal_kwargs={'ignores': ['post_save']})
Beispiel #4
0
    def test_ignore_post_save_signal(self):
        resource = ResourceFactory()
        DatasetFactory(resources=[resource])
        unexpected_signals = Dataset.after_save, Dataset.on_update

        with assert_not_emit(*unexpected_signals), assert_emit(post_save):
            resource.title = 'New title'
            resource.save(signal_kwargs={'ignores': ['post_save']})
Beispiel #5
0
    def test_ignore_post_save_signal(self):
        resource = ResourceFactory()
        # assigning to a variable to avoid garbage collection issue
        _ = DatasetFactory(resources=[resource])
        unexpected_signals = Dataset.after_save, Dataset.on_update

        with assert_not_emit(*unexpected_signals), assert_emit(post_save):
            resource.title = 'New title'
            resource.save(signal_kwargs={'ignores': ['post_save']})
 def test_create_same(self, api):
     data = self.factory.as_dict()
     url = url_for('api.organization_badges', org=self.organization)
     with assert_emit(on_badge_added):
         api.post(url, data)
     with assert_not_emit(on_badge_added):
         response = api.post(url, data)
         assert200(response)
     self.organization.reload()
     assert len(self.organization.badges) is 1
Beispiel #7
0
 def test_create_same(self):
     data = self.factory.as_dict()
     url = url_for('api.organization_badges', org=self.organization)
     with self.api_user():
         with assert_emit(on_badge_added):
             self.post(url, data)
         with assert_not_emit(on_badge_added):
             response = self.post(url, data)
     self.assertStatus(response, 200)
     self.organization.reload()
     self.assertEqual(len(self.organization.badges), 1)
Beispiel #8
0
    def test_updated(self):
        '''It should store the updated metric on "updated" signal'''
        obj = FakeModel.objects.create()
        metric = FakeMetric(obj)
        metric.value = 'some-value'

        with assert_emit(FakeMetric.updated):
            with assert_not_emit(FakeMetric.need_update):
                metric.notify_update()

        metrics = Metrics.objects.last_for(obj)
        assert metrics.values['fake'] == 'some-value'
Beispiel #9
0
    def test_updated(self):
        '''It should store the updated metric on "updated" signal'''
        obj = FakeModel.objects.create()
        metric = FakeMetric(obj)
        metric.value = 'some-value'

        with assert_emit(FakeMetric.updated):
            with assert_not_emit(FakeMetric.need_update):
                metric.notify_update()

        metrics = Metrics.objects.last_for(obj)
        assert metrics.values['fake'] == 'some-value'