Пример #1
0
    def test_multiple_domain_download(self):
        (headers,
         rows) = parse_mobile_users(self.domain_obj.name,
                                    {'domains': ['bookshelf', 'book']})

        rows = list(rows)
        self.assertEqual(3, len(rows))
        spec = dict(zip(headers, rows[2]))
        self.assertEqual('emily', spec['username'])
        self.assertEqual('True', spec['is_active'])
        self.assertEqual('Emily Bronte', spec['name'])
Пример #2
0
    def test_download(self):
        (headers, rows) = parse_mobile_users(self.domain_obj.name, {})
        self.assertNotIn('user_profile', headers)

        rows = list(rows)
        self.assertEqual(2, len(rows))

        spec = dict(zip(headers, rows[0]))
        self.assertEqual('edith', spec['username'])
        self.assertTrue(re.search(r'^\*+$', spec['password']))
        self.assertEqual('True', spec['is_active'])
        self.assertEqual('Edith Wharton', spec['name'])
        self.assertTrue(spec['registered_on (read only)'].startswith(
            datetime.today().strftime("%Y-%m-%d")))
        self.assertEqual('', spec['data: _type'])
        self.assertEqual(1862, spec['data: born'])
Пример #3
0
    def test_download_with_profile(self):
        (headers, rows) = parse_mobile_users(self.domain_obj.name, {})
        self.assertIn('user_profile', headers)
        self.assertIn('data: _type', headers)

        rows = list(rows)
        self.assertEqual(2, len(rows))

        spec = dict(zip(headers, rows[0]))
        self.assertEqual('edith', spec['username'])
        self.assertEqual('', spec['user_profile'])
        self.assertEqual('', spec['data: _type'])
        self.assertEqual(1862, spec['data: born'])

        spec = dict(zip(headers, rows[1]))
        self.assertEqual('george', spec['username'])
        self.assertEqual('Novelist', spec['user_profile'])
        self.assertEqual('fiction', spec['data: _type'])
        self.assertEqual(1849, spec['data: born'])
Пример #4
0
    def test_download(self):
        # Add multiple phone numbers to user1
        self.__class__.user1.add_phone_number('27786544321')
        self.__class__.user1.save()

        (headers, rows) = parse_mobile_users(self.domain_obj.name, {})

        rows = list(rows)
        self.assertEqual(2, len(rows))
        self.assertTrue('phone-number 1' in headers)
        self.assertTrue('phone-number 2' in headers)

        spec = dict(zip(headers, rows[0]))
        self.assertEqual('edith', spec['username'])
        self.assertTrue(re.search(r'^\*+$', spec['password']))
        self.assertEqual('True', spec['is_active'])
        self.assertEqual('Edith Wharton', spec['name'])
        self.assertTrue(spec['registered_on (read only)'].startswith(
            datetime.today().strftime("%Y-%m-%d")))
        self.assertEqual('', spec['data: _type'])
        self.assertEqual(1862, spec['data: born'])
        self.assertEqual('1', spec['location_code 1'])
        self.assertEqual(spec['phone-number 1'], '27786541239')
        self.assertEqual(spec['phone-number 2'], '27786544321')