def test_get_file_size(self): filename = Utils.new_tmp_file() with open(filename, 'w') as file: file.write('This string is 28 chars long') self.assertEqual(28, StorageManager.get_file_size(filename))
def test_pack_status(self): pack = Utils.new_tmp_file() Config.encrypted_file = pack encrypted = crypto.encode(b"fooobarr", b"#bellavita", b"foo: bar") with open(pack, "wb") as f: f.write(encrypted) status = self.admin_handler.pack_status() self.assertTrue(status["uploaded"]) self.assertEqual(status["foo"], "bar")
def test_get_input(self): input_path = Utils.new_tmp_file() ContestManager.input_queue["poldo"] = gevent.queue.Queue(1) ContestManager.input_queue["poldo"].put({ "id": "inputid", "path": input_path }) input = ContestManager.get_input("poldo", 42) self.assertEqual("inputid", input[0]) self.assertIn("poldo_input_42.txt", input[1])
def test_missing_db(self): db_path = Utils.new_tmp_file() os.remove(db_path) Config.db = db_path Database.connected = False Database.connect_to_database()
def setUp(self): self.configFilePath = Utils.new_tmp_file() Config.loaded = False