def test_editor_locks_are_passed_in_payload_when_another_user_editing(
    inspire_app,
    clean_celery_session,
    enable_disambiguation,
    record_with_two_revisions,
    override_config,
):
    from inspirehep.disambiguation.tasks import disambiguate_authors

    with override_config(FEATURE_FLAG_ENABLE_HAL_PUSH=True):

        celery_task_annotation = MapAnnotation({"countdown": 1.5})

        user = create_user(role=Roles.cataloger.value)

        record = LiteratureRecord.get_record_by_pid_value(111)
        record["authors"] = [{"full_name": "An Author"}]
        record["_export_to"] = {"HAL": True}
        record["external_system_identifiers"] = [{
            "schema": "HAL",
            "value": "HAL-12345678"
        }]
        record.update(dict(record))
        db.session.commit()

        def assert_locks():
            with inspire_app.test_client() as client:
                login_user_via_session(client, email=user.email)
                response = client.get(
                    f'/api/editor/literature/{record["control_number"]}',
                    content_type="application/json",
                )

            assert "task_locks" in response.json
            assert response.json["task_locks"].startswith("Scheduled tasks:")

        retry_until_pass(assert_locks, 0.05)
        resolve_all(celery_task_annotation, disambiguate_authors)
Beispiel #2
0
    def test_annotate_any(self):
        x = MapAnnotation({'*': {'foo': 2}})
        self.assertDictEqual(x.annotate_any(), {'foo': 2})

        x = MapAnnotation()
        self.assertIsNone(x.annotate_any())
Beispiel #3
0
 def test_annotate(self):
     x = MapAnnotation({self.add.name: {'foo': 1}})
     self.assertDictEqual(x.annotate(self.add), {'foo': 1})
     self.assertIsNone(x.annotate(self.mul))
Beispiel #4
0
    def test_annotate_any(self):
        x = MapAnnotation({'*': {"foo": 2}})
        self.assertDictEqual(x.annotate_any(), {"foo": 2})

        x = MapAnnotation()
        self.assertIsNone(x.annotate_any())
Beispiel #5
0
 def test_annotate(self):
     x = MapAnnotation({add.name: {"foo": 1}})
     self.assertDictEqual(x.annotate(add), {"foo": 1})
     self.assertIsNone(x.annotate(mul))
Beispiel #6
0
 def test_annotate(self):
     x = MapAnnotation({add.name: {"foo": 1}})
     self.assertDictEqual(x.annotate(add), {"foo": 1})
     self.assertIsNone(x.annotate(mul))
Beispiel #7
0
 def test_annotate(self):
     x = MapAnnotation({self.add.name: {'foo': 1}})
     self.assertDictEqual(x.annotate(self.add), {'foo': 1})
     self.assertIsNone(x.annotate(self.mul))
    def test_annotate_any(self):
        x = MapAnnotation({'*': {'foo': 2}})
        assert x.annotate_any() == {'foo': 2}

        x = MapAnnotation()
        assert x.annotate_any() is None
 def test_annotate(self):
     x = MapAnnotation({self.add.name: {'foo': 1}})
     assert x.annotate(self.add) == {'foo': 1}
     assert x.annotate(self.mul) is None
Beispiel #10
0
    def test_annotate_any(self):
        x = MapAnnotation({'*': {'foo': 2}})
        assert x.annotate_any() == {'foo': 2}

        x = MapAnnotation()
        assert x.annotate_any() is None
Beispiel #11
0
 def test_annotate(self):
     x = MapAnnotation({self.add.name: {'foo': 1}})
     assert x.annotate(self.add) == {'foo': 1}
     assert x.annotate(self.mul) is None