Ejemplo n.º 1
0
 def test_duplicate_member_id_fails_fatally(self):
     c = CustomerFactory()
     UserFactory(name="1001", customer=c)
     UserFactory(name="1001", customer=c)
     
     with self.assertRaises(SystemExit):
         get_multi_access_members(self.session, self.tui, customer_id=c.id)
Ejemplo n.º 2
0
 def test_get_members_ignores_after_whitespace(self):
     c = CustomerFactory()
     UserFactory(name="1001 SUNE", customer=c)
     
     u, = get_multi_access_members(self.session, self.tui, customer_id=c.id)
     
     self.assertEqual(1001, u.member_number)
Ejemplo n.º 3
0
def sync(session=None,
         client=None,
         ui=None,
         customer_id=None,
         authority_id=None,
         what=None,
         ignore_running=False):
    what = what or WHAT_ALL

    # Exit if MultiAccess is running

    if not ignore_running:
        ui.info__progress("checking for running MultiAccess")
        if is_multi_access_running():
            ui.info__progress(
                "looks like MultiAccess is running, please exit MultiAccess and run again"
            )
            return

    # Log in to the MakerAdmin server unless we are already logged in
    if not client.is_logged_in():
        while not client.login():
            pass

    # Run actions on MakerAdmin (ship orders and update key timestamps)

    if WHAT_ORDERS in what:
        client.ship_orders(ui)

    # Fetch from MakerAdmin

    ma_members = client.fetch_members(ui)

    # Fetch relevant data from db and diff it

    db_members = get_multi_access_members(session, ui, customer_id)

    # Diff maker data.

    ui.info__progress('diffing multi access users against maker admin members')
    diffs = []
    if WHAT_UPDATE in what:
        diffs += UpdateMember.find_diffs(db_members, ma_members)
    if WHAT_ADD in what:
        diffs += AddMember.find_diffs(db_members, ma_members)
    if WHAT_BLOCK in what:
        diffs += BlockMember.find_diffs(db_members, ma_members)

    if not diffs:
        ui.info__progress('nothing to update')
        return

    # Present diff of what will be changed

    ui.prompt__update_db(
        heading=f'the following {len(diffs)} changes will be made',
        lines=[d.describe_update() for d in diffs])

    # Preform changes

    update_diffs(session,
                 ui,
                 diffs,
                 customer_id=customer_id,
                 authority_id=authority_id)
    ui.info__progress('finished updating db')

    return
Ejemplo n.º 4
0
 def test_fails_fatally_on_problem_member(self):
     c = CustomerFactory()
     UserFactory(name="SUNE 1001", customer=c)
     
     with self.assertRaises(SystemExit):
         get_multi_access_members(self.session, self.tui, customer_id=c.id)