コード例 #1
0
    def test_returns_applications_ids_with_current_status_retry(self, app):
        # given
        import1 = create_beneficiary_import(
            status=ImportStatus.RETRY, demarche_simplifiee_application_id=456)
        import2 = create_beneficiary_import(
            status=ImportStatus.RETRY, demarche_simplifiee_application_id=123)
        user = create_user(email='*****@*****.**')
        import3 = create_beneficiary_import(
            user,
            status=ImportStatus.CREATED,
            demarche_simplifiee_application_id=789)

        PcObject.save(import1, import2, import3)

        # when
        ids = find_applications_ids_to_retry()

        # then
        assert ids == [123, 456]
コード例 #2
0
    def test_returns_an_empty_list_if_no_retry_imports_exist(self, app):
        # given
        import1 = create_beneficiary_import(
            status=ImportStatus.DUPLICATE,
            demarche_simplifiee_application_id=456)
        import2 = create_beneficiary_import(
            status=ImportStatus.ERROR, demarche_simplifiee_application_id=123)
        user = create_user(email='*****@*****.**')
        import3 = create_beneficiary_import(
            user,
            status=ImportStatus.CREATED,
            demarche_simplifiee_application_id=789)

        PcObject.save(import1, import2, import3)

        # when
        ids = find_applications_ids_to_retry()

        # then
        assert not ids
コード例 #3
0
    def test_returns_created_at_date_of_most_recent_beneficiary_import_with_created_status(
            self, app):
        # given
        now = datetime.utcnow()

        yesterday = now - timedelta(days=1)
        two_days_ago = now - timedelta(days=2)
        three_days_ago = now - timedelta(days=3)

        user1 = create_user(email='*****@*****.**', date_created=yesterday)
        user2 = create_user(email='*****@*****.**', date_created=two_days_ago)
        user3 = create_user(email='*****@*****.**', date_created=three_days_ago)
        beneficiary_import2 = create_beneficiary_import(user2, status=ImportStatus.ERROR, date=two_days_ago,
                                                        demarche_simplifiee_application_id=1)
        beneficiary_import3 = create_beneficiary_import(user3, status=ImportStatus.CREATED, date=three_days_ago,
                                                        demarche_simplifiee_application_id=3)

        PcObject.save(user1, beneficiary_import2, beneficiary_import3)

        # when
        most_recent_creation_date = find_most_recent_beneficiary_creation_date()

        # then
        assert most_recent_creation_date == three_days_ago
コード例 #4
0
    def test_returns_false_when_a_beneficiary_import_exist_with_status_retry(
            self, app):
        # given
        now = datetime.utcnow()
        user1 = create_user(email='*****@*****.**', date_created=now)
        beneficiary_import = create_beneficiary_import(
            user1,
            status=ImportStatus.RETRY,
            demarche_simplifiee_application_id=123)

        PcObject.save(beneficiary_import)

        # when
        result = is_already_imported(123)

        # then
        assert result is False