コード例 #1
0
    def test__model__device__random__multiple_devices(self, random_patch,
                                                      owner_patch, power_patch,
                                                      and_patch):
        self.query_device.filter().order_by(
        ).first.return_value = "random device"
        owner_patch.__ne__.return_value = "owner-ne"

        expected_result = "random device"
        actual_result = Device.random("some user")

        self.assertEqual(expected_result, actual_result)
        owner_patch.__ne__.assert_called_with("some user")
        and_patch.assert_called_with("owner-ne", power_patch)
        random_patch.assert_called_with()
        self.query_device.filter.assert_called_with(and_patch())
        self.query_device.filter().order_by.assert_called_with(random_patch())
コード例 #2
0
ファイル: device.py プロジェクト: cryptic-game/cryptic-device
def spot(data: dict, user: str) -> dict:
    device: Optional[Device] = Device.random(user)
    if device is None:
        return device_not_found

    return device.serialize
コード例 #3
0
def spot(data: dict, user: str) -> dict:
    device: Device = Device.random(user)

    return device.serialize