From 3126c9dc125333451fff6004397c5bcb716c7b64 Mon Sep 17 00:00:00 2001 From: Andrey Kabanov Date: Wed, 23 Feb 2022 14:09:38 -0800 Subject: [PATCH] Fix team_members stream PK (#157) * add `team_slug` as a pk for team members stream * add `team_slug` to schema * add `team_slug` to team members PK in tap-tester * remove team members stream bug info --- tap_github/__init__.py | 3 ++- tap_github/schemas/team_members.json | 6 ++++++ tests/base.py | 2 +- tests/test_github_automatic_fields.py | 12 +++++------- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tap_github/__init__.py b/tap_github/__init__.py index 1f4eebcc..5c2d768a 100644 --- a/tap_github/__init__.py +++ b/tap_github/__init__.py @@ -39,7 +39,7 @@ 'project_cards': ['id'], 'repos': ['id'], 'teams': ['id'], - 'team_members': ['id'], + 'team_members': ['id', 'team_slug'], 'team_memberships': ['url'] } @@ -442,6 +442,7 @@ def get_all_team_members(team_slug, schemas, repo_path, state, mdata): team_members = response.json() for r in team_members: r['_sdc_repository'] = repo_path + r['team_slug'] = team_slug # transform and write release record with singer.Transformer() as transformer: diff --git a/tap_github/schemas/team_members.json b/tap_github/schemas/team_members.json index 82b17bed..b707c5e3 100644 --- a/tap_github/schemas/team_members.json +++ b/tap_github/schemas/team_members.json @@ -117,6 +117,12 @@ "null", "string" ] + }, + "team_slug": { + "type": [ + "null", + "string" + ] } } } \ No newline at end of file diff --git a/tests/base.py b/tests/base.py index 6ea415a4..33c0478a 100644 --- a/tests/base.py +++ b/tests/base.py @@ -176,7 +176,7 @@ def expected_metadata(self): self.OBEYS_START_DATE: False }, "team_members": { - self.PRIMARY_KEYS: {"id"}, + self.PRIMARY_KEYS: {"id", "team_slug"}, self.REPLICATION_METHOD: self.FULL, self.OBEYS_START_DATE: False }, diff --git a/tests/test_github_automatic_fields.py b/tests/test_github_automatic_fields.py index 03ae904f..7a5bc759 100644 --- a/tests/test_github_automatic_fields.py +++ b/tests/test_github_automatic_fields.py @@ -64,10 +64,8 @@ def test_run(self): for actual_keys in record_messages_keys: self.assertSetEqual(expected_keys, actual_keys) - # BUG-TDL-17507 An org can have multiple teams with overlapping membership - if stream != 'team_members': - # Verify that all replicated records have unique primary key values. - self.assertEqual( - len(primary_keys_list), - len(unique_primary_keys_list), - msg="Replicated record does not have unique primary key values.") + # Verify that all replicated records have unique primary key values. + self.assertEqual( + len(primary_keys_list), + len(unique_primary_keys_list), + msg="Replicated record does not have unique primary key values.")