def test_platform_garbage(self, garbage): """ Verifies a TypeError is raised when attempting to set Rat.platform to garbage Args: garbage (): """ my_rat = Rat(None, "potato", Platforms.PC) with pytest.raises(TypeError): my_rat.platform = garbage
def rat_good_fx(request) -> Rat: """ Testing fixture containing good and registered rats """ params = request.param myRat = Rat(params[2], name=params[0], platform=params[1]) return myRat
def test_constructor_cache(self, rat_cache_fx): """Verifies constructor behavior with a cache present""" uuid = uuid4() rat = Rat(uuid, "unit_test[BOT]", Platforms.PC) assert Platforms.PC == rat.platform assert uuid == rat.uuid assert "unit_test[BOT]" == rat.name assert rat.name in rat_cache_fx.by_name
async def test_find_rat_incorrect_platform(rat_cache_fx, actual, invalids): """ Verifies that `Rat.get_rat_by_name` called with a specific platform that does not match the stored platform returns None """ Rat(name="UNIT_TEST", uuid=None, platform=actual) for platform in invalids: found_rat = await rat_cache_fx.get_rat_by_name(name="UNIT_TEST", platform=platform) assert found_rat is None
async def test_add_rat_by_rat_object(uuid: UUID, name: str, rescue_plain_fx: Rescue): """ Verifies `Rescue.add_rat` can add a rat given a `Rat` object """ # rats_raw = [(uuid4(), "foo"), (uuid4(), "bar"), (uuid4(), "potato")] # rats = [Rat(x, y) for x, y in rats_raw] result_rescue = deepcopy(rescue_plain_fx) rat = Rat(uuid=uuid, name=name) await result_rescue.add_rat(rat=rat) assert rat in result_rescue.rats
def test_name_valid(self, name, rat_good_fx: Rat): rat_good_fx.name = name assert name == rat_good_fx.name
def test_uuid_strings_invalid(self, rat_good_fx: Rat, random_string_fx): with pytest.raises(ValueError): rat_good_fx.uuid = random_string_fx
def rat_no_id_fx(): """ Returns: (Rescue): Rescue test fixture without an api ID """ return Rat(None, "noIdRat")