/ tests / AuthenticatedUser.py
AuthenticatedUser.py
  1  ############################ Copyrights and license ############################
  2  #                                                                              #
  3  # Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net>                 #
  4  # Copyright 2012 Zearin <zearin@gonk.net>                                      #
  5  # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net>                 #
  6  # Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net>                 #
  7  # Copyright 2016 Jannis Gebauer <ja.geb@me.com>                                #
  8  # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com>          #
  9  # Copyright 2017 Balázs Rostás <rostas.balazs@gmail.com>                       #
 10  # Copyright 2017 Jannis Gebauer <ja.geb@me.com>                                #
 11  # Copyright 2018 Jacopo Notarstefano <jacopo.notarstefano@gmail.com>           #
 12  # Copyright 2018 sfdye <tsfdye@gmail.com>                                      #
 13  # Copyright 2018 itsbruce <it.is.bruce@gmail.com>                              #
 14  #                                                                              #
 15  # This file is part of PyGithub.                                               #
 16  # http://pygithub.readthedocs.io/                                              #
 17  #                                                                              #
 18  # PyGithub is free software: you can redistribute it and/or modify it under    #
 19  # the terms of the GNU Lesser General Public License as published by the Free  #
 20  # Software Foundation, either version 3 of the License, or (at your option)    #
 21  # any later version.                                                           #
 22  #                                                                              #
 23  # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
 24  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
 25  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
 26  # details.                                                                     #
 27  #                                                                              #
 28  # You should have received a copy of the GNU Lesser General Public License     #
 29  # along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
 30  #                                                                              #
 31  ################################################################################
 32  
 33  from datetime import datetime, timezone
 34  
 35  import github
 36  
 37  from . import Framework
 38  
 39  
 40  class AuthenticatedUser(Framework.TestCase):
 41      def setUp(self):
 42          super().setUp()
 43          self.user = self.g.get_user()
 44  
 45      def testAttributes(self):
 46          self.assertEqual(
 47              self.user.avatar_url,
 48              "https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
 49          )
 50          self.assertEqual(self.user.bio, "")
 51          self.assertEqual(self.user.blog, "http://vincent-jacques.net")
 52          self.assertEqual(self.user.collaborators, 0)
 53          self.assertEqual(self.user.company, "Criteo")
 54          self.assertEqual(
 55              self.user.created_at,
 56              datetime(2010, 7, 9, 6, 10, 6, tzinfo=timezone.utc),
 57          )
 58          self.assertEqual(self.user.disk_usage, 16692)
 59          self.assertEqual(self.user.email, "vincent@vincent-jacques.net")
 60          self.assertEqual(self.user.followers, 13)
 61          self.assertEqual(self.user.following, 24)
 62          self.assertEqual(self.user.gravatar_id, "b68de5ae38616c296fa345d2b9df2225")
 63          self.assertFalse(self.user.hireable)
 64          self.assertEqual(self.user.html_url, "https://github.com/jacquev6")
 65          self.assertEqual(self.user.id, 327146)
 66          self.assertEqual(self.user.location, "Paris, France")
 67          self.assertEqual(self.user.login, "jacquev6")
 68          self.assertEqual(self.user.name, "Vincent Jacques")
 69          self.assertEqual(self.user.owned_private_repos, 5)
 70          self.assertEqual(self.user.plan.name, "micro")
 71          self.assertEqual(self.user.plan.collaborators, 1)
 72          self.assertEqual(self.user.plan.space, 614400)
 73          self.assertEqual(self.user.plan.private_repos, 5)
 74          self.assertEqual(self.user.private_gists, 5)
 75          self.assertEqual(self.user.public_gists, 1)
 76          self.assertEqual(self.user.public_repos, 10)
 77          self.assertEqual(self.user.total_private_repos, 5)
 78          self.assertEqual(self.user.type, "User")
 79          self.assertEqual(self.user.url, "https://api.github.com/users/jacquev6")
 80          self.assertEqual(self.user.node_id, "MDQ6VXNlcjMyNzE0Ng==")
 81          self.assertEqual(repr(self.user), 'AuthenticatedUser(login="jacquev6")')
 82          self.assertTrue(self.user.two_factor_authentication)
 83  
 84      def testEditWithoutArguments(self):
 85          self.user.edit()
 86  
 87      def testEditWithAllArguments(self):
 88          self.user.edit(
 89              "Name edited by PyGithub",
 90              "Email edited by PyGithub",
 91              "Blog edited by PyGithub",
 92              "Company edited by PyGithub",
 93              "Location edited by PyGithub",
 94              True,
 95              "Bio edited by PyGithub",
 96          )
 97          self.assertEqual(self.user.name, "Name edited by PyGithub")
 98          self.assertEqual(self.user.email, "Email edited by PyGithub")
 99          self.assertEqual(self.user.blog, "Blog edited by PyGithub")
100          self.assertEqual(self.user.company, "Company edited by PyGithub")
101          self.assertEqual(self.user.location, "Location edited by PyGithub")
102          self.assertTrue(self.user.hireable)
103          self.assertEqual(self.user.bio, "Bio edited by PyGithub")
104  
105      def testEmails(self):
106          emails = self.user.get_emails()
107          self.assertEqual(
108              [item.email for item in emails],
109              ["vincent@vincent-jacques.net", "github.com@vincent-jacques.net"],
110          )
111          self.assertTrue(emails[0].primary)
112          self.assertTrue(emails[0].verified)
113          self.assertEqual(emails[0].visibility, "private")
114          self.user.add_to_emails("1@foobar.com", "2@foobar.com")
115          self.assertEqual(
116              [item.email for item in self.user.get_emails()],
117              [
118                  "vincent@vincent-jacques.net",
119                  "1@foobar.com",
120                  "2@foobar.com",
121                  "github.com@vincent-jacques.net",
122              ],
123          )
124          self.user.remove_from_emails("1@foobar.com", "2@foobar.com")
125          self.assertEqual(
126              [item.email for item in self.user.get_emails()],
127              ["vincent@vincent-jacques.net", "github.com@vincent-jacques.net"],
128          )
129  
130      def testFollowing(self):
131          nvie = self.g.get_user("nvie")
132          self.assertListKeyEqual(
133              self.user.get_following(),
134              lambda u: u.login,
135              [
136                  "schacon",
137                  "jamis",
138                  "chad",
139                  "unclebob",
140                  "dabrahams",
141                  "jnorthrup",
142                  "brugidou",
143                  "regisb",
144                  "walidk",
145                  "tanzilli",
146                  "fjardon",
147                  "r3c",
148                  "sdanzan",
149                  "vineus",
150                  "cjuniet",
151                  "gturri",
152                  "ant9000",
153                  "asquini",
154                  "claudyus",
155                  "jardon-u",
156                  "s-bernard",
157                  "kamaradclimber",
158                  "Lyloa",
159                  "nvie",
160              ],
161          )
162          self.assertTrue(self.user.has_in_following(nvie))
163          self.user.remove_from_following(nvie)
164          self.assertFalse(self.user.has_in_following(nvie))
165          self.user.add_to_following(nvie)
166          self.assertTrue(self.user.has_in_following(nvie))
167          self.assertListKeyEqual(
168              self.user.get_followers(),
169              lambda u: u.login,
170              [
171                  "jnorthrup",
172                  "brugidou",
173                  "regisb",
174                  "walidk",
175                  "afzalkhan",
176                  "sdanzan",
177                  "vineus",
178                  "gturri",
179                  "fjardon",
180                  "cjuniet",
181                  "jardon-u",
182                  "kamaradclimber",
183                  "L42y",
184              ],
185          )
186  
187      def testWatching(self):
188          gitflow = self.g.get_user("nvie").get_repo("gitflow")
189          self.assertListKeyEqual(
190              self.user.get_watched(),
191              lambda r: r.name,
192              [
193                  "git",
194                  "boost.php",
195                  "capistrano",
196                  "boost.perl",
197                  "git-subtree",
198                  "git-hg",
199                  "homebrew",
200                  "celtic_knot",
201                  "twisted-intro",
202                  "markup",
203                  "hub",
204                  "gitflow",
205                  "murder",
206                  "boto",
207                  "agit",
208                  "d3",
209                  "pygit2",
210                  "git-pulls",
211                  "django_mathlatex",
212                  "scrumblr",
213                  "developer.github.com",
214                  "python-github3",
215                  "PlantUML",
216                  "bootstrap",
217                  "drawnby",
218                  "django-socketio",
219                  "django-realtime",
220                  "playground",
221                  "BozoCrack",
222                  "FatherBeaver",
223                  "PyGithub",
224                  "django",
225                  "django",
226                  "TestPyGithub",
227              ],
228          )
229          self.assertTrue(self.user.has_in_watched(gitflow))
230          self.user.remove_from_watched(gitflow)
231          self.assertFalse(self.user.has_in_watched(gitflow))
232          self.user.add_to_watched(gitflow)
233          self.assertTrue(self.user.has_in_watched(gitflow))
234  
235      def testStarring(self):
236          gitflow = self.g.get_user("nvie").get_repo("gitflow")
237          self.assertListKeyEqual(
238              self.user.get_starred(),
239              lambda r: r.name,
240              [
241                  "git",
242                  "boost.php",
243                  "capistrano",
244                  "boost.perl",
245                  "git-subtree",
246                  "git-hg",
247                  "homebrew",
248                  "celtic_knot",
249                  "twisted-intro",
250                  "markup",
251                  "hub",
252                  "gitflow",
253                  "murder",
254                  "boto",
255                  "agit",
256                  "d3",
257                  "pygit2",
258                  "git-pulls",
259                  "django_mathlatex",
260                  "scrumblr",
261                  "developer.github.com",
262                  "python-github3",
263                  "PlantUML",
264                  "bootstrap",
265                  "drawnby",
266                  "django-socketio",
267                  "django-realtime",
268                  "playground",
269                  "BozoCrack",
270                  "FatherBeaver",
271                  "amaunet",
272                  "django",
273                  "django",
274                  "moviePlanning",
275                  "folly",
276              ],
277          )
278          self.assertTrue(self.user.has_in_starred(gitflow))
279          self.user.remove_from_starred(gitflow)
280          self.assertFalse(self.user.has_in_starred(gitflow))
281          self.user.add_to_starred(gitflow)
282          self.assertTrue(self.user.has_in_starred(gitflow))
283  
284      def testSubscriptions(self):
285          gitflow = self.g.get_user("nvie").get_repo("gitflow")
286          self.assertListKeyEqual(
287              self.user.get_subscriptions(),
288              lambda r: r.name,
289              [
290                  "gitflow",
291                  "ViDE",
292                  "Boost.HierarchicalEnum",
293                  "QuadProgMm",
294                  "DrawSyntax",
295                  "DrawTurksHead",
296                  "PrivateStuff",
297                  "vincent-jacques.net",
298                  "Hacking",
299                  "C4Planner",
300                  "developer.github.com",
301                  "PyGithub",
302                  "PyGithub",
303                  "django",
304                  "CinePlanning",
305                  "PyGithub",
306                  "PyGithub",
307                  "PyGithub",
308                  "IpMap",
309                  "PyGithub",
310                  "PyGithub",
311                  "PyGithub",
312                  "PyGithub",
313                  "PyGithub",
314                  "PyGithub",
315                  "PyGithub",
316                  "PyGithub",
317                  "PyGithub",
318                  "PyGithub",
319                  "PyGithub",
320                  "PyGithub",
321              ],
322          )
323          self.assertTrue(self.user.has_in_subscriptions(gitflow))
324          self.user.remove_from_subscriptions(gitflow)
325          self.assertFalse(self.user.has_in_subscriptions(gitflow))
326          self.user.add_to_subscriptions(gitflow)
327          self.assertTrue(self.user.has_in_subscriptions(gitflow))
328  
329      def testGetAuthorizations(self):
330          self.assertListKeyEqual(self.user.get_authorizations(), lambda a: a.id, [372294])
331  
332      def testCreateRepository(self):
333          repo = self.user.create_repo(name="TestPyGithub")
334          self.assertEqual(repo.url, "https://api.github.com/repos/jacquev6/TestPyGithub")
335  
336      def testCreateProject(self):
337          project = self.user.create_project(name="TestPyGithub", body="This is the body")
338          self.assertEqual(project.url, "https://api.github.com/projects/4084610")
339  
340      def testCreateRepositoryWithAllArguments(self):
341          repo = self.user.create_repo(
342              name="TestPyGithub",
343              description="Repo created by PyGithub",
344              homepage="http://foobar.com",
345              private=False,
346              has_issues=False,
347              has_projects=False,
348              has_wiki=False,
349              has_downloads=False,
350              allow_squash_merge=False,
351              allow_merge_commit=False,
352              allow_rebase_merge=True,
353              delete_branch_on_merge=False,
354          )
355          self.assertEqual(repo.url, "https://api.github.com/repos/jacquev6/TestPyGithub")
356  
357      def testCreateRepositoryWithAutoInit(self):
358          repo = self.user.create_repo(name="TestPyGithub", auto_init=True, gitignore_template="Python")
359          self.assertEqual(repo.url, "https://api.github.com/repos/jacquev6/TestPyGithub")
360  
361      def testCreateAuthorizationWithoutArguments(self):
362          authorization = self.user.create_authorization()
363          self.assertEqual(authorization.id, 372259)
364  
365      def testCreateAuthorizationWithAllArguments(self):
366          authorization = self.user.create_authorization(
367              ["repo"], "Note created by PyGithub", "http://vincent-jacques.net/PyGithub"
368          )
369          self.assertEqual(authorization.id, 372294)
370  
371      def testCreateAuthorizationWithClientIdAndSecret(self):
372          # I don't have a client_id and client_secret so the ReplayData for this test is forged
373          authorization = self.user.create_authorization(
374              client_id="01234567890123456789",
375              client_secret="0123456789012345678901234567890123456789",
376          )
377          self.assertEqual(authorization.id, 372294)
378  
379      def testCreateGist(self):
380          gist = self.user.create_gist(
381              True,
382              {"foobar.txt": github.InputFileContent("File created by PyGithub")},
383              "Gist created by PyGithub",
384          )
385          self.assertEqual(gist.description, "Gist created by PyGithub")
386          self.assertEqual(list(gist.files.keys()), ["foobar.txt"])
387          self.assertEqual(gist.files["foobar.txt"].content, "File created by PyGithub")
388  
389      def testCreateGistWithoutDescription(self):
390          gist = self.user.create_gist(True, {"foobar.txt": github.InputFileContent("File created by PyGithub")})
391          self.assertEqual(gist.description, None)
392          self.assertEqual(list(gist.files.keys()), ["foobar.txt"])
393          self.assertEqual(gist.files["foobar.txt"].content, "File created by PyGithub")
394  
395      def testCreateKey(self):
396          key = self.user.create_key(
397              "Key added through PyGithub",
398              "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2Mm0RjTNAYFfSCtUpO54usdseroUSIYg5KX4JoseTpqyiB/hqewjYLAdUq/tNIQzrkoEJWSyZrQt0ma7/YCyMYuNGd3DU6q6ZAyBeY3E9RyCiKjO3aTL2VKQGFvBVVmGdxGVSCITRphAcsKc/PF35/fg9XP9S0anMXcEFtdfMHz41SSw+XtE+Vc+6cX9FuI5qUfLGbkv8L1v3g4uw9VXlzq4GfTA+1S7D6mcoGHopAIXFlVr+2RfDKdSURMcB22z41fljO1MW4+zUS/4FyUTpL991es5fcwKXYoiE+x06VJeJJ1Krwx+DZj45uweV6cHXt2JwJEI9fWB6WyBlDejWw== vincent@IDEE",
399          )
400          self.assertEqual(key.id, 2626650)
401  
402      def testGetEvents(self):
403          self.assertListKeyBegin(
404              self.user.get_events(),
405              lambda e: e.type,
406              ["PushEvent", "IssuesEvent", "IssueCommentEvent", "PushEvent"],
407          )
408  
409      def testGetOrganizationEvents(self):
410          self.assertListKeyBegin(
411              self.user.get_organization_events(self.g.get_organization("BeaverSoftware")),
412              lambda e: e.type,
413              ["CreateEvent", "CreateEvent", "PushEvent", "PushEvent"],
414          )
415  
416      def testGetGists(self):
417          self.assertListKeyEqual(
418              self.user.get_gists(),
419              lambda g: g.id,
420              [
421                  "2793505",
422                  "2793179",
423                  "11cb445f8197e17d303d",
424                  "1942384",
425                  "dcb7de17e8a52b74541d",
426              ],
427          )
428          self.assertListKeyEqual(
429              self.user.get_gists(since=datetime(2012, 3, 1, 23, 0, 0)),
430              lambda g: g.id,
431              ["2793505", "2793179", "11cb445f8197e17d303d"],
432          )
433  
434      def testGetStarredGists(self):
435          self.assertListKeyEqual(
436              self.user.get_starred_gists(),
437              lambda g: g.id,
438              ["1942384", "dcb7de17e8a52b74541d"],
439          )
440  
441      def testGetIssues(self):
442          self.assertListKeyEqual(
443              self.user.get_issues(),
444              lambda i: (i.id, i.repository.name),
445              [
446                  (4639931, "PyGithub"),
447                  (4452000, "PyGithub"),
448                  (4356743, "PyGithub"),
449                  (3716033, "PyGithub"),
450                  (3715946, "PyGithub"),
451                  (3643837, "PyGithub"),
452                  (3628022, "PyGithub"),
453                  (3624595, "PyGithub"),
454                  (3624570, "PyGithub"),
455                  (3624561, "PyGithub"),
456                  (3624556, "PyGithub"),
457                  (3619973, "PyGithub"),
458                  (3527266, "PyGithub"),
459                  (3527245, "PyGithub"),
460                  (3527231, "PyGithub"),
461              ],
462          )
463  
464      def testGetIssuesWithAllArguments(self):
465          requestedByUser = self.user.get_repo("PyGithub").get_label("Requested by user")
466          issues = self.user.get_issues(
467              "assigned",
468              "closed",
469              [requestedByUser],
470              "comments",
471              "asc",
472              datetime(2012, 5, 28, 23, 0, 0),
473          )
474          self.assertListKeyEqual(
475              issues,
476              lambda i: i.id,
477              [
478                  6816576,
479                  8495415,
480                  6889934,
481                  8339699,
482                  8075253,
483                  8033963,
484                  9089893,
485                  9489725,
486                  11746141,
487                  5152384,
488                  5177381,
489                  5783131,
490                  6454054,
491                  6641076,
492                  6653907,
493                  7331214,
494                  9489813,
495                  9776615,
496                  10360280,
497                  4356743,
498                  6583381,
499                  6751469,
500                  8189836,
501                  10758585,
502                  12097154,
503                  12867103,
504                  5191621,
505                  5256315,
506                  6363719,
507                  9209408,
508                  6912733,
509                  9948505,
510                  11503771,
511                  10922412,
512                  11844658,
513                  12566144,
514                  6353712,
515                  9323084,
516                  10379143,
517                  5387373,
518                  12179668,
519                  6911794,
520                  11731917,
521                  6807542,
522                  6780606,
523              ],
524          )
525  
526      def testGetUserIssues(self):
527          self.assertListKeyEqual(
528              self.user.get_user_issues(),
529              lambda i: i.id,
530              [
531                  14447880,
532                  13505356,
533                  12541184,
534                  10586808,
535                  6741461,
536                  6741457,
537                  6727331,
538                  5641572,
539              ],
540          )
541  
542      def testGetUserIssuesWithAllArguments(self):
543          requestedByUser = self.user.get_repo("PyGithub").get_label("Requested by user")
544          issues = self.user.get_user_issues(
545              "assigned",
546              "closed",
547              [requestedByUser],
548              "comments",
549              "asc",
550              datetime(2012, 5, 28, 23, 0, 0),
551          )
552          self.assertListKeyEqual(
553              issues,
554              lambda i: i.id,
555              [
556                  6816576,
557                  8495415,
558                  6889934,
559                  8339699,
560                  8075253,
561                  8033963,
562                  9089893,
563                  9489725,
564                  11746141,
565                  5152384,
566                  5177381,
567                  5783131,
568                  6454054,
569                  6641076,
570                  6653907,
571                  7331214,
572                  9489813,
573                  9776615,
574                  10360280,
575                  4356743,
576                  6583381,
577                  6751469,
578                  8189836,
579                  10758585,
580                  12097154,
581                  12867103,
582                  5191621,
583                  5256315,
584                  6363719,
585                  9209408,
586                  6912733,
587                  9948505,
588                  11503771,
589                  10922412,
590                  11844658,
591                  12566144,
592                  6353712,
593                  9323084,
594                  10379143,
595                  5387373,
596                  12179668,
597                  6911794,
598                  11731917,
599                  6807542,
600                  6780606,
601              ],
602          )
603  
604      def testGetKeys(self):
605          self.assertListKeyEqual(
606              self.user.get_keys(),
607              lambda k: k.title,
608              ["vincent@home", "vincent@gandi", "vincent@aws", "vincent@macbook"],
609          )
610  
611      def testGetOrgs(self):
612          self.assertListKeyEqual(self.user.get_orgs(), lambda o: o.login, ["BeaverSoftware"])
613  
614      def testGetRepos(self):
615          self.assertListKeyEqual(
616              self.user.get_repos(),
617              lambda r: r.name,
618              [
619                  "TestPyGithub",
620                  "django",
621                  "PyGithub",
622                  "developer.github.com",
623                  "acme-public-website",
624                  "C4Planner",
625                  "Hacking",
626                  "vincent-jacques.net",
627                  "Contests",
628                  "Candidates",
629                  "Tests",
630                  "DrawTurksHead",
631                  "DrawSyntax",
632                  "QuadProgMm",
633                  "Boost.HierarchicalEnum",
634                  "ViDE",
635              ],
636          )
637  
638      def testGetReposWithArguments(self):
639          self.assertListKeyEqual(
640              self.user.get_repos("all", "owner", "public", "full_name", "desc"),
641              lambda r: r.name,
642              [
643                  "ViDE",
644                  "QuadProgMm",
645                  "PyGithub",
646                  "DrawTurksHead",
647                  "DrawSyntax",
648                  "django",
649                  "developer.github.com",
650                  "C4Planner",
651                  "Boost.HierarchicalEnum",
652                  "acme-public-website",
653              ],
654          )
655  
656      def testCreateFork(self):
657          repo = self.user.create_fork(self.g.get_user("nvie").get_repo("gitflow"))
658          self.assertEqual(repo.source.full_name, "nvie/gitflow")
659  
660      def testCreateRepoFromTemplate(self):
661          template_repo = self.g.get_repo("actions/hello-world-docker-action")
662  
663          repo = self.user.create_repo_from_template("hello-world-docker-action-new", template_repo)
664          self.assertEqual(
665              repo.url,
666              "https://api.github.com/repos/jacquev6/hello-world-docker-action-new",
667          )
668          self.assertFalse(repo.is_template)
669  
670      def testCreateRepoFromTemplateWithAllArguments(self):
671          template_repo = self.g.get_repo("actions/hello-world-docker-action")
672  
673          description = "My repo from template"
674          private = True
675          repo = self.user.create_repo_from_template(
676              "hello-world-docker-action-new",
677              template_repo,
678              description=description,
679              private=private,
680          )
681          self.assertEqual(repo.description, description)
682          self.assertTrue(repo.private)
683  
684      def testGetNotification(self):
685          notification = self.user.get_notification("8406712")
686          self.assertEqual(notification.id, "8406712")
687          self.assertEqual(notification.unread, False)
688          self.assertEqual(notification.reason, "author")
689          self.assertEqual(notification.subject.title, "Feature/coveralls")
690          self.assertEqual(notification.subject.type, "PullRequest")
691          self.assertEqual(notification.repository.id, 8432784)
692          self.assertEqual(
693              notification.updated_at,
694              datetime(2013, 3, 15, 5, 43, 11, tzinfo=timezone.utc),
695          )
696          self.assertEqual(notification.url, None)
697          self.assertEqual(notification.subject.url, None)
698          self.assertEqual(notification.subject.latest_comment_url, None)
699          self.assertEqual(
700              repr(notification),
701              'Notification(subject=NotificationSubject(title="Feature/coveralls"), id="8406712")',
702          )
703          self.assertEqual(repr(notification.subject), 'NotificationSubject(title="Feature/coveralls")')
704  
705      def testGetNotifications(self):
706          self.assertListKeyEqual(self.user.get_notifications(participating=True), lambda n: n.id, ["8406712"])
707  
708      def testGetNotificationsWithOtherArguments(self):
709          self.assertListKeyEqual(self.user.get_notifications(all=True), lambda n: n.id, [])
710  
711      def testMarkNotificationsAsRead(self):
712          self.user.mark_notifications_as_read(datetime(2018, 10, 18, 18, 20, 0o1, 0))
713  
714      def testGetTeams(self):
715          self.assertListKeyEqual(
716              self.user.get_teams(),
717              lambda t: t.name,
718              [
719                  "Owners",
720                  "Honoraries",
721                  "Honoraries",
722                  "Honoraries",
723                  "Honoraries",
724                  "Honoraries",
725                  "Honoraries",
726                  "Honoraries",
727                  "Honoraries",
728                  "Honoraries",
729              ],
730          )
731  
732      def testAcceptInvitation(self):
733          self.assertEqual(self.user.accept_invitation(4294886), None)
734  
735      def testGetInvitations(self):
736          invitation = self.user.get_invitations()[0]
737          self.assertEqual(repr(invitation), "Invitation(id=17285388)")
738          self.assertEqual(invitation.id, 17285388)
739          self.assertEqual(invitation.permissions, "write")
740          created_at = datetime(2019, 6, 27, 11, 47, tzinfo=timezone.utc)
741          self.assertEqual(invitation.created_at, created_at)
742          self.assertEqual(
743              invitation.url,
744              "https://api.github.com/user/repository_invitations/17285388",
745          )
746          self.assertEqual(invitation.html_url, "https://github.com/jacquev6/PyGithub/invitations")
747          self.assertEqual(invitation.repository.name, "PyGithub")
748          self.assertEqual(invitation.invitee.login, "foobar-test1")
749          self.assertEqual(invitation.inviter.login, "jacquev6")
750  
751      def testCreateMigration(self):
752          self.assertTrue(isinstance(self.user.create_migration(["sample-repo"]), github.Migration.Migration))
753  
754      def testGetMigrations(self):
755          self.assertEqual(self.user.get_migrations().totalCount, 46)
756  
757      def testInstallations(self):
758          installations = self.user.get_installations()
759          self.assertEqual(installations[0].id, 123456)
760          self.assertEqual(installations[0].app_id, 10101)
761          self.assertEqual(installations[0].target_id, 3344556)
762          self.assertEqual(installations[0].target_type, "User")
763          self.assertEqual(installations.totalCount, 1)