"""e2e tests for account creation from api gateway.""" import os from .api_gateway import ApiGateway from .db_connection import DBConnection from .integration_test_helper import IntegrationTestHelper spotify_id = '6o0gT48NdtTQrF5Q5RJJdN' NEO4J_QA = os.environ.get('NEO4J_QA') NEO4J_USER = os.environ.get('NEO4J_USER') NEO4J_PASSWORD = os.environ.get('NEO4J_PASSWORD') AUTO_APPROVE = os.environ.get('AUTO_APPROVE', 'False').lower() == 'true' def assert_profiles_created(conn, email): """Assert identity nodes and profiles.""" data_present = conn.wait_for_label_participant(spotify_id, 40) assert data_present results = conn.get_identity_profiles(email) assert len(results) >= 6 assert results[0]['i.email'] == email for profile in results: assert profile['p.brand'] == 'awal' def test_awal_account_created(get_consumer): """Run test for awal account creation.""" consumer = get_consumer('event.gdaSignup') helper = IntegrationTestHelper() partition, start_position = helper.get_last_partition_position(consumer) conn = DBConnection(NEO4J_QA, NEO4J_USER, NEO4J_PASSWORD) conn.remove_existing_label_participant(spotify_id) conn.close() api_gateway = ApiGateway() email = api_gateway.post_form_to_gda_gateway(spotify_id) consumer.poll(30000) last_position = helper.get_last_partition_position(consumer)[1] assert last_position == start_position + 1 if AUTO_APPROVE: conn.open_connection() assert_profiles_created(conn, email) conn.close()