Beispiel #1
0
    def fix_failed(self):
        sheet = Sheet(gdstats_sheet)
        failed = sheet.to_df('Failed Players!A1:AN')
        fixed = pd.DataFrame(columns=failed.columns)
        if failed.empty:
            return print("No players found!")
        for row in failed.index:
            username = failed.loc[row, 'Username']
            known = input(f"Do you know who {username} is? (y/n) ")
            if known == "y":
                _id = input("Please type their discord id: ")
                # Add rl id to their account
                found = self.session.all_players.find_one_and_update(
                    {"_id": _id},
                    {"$push": {
                        "rl_id": failed.loc[row, "Discord ID"]
                    }})
                if found:
                    fixed = fixed.append(failed.loc[row])
                    fixed.loc[fixed['Username'] == username,
                              'Discord ID'] = _id
                    fixed.loc[fixed['Username'] == username,
                              'Username'] = found['username']
                    failed.drop(row)

        self.unknown = failed['Username'].values
        sheet.clear("Failed Players!A2:AN")
        self.log_data(fixed.set_index("Discord ID"),
                      f'{dates[get_latest_gameday()]}!A2:Z')
        self.upload_stats(fixed.set_index("Discord ID"))
Beispiel #2
0
        self.assertEqual(
            type(
                test.push_df(
                    'testing!A1:D',
                    pd.DataFrame({
                        'one': 1,
                        'two': 2,
                        'three': 3,
                        'four': 4
                    },
                                 index=[0]))), dict)

    def test_push_fail(self):
        self.assertRaises(
            PushDfError, test.push_df, "test!A1:D",
            pd.DataFrame({
                'one': 1,
                'two': 2,
                'three': 3,
                'four': 4
            },
                         index=[0]), "")

    def test_ensure_recent(self):
        indy.ensure_recent()


if __name__ == '__main__':  # pragma: no cover
    unittest.main()
    test.clear('testing!A1:D')