Esempio n. 1
0
 def setUp(self):
     Account.default_adapter = MockAdapter
     self.members = MemberImport(
         Account(account_id="100", public_key="xxx", private_key="yyy"),
         {
             'status': ImportStatus.Ok,
             'style': ImportStyle.AddAndUpdate,
             'import_started': datetime.now().strftime(SERIALIZED_DATETIME_FORMAT),
             'import_finished': datetime.now().strftime(SERIALIZED_DATETIME_FORMAT)
         }
     ).members
Esempio n. 2
0
class ImportMemberCollectionTest(unittest.TestCase):
    def setUp(self):
        Account.default_adapter = MockAdapter
        self.members = MemberImport(
            Account(account_id="100", public_key="xxx", private_key="yyy"), {
                'status':
                ImportStatus.Ok,
                'style':
                ImportStyle.AddAndUpdate,
                'import_started':
                datetime.now().strftime(SERIALIZED_DATETIME_FORMAT),
                'import_finished':
                datetime.now().strftime(SERIALIZED_DATETIME_FORMAT)
            }).members

    def test_can_fetch_all_members(self):
        with self.assertRaises(ex.NoImportIdError):
            self.members.fetch_all()
        self.assertEquals(self.members.member_import.account.adapter.called, 0)

    def test_can_fetch_all_members2(self):
        # Setup
        MockAdapter.expected = [{
            'member_id': 200,
            'email': u"*****@*****.**"
        }, {
            'member_id': 201,
            'email': u"*****@*****.**"
        }, {
            'member_id': 202,
            'email': u"*****@*****.**"
        }]
        self.members.member_import['import_id'] = 1024

        members = self.members.fetch_all()

        self.assertEquals(self.members.member_import.account.adapter.called, 1)
        self.assertEquals(self.members.member_import.account.adapter.call,
                          ('GET', '/members/imports/1024/members', {}))
        self.assertIsInstance(members, dict)
        self.assertEquals(3, len(members))
        self.assertEquals(3, len(self.members))
        self.assertIsInstance(self.members[200], Member)
        self.assertIsInstance(self.members[201], Member)
        self.assertIsInstance(self.members[202], Member)
        self.assertEquals(self.members[200]['email'], u"*****@*****.**")
        self.assertEquals(self.members[201]['email'], u"*****@*****.**")
        self.assertEquals(self.members[202]['email'], u"*****@*****.**")
Esempio n. 3
0
class ImportMemberCollectionTest(unittest.TestCase):
    def setUp(self):
        Account.default_adapter = MockAdapter
        self.members = MemberImport(
            Account(account_id="100", public_key="xxx", private_key="yyy"),
            {
                'status': ImportStatus.Ok,
                'style': ImportStyle.AddAndUpdate,
                'import_started': datetime.now().strftime(SERIALIZED_DATETIME_FORMAT),
                'import_finished': datetime.now().strftime(SERIALIZED_DATETIME_FORMAT)
            }
        ).members

    def test_can_fetch_all_members(self):
        with self.assertRaises(ex.NoImportIdError):
            self.members.fetch_all()
        self.assertEquals(self.members.member_import.account.adapter.called, 0)

    def test_can_fetch_all_members2(self):
        # Setup
        MockAdapter.expected = [
            {'member_id': 200, 'email': u"*****@*****.**"},
            {'member_id': 201, 'email': u"*****@*****.**"},
            {'member_id': 202, 'email': u"*****@*****.**"}
        ]
        self.members.member_import['import_id'] = 1024

        members = self.members.fetch_all()

        self.assertEquals(self.members.member_import.account.adapter.called, 1)
        self.assertEquals(
            self.members.member_import.account.adapter.call,
            ('GET', '/members/imports/1024/members', {}))
        self.assertIsInstance(members, dict)
        self.assertEquals(3, len(members))
        self.assertEquals(3, len(self.members))
        self.assertIsInstance(self.members[200], Member)
        self.assertIsInstance(self.members[201], Member)
        self.assertIsInstance(self.members[202], Member)
        self.assertEquals(self.members[200]['email'], u"*****@*****.**")
        self.assertEquals(self.members[201]['email'], u"*****@*****.**")
        self.assertEquals(self.members[202]['email'], u"*****@*****.**")
Esempio n. 4
0
 def setUp(self):
     Account.default_adapter = MockAdapter
     self.members = MemberImport(
         Account(account_id="100", public_key="xxx", private_key="yyy"),
         {
             'status': ImportStatus.Ok,
             'style': ImportStyle.AddAndUpdate,
             'import_started': datetime.now().strftime(SERIALIZED_DATETIME_FORMAT),
             'import_finished': datetime.now().strftime(SERIALIZED_DATETIME_FORMAT)
         }
     ).members