How to use steam - 10 common examples

To help you get started, we’ve selected a few steam examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ValvePython / steam / tests / test_steamid.py View on Github external
# type out of bound
        self.assertFalse(SteamID(1, EType.Max).is_valid())
        # universe out of bound
        self.assertFalse(SteamID(1, universe=EUniverse.Max).is_valid())
        # individual
        self.assertTrue(SteamID(123, EType.Individual, EUniverse.Public, instance=0).is_valid())
        self.assertTrue(SteamID(123, EType.Individual, EUniverse.Public, instance=1).is_valid())
        self.assertTrue(SteamID(123, EType.Individual, EUniverse.Public, instance=2).is_valid())
        self.assertTrue(SteamID(123, EType.Individual, EUniverse.Public, instance=3).is_valid())
        self.assertTrue(SteamID(123, EType.Individual, EUniverse.Public, instance=4).is_valid())
        self.assertFalse(SteamID(123, EType.Individual, EUniverse.Public, instance=5).is_valid())
        self.assertFalse(SteamID(123, EType.Individual, EUniverse.Public, instance=333).is_valid())
        # clan
        self.assertTrue(SteamID(1, EType.Clan, EUniverse.Public, instance=0).is_valid())
        self.assertFalse(SteamID(1, EType.Clan, EUniverse.Public, instance=1).is_valid())
        self.assertFalse(SteamID(1, EType.Clan, EUniverse.Public, instance=1234).is_valid())

        s = SteamID(123, type=EType.Clan, universe=EUniverse.Public, instance=333)
        self.assertFalse(s.is_valid())
github ValvePython / steam / tests / test_steamid.py View on Github external
def test_as_steam2(self):
        self.assertEqual(SteamID('STEAM_0:1:4').as_steam2, 'STEAM_1:1:4')
        self.assertEqual(SteamID('STEAM_1:1:4').as_steam2, 'STEAM_1:1:4')
        self.assertEqual(SteamID('STEAM_0:0:4').as_steam2, 'STEAM_1:0:4')
        self.assertEqual(SteamID('STEAM_1:0:4').as_steam2, 'STEAM_1:0:4')

        self.assertEqual(SteamID('STEAM_4:0:4').as_steam2, 'STEAM_4:0:4')
        self.assertEqual(SteamID('STEAM_4:1:4').as_steam2, 'STEAM_4:1:4')
github ValvePython / steam / tests / test_steamid.py View on Github external
def test_kwarg_type(self):
        with self.assertRaises(KeyError):
            SteamID(id=5, type="doesn't exist")
        with self.assertRaises(ValueError):
            SteamID(id=5, type=99999999)
        with self.assertRaises(KeyError):
            SteamID(id=5, type=None)

        self.assertEqual(SteamID(id=5, type=1).type, EType.Individual)
        self.assertEqual(SteamID(id=5, type='Individual').type, EType.Individual)
        self.assertEqual(SteamID(id=5, type='AnonUser').type, EType.AnonUser)
github ValvePython / steam / tests / test_steamid.py View on Github external
def test_as_steam3(self):
        self.assertEqual(SteamID('[U:1:1234]').as_steam3, '[U:1:1234]')
        self.assertEqual(SteamID('[U:1:1234:56]').as_steam3, '[U:1:1234:56]')
        self.assertEqual(SteamID('[g:1:4]').as_steam3, '[g:1:4]')
        self.assertEqual(SteamID('[A:1:1234:567]').as_steam3, '[A:1:1234:567]')
        self.assertEqual(SteamID('[G:1:1234:567]').as_steam3, '[G:1:1234]')
        self.assertEqual(SteamID('[T:1:1234]').as_steam3, '[T:1:1234]')
        self.assertEqual(SteamID('[c:1:1234]').as_steam3, '[c:1:1234]')
        self.assertEqual(SteamID('[L:1:1234]').as_steam3, '[L:1:1234]')
github ValvePython / steam / tests / test_steamid.py View on Github external
def test_args_only(self):
        self.compare(SteamID(1, 2),
                     [1, 2, 0, 0])
        self.compare(SteamID(1, 2, 3),
                     [1, 2, 3, 0])
        self.compare(SteamID(1, 2, 3, 4),
                     [1, 2, 3, 4])
github ValvePython / steam / tests / test_steamid.py View on Github external
def test_as_steam3(self):
        self.assertEqual(SteamID('[U:1:1234]').as_steam3, '[U:1:1234]')
        self.assertEqual(SteamID('[U:1:1234:56]').as_steam3, '[U:1:1234:56]')
        self.assertEqual(SteamID('[g:1:4]').as_steam3, '[g:1:4]')
        self.assertEqual(SteamID('[A:1:1234:567]').as_steam3, '[A:1:1234:567]')
        self.assertEqual(SteamID('[G:1:1234:567]').as_steam3, '[G:1:1234]')
        self.assertEqual(SteamID('[T:1:1234]').as_steam3, '[T:1:1234]')
        self.assertEqual(SteamID('[c:1:1234]').as_steam3, '[c:1:1234]')
        self.assertEqual(SteamID('[L:1:1234]').as_steam3, '[L:1:1234]')
github ValvePython / steam / tests / test_utils.py View on Github external
def test_proto_fill_from_dict__func_generator(self):
        def number_gen():
            yield 1
            yield 2
            yield 3

        utp.proto_fill_from_dict(self.msg, {'list_number32': number_gen()})
        self.assertEqual(self.msg.list_number32, [1,2,3])
github ValvePython / steam / tests / test_utils.py View on Github external
def test_proto_fill_from_dict__generator(self):
        utp.proto_fill_from_dict(self.msg, {'list_number32': (x for x in [1,2,3])})
        self.assertEqual(self.msg.list_number32, [1,2,3])
github ValvePython / steam / tests / test_utils.py View on Github external
def test_proto_fill_from_dict__dict_filter(self):
        utp.proto_fill_from_dict(self.msg, {'messages': filter(lambda x: True, [{'text': 'one'}, {'text': 'two'}])})
        self.assertEqual(len(self.msg.messages), 2)
        self.assertEqual(self.msg.messages[0].text, 'one')
        self.assertEqual(self.msg.messages[1].text, 'two')
github ValvePython / steam / tests / test_utils.py View on Github external
def test_proto_from_dict_merge_dict(self):
        self.msg.messages.add(text='one')
        self.msg.messages.add(text='two')

        utp.proto_fill_from_dict(self.msg, {'messages': [{'text': 'three'}]}, clear=False)

        self.assertEqual(len(self.msg.messages), 1)
        self.assertEqual(self.msg.messages[0].text, 'three')