Skip to content

Commit

Permalink
Fix team_members stream PK (#157)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
loeakaodas authored Feb 23, 2022
1 parent f1ba2fd commit 3126c9d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion tap_github/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
'project_cards': ['id'],
'repos': ['id'],
'teams': ['id'],
'team_members': ['id'],
'team_members': ['id', 'team_slug'],
'team_memberships': ['url']
}

Expand Down Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions tap_github/schemas/team_members.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@
"null",
"string"
]
},
"team_slug": {
"type": [
"null",
"string"
]
}
}
}
2 changes: 1 addition & 1 deletion tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
12 changes: 5 additions & 7 deletions tests/test_github_automatic_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

0 comments on commit 3126c9d

Please sign in to comment.