def test_put_colony_simple(self, version, market, test_app_context: Flask): client = test_app_context.test_client() user_id = make_user(client, version, market) colony_id = make_colony(client, version, market, user_id) url = '/{}/{}/colonies/{}'.format(version, market, colony_id) colony_metadata = { 'BaseName': 'TestBase', 'FactionName': 'TestFaction', 'Planet': 'TestPlanet', 'OwnerType': 'Steam', 'OwnerID': user_id, 'LastGameTick': 1, 'HasSpawned': False } result = client.put(url, data=json.dumps(colony_metadata), mimetype='application/json') assert result.status_code == 200 assert result.json assert result.json['Hash'] == colony_id
def test_put_colony_ban_steam(self, version, market, test_app_context: Flask): client = test_app_context.test_client() user_id = make_user(client, version, market) colony_id = make_colony(client, version, market, user_id) url = '/{}/{}/colonies/{}'.format(version, market, colony_id) colony_metadata = { 'BaseName': 'TestBase', 'FactionName': 'TestFaction', 'Planet': 'TestPlanet', 'OwnerType': 'Steam', 'OwnerID': user_id, 'LastGameTick': 1, 'HasSpawned': True } result = client.put(url, data=json.dumps(colony_metadata), mimetype='application/json') assert result.status_code == 200 # Check the the user is in the moderation queue. redis = g._database assert redis.sismember(consts.KEY_USER_STEAM_ID_MODERATE_SET, user_id)
def test_subscribe(self, version, market, test_app_context: Flask): client = test_app_context.test_client() user_id = make_user(client, version, market) colony_id = make_colony(client, version, market, user_id) # Get token url = '/{}/{}/prime_subscription/check/{}'.format( version, market, colony_id) result = client.get(url, mimetype='application/json') assert result.status_code == 200 assert 'Token' in result.json url = '/{}/{}/prime_subscription/subscribe/{}'.format( version, market, colony_id) post = {'Token': result.json['Token']} result = client.put(url, data=json.dumps(post), mimetype='application/json') assert result.status_code == 200 url = '/{}/{}/prime_subscription/check/{}'.format( version, market, colony_id) result = client.get(url, mimetype='application/json') assert result.status_code == 200 assert result.json assert "TickSubscriptionExpires" in result.json assert "SubscriptionCost" in result.json assert 'Token' in result.json
def test_not_subscribed(self, version, market, test_app_context: Flask): client = test_app_context.test_client() user_id = make_user(client, version, market) colony_id = make_colony(client, version, market, user_id) url = '/{}/{}/prime_subscription/check/{}'.format( version, market, colony_id) result = client.get(url, mimetype='application/json') assert result.status_code == 200 assert "TickSubscriptionExpires" in result.json assert result.json['TickSubscriptionExpires'] == 0
def test_put_create_basic_unknown_user(self, version, market, test_app_context: Flask): client = test_app_context.test_client() user_id = make_user(client, version, market) colony = {'BaseName': 'TestBase', 'FactionName': 'TestFaction', 'Planet': 'TestPlanet', 'OwnerType': 'Unknown', 'OwnerID': user_id, 'LastGameTick': 0} url = '/{}/{}/colonies/create'.format(version, market) result = client.put(url, data=json.dumps(colony), mimetype='application/json') assert result.status_code == 400
def test_get_colony(self, version, market, test_app_context: Flask): client = test_app_context.test_client() user_id = make_user(client, version, market) colony_id = make_colony(client, version, market, user_id) url = '/{}/{}/colonies/{}'.format(version, market, colony_id) result = client.get(url, mimetype='application/json') assert result.status_code == 200 assert result.json client_expects = {'BaseName', 'FactionName', 'Planet', 'OwnerID', 'OwnerType', 'Hash'} got = set(result.json.keys()) assert client_expects.issubset(got)
def test_put_colony_mod_list(self, version, market, test_app_context: Flask): client = test_app_context.test_client() user_id = make_user(client, version, market) colony_id = make_colony(client, version, market, user_id) url = '/{}/{}/colonies/{}/mod_metadata'.format(version, market, colony_id) colony_metadata = { 'ModList': ["Core", "GlitterWorldPrime [R1]"] } payload = io.BytesIO(gzip.compress(json.dumps(colony_metadata).encode('utf-8'))) result = client.put(url, data={'mods': (payload, 'mods')}) assert result.status_code == 200
def test_subscribe_no_token(self, version, market, test_app_context: Flask): client = test_app_context.test_client() user_id = make_user(client, version, market) colony_id = make_colony(client, version, market, user_id) url = '/{}/{}/prime_subscription/subscribe/{}'.format( version, market, colony_id) result = client.put(url, data='{}', mimetype='application/json') assert result.status_code == 400 result = client.put(url, data=json.dumps({'Token': ''}), mimetype='application/json') assert result.status_code == 400
def test_put_colony_thing_list(self, version, market, test_app_context: Flask): client = test_app_context.test_client() user_id = make_user(client, version, market) colony_id = make_colony(client, version, market, user_id) url = '/{}/{}/colonies/{}/thing_metadata'.format( version, market, colony_id) colony_metadata = { 'Locale': 'english', 'Things': get_vanilla_thing_data() } payload = io.BytesIO( gzip.compress(json.dumps(colony_metadata).encode('utf-8'))) result = client.put(url, data={'things': (payload, 'things')}) assert result.status_code == 200
def test_place_order_small_cheat_reset_to_new(self, version, market, test_app_context: Flask): client = test_app_context.test_client() user_id = make_user(client, version, market) colony_id = make_colony(client, version, market, user_id) make_prime(client, version, market, colony_id) #### # Place the order #### url = '/{}/{}/orders/{}'.format(version, market, colony_id) tick = 1 order = {"ThingsSoldToGwp": [ {"BaseMarketValue": 1.2, "CurrentBuyPrice": 9.36, "HitPoints": 140, "MinifiedContainer": False, "Name": "WoodLog", "Quality": "", "Quantity": 1, "StuffType": ""}, {"BaseMarketValue": 1, "CurrentBuyPrice": 1, "HitPoints": -1, "MinifiedContainer": False, "Name": "Silver", "Quality": "", "Quantity": 14, "StuffType": ""}], "ThingsBoughtFromGwp": [ {"BaseMarketValue": 1.9, "CurrentBuyPrice": 14.82, "HitPoints": -1, "MinifiedContainer": False, "Name": "Steel", "Quality": "", "Quantity": 1, "StuffType": ""}], "CurrentGameTick": tick} payload = io.BytesIO(gzip.compress(json.dumps(order).encode('utf-8'))) result = client.put(url, data={'order': (payload, 'order')}) assert result.status_code == 200 #### # Get a list of orders #### url = '/{}/{}/orders/{}?tick={}'.format(version, market, colony_id, tick) result = client.get(url) #### # Get the order metadata #### hash_id = result.json['Orders'][0]['Hash'] url = '/{}/{}/orders/{}/{}'.format(version, market, colony_id, hash_id) result = client.get(url) #### # Update the order status to Processed #### order_status = {'Status': 'processed'} url = '/{}/{}/orders/{}/{}'.format(version, market, colony_id, hash_id) result = client.post(url, data=json.dumps(order_status), content_type=consts.MIME_JSON) assert result.status_code == 200 #### # Try cheating to new #### order_status = {'Status': 'new'} url = '/{}/{}/orders/{}/{}'.format(version, market, colony_id, hash_id) result = client.post(url, data=json.dumps(order_status), content_type=consts.MIME_JSON) assert result.status_code == 400 #### # Update the order status to Done #### order_status = {'Status': 'done'} url = '/{}/{}/orders/{}/{}'.format(version, market, colony_id, hash_id) result = client.post(url, data=json.dumps(order_status), content_type=consts.MIME_JSON) assert result.status_code == 200 #### # Try cheating to new #### order_status = {'Status': 'new'} url = '/{}/{}/orders/{}/{}'.format(version, market, colony_id, hash_id) result = client.post(url, data=json.dumps(order_status), content_type=consts.MIME_JSON) assert result.status_code == 400