Commit 0af56043 authored by Jeremy Pallats's avatar Jeremy Pallats 💬
Browse files

FIX #90: Start of cycle ocr refresh put old ocr-ed data ...

- Validation was too strong, preventing lower values of fort and um.
- Added test for ocr_preps.
- Provided text feedback when scheduling !ocr refresh
parent d8d64c11
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1239,6 +1239,7 @@ class OCR(Action):
        if self.args.subcmd == "preps":
            reply = cogdb.query.ocr_prep_report(self.session)
        elif self.args.subcmd == "refresh":  # pragma: no cover
            reply = "OCR Sheet has been read and update pushed to Fort"
            await monitor_ocr_sheet(self.bot, delay=0, repeat=False)

        if reply:
+4 −2
Original line number Diff line number Diff line
@@ -812,8 +812,10 @@ class OCRScanner(FortScanner):

        Returns: A dictionary mapping system names from ALL CAPS to normal eddb name.
        """
        systems_in_sheets = [x.upper() for x in cogdb.eddb.HUDSON_CONTROLS] + \
            [x for x in self.cells_col_major[self.prep_col][2:7] if x]
        with cogdb.session_scope(cogdb.EDDBSession) as eddb_session:
            systems_in_sheets = [x.name.upper() for x in
                                 cogdb.eddb.get_nearest_controls(eddb_session, power='Hudson')]
        systems_in_sheets += [x for x in self.cells_col_major[self.prep_col][2:7] if x]

        # Generate a map for system name correction
        with cogdb.session_scope(cogdb.EDDBSession) as eddb_session:
+1 −1
Original line number Diff line number Diff line
@@ -1090,7 +1090,7 @@ class OCRTracker(Base):
    @sqla_orm.validates('fort', 'um')
    def validate_merits(self, key, value):
        try:
            if value < 0 or value > SENSIBLE_OCR_MERITS or value < getattr(self, key):
            if value < 0 or value > SENSIBLE_OCR_MERITS:
                raise cog.exc.ValidationFail("Bounds check failed for: {} with value {}".format(key, value))
        except TypeError:
            pass
+13 −0
Original line number Diff line number Diff line
@@ -941,6 +941,19 @@ Burr | 2200 | 5800```"""
    assert cog.actions.SCANNERS['hudson_undermine'].payloads == expect


@pytest.mark.asyncio
async def test_cmd_ocr_preps(session, f_bot, f_dusers, f_fort_testbed, f_ocr_testbed):
    msg = fake_msg_gears("!ocr preps")

    await action_map(msg, f_bot).execute()
    expected = """__Hudson Preps Report__

Current Consolidation: 0%

Rhea: 0, updated at 2021-08-25 02:33:00"""
    f_bot.send_message.assert_called_with(msg.channel, expected)


@pytest.mark.asyncio
async def test_cmd_pin(session, f_bot, f_dusers, f_fort_testbed):
    msg = fake_msg_gears("!pin")