MCPcopy Index your code
hub / github.com/PyGithub/PyGithub / testShouldDeferWrites

Method testShouldDeferWrites

tests/Requester.py:616–658  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

614 self.assertEqual(sleep_mock.call_args_list, [mock.call(1), mock.call(1), mock.call(1)])
615
616 def testShouldDeferWrites(self):
617 with self.mock_sleep() as sleep_mock:
618 # same test setup as in AuthenticatedUser.testEmail
619 user = self.g.get_user()
620 emails = user.get_emails()
621 self.assertEqual(
622 [item.email for item in emails],
623 ["vincent@vincent-jacques.net", "github.com@vincent-jacques.net"],
624 )
625 self.assertTrue(emails[0].primary)
626 self.assertTrue(emails[0].verified)
627 self.assertEqual(emails[0].visibility, "private")
628 user.add_to_emails("1@foobar.com", "2@foobar.com")
629 self.assertEqual(
630 [item.email for item in user.get_emails()],
631 [
632 "vincent@vincent-jacques.net",
633 "1@foobar.com",
634 "2@foobar.com",
635 "github.com@vincent-jacques.net",
636 ],
637 )
638 user.remove_from_emails("1@foobar.com", "2@foobar.com")
639 self.assertEqual(
640 [item.email for item in user.get_emails()],
641 ["vincent@vincent-jacques.net", "github.com@vincent-jacques.net"],
642 )
643
644 self.assertEqual(
645 sleep_mock.call_args_list,
646 [
647 # g.get_user() does not call into GitHub API
648 # user.get_emails() is the first request so no waiting needed
649 # user.add_to_emails is a write request, this is the first write request
650 mock.call(1),
651 # user.get_emails() is a read request
652 mock.call(1),
653 # user.remove_from_emails is a write request, it has to be 3 seconds after the last write
654 mock.call(2),
655 # user.get_emails() is a read request
656 mock.call(1),
657 ],
658 )

Callers

nothing calls this directly

Calls 5

mock_sleepMethod · 0.80
get_userMethod · 0.80
get_emailsMethod · 0.80
add_to_emailsMethod · 0.80
remove_from_emailsMethod · 0.80

Tested by

no test coverage detected