コード例 #1
0
 def test_get_flat_users(self):
     john, paul, george, ringo, freddy = DummyUser().create_dummy_beatles()
     flat_1, flat_2 = DummyUser().set_flats_to_beatles(
         john, paul, george, ringo, freddy)
     flat_3 = Flat()
     self.assertEqual(get_flat_users(flat_1), [
         john,
     ])
     self.assertEqual(get_flat_users(flat_2), [paul, george, ringo])
     self.assertEqual(get_flat_users(flat_3), [])
     self.assertEqual(get_flat_users(None), [])
     self.assertEqual(get_flat_users(User()), [])
コード例 #2
0
 def test_has_flat_member(self):
     john, paul, george, ringo, freddy = DummyUser().create_dummy_beatles()
     flat_1, flat_2 = DummyUser().set_flats_to_beatles(
         john, paul, george, ringo, freddy)
     flat_3 = Flat()
     DummyUser().create_dummy_group(group_name='members')
     DummyUser().add_dummy_group(john, group_name='members')
     self.assertEqual(has_flat_member(flat_1), True)
     self.assertEqual(has_flat_member(flat_2), False)
     self.assertEqual(has_flat_member(flat_3), False)
     self.assertEqual(has_flat_member(None), False)
     self.assertEqual(has_flat_member(User()), False)
コード例 #3
0
ファイル: test_functions.py プロジェクト: wanrumwie/koopsite
 def test_get_miniature_path(self):
     user = DummyUser().create_dummy_user()
     picture_path = os.path.join("koopsite", "tests", "profile_image.jpg")
     mini_path = get_miniature_path(picture_path)
     self.assertEqual(mini_path, 'koopsite\\tests\\profile_image_30x24.jpg')
     mini_path = get_miniature_path(picture_path, "200x100")
     self.assertEqual(mini_path,
                      'koopsite\\tests\\profile_image_200x100.jpg')
コード例 #4
0
 def test_thumbnail_for_path(self):
     user = DummyUser().create_dummy_user()
     picture_path = "koopsite/tests/profile_image.jpg"
     mini_url = get_thumbnail_url_path(picture_path)[0]
     self.assertEqual(mini_url, 'koopsite/tests/profile_image_30x24.jpg')
     mini_url = get_thumbnail_url_path(picture_path, "200x100")[0]
     self.assertEqual(mini_url, 'koopsite/tests/profile_image_200x100.jpg')
     os.remove('koopsite/tests/profile_image_30x24.jpg')
     os.remove('koopsite/tests/profile_image_200x100.jpg')
コード例 #5
0
    def test_thumbnail_for_file_3(self):
        user = DummyUser().create_dummy_user()
        # picture_path="koopsite/tests/profile_image_3.jpg"
        picture_path = os.path.join("koopsite", "tests", "profile_image_3.jpg")
        DummyUser().create_dummy_profile(user, picture_path=picture_path)
        picture = user.userprofile.picture
        expected_url = '/media/profile_images/1_30x24.jpg'
        expected_path = os.path.join(MEDIA_ROOT, "profile_images",
                                     "1_30x24.jpg")
        mini_url, mini_path = get_thumbnail_url_path(picture)
        self.assertEqual(mini_url, expected_url)
        self.assertEqual(mini_path, expected_path)

        image = Image.open(expected_path)
        size = image.size
        self.assertEqual(size, (30, 16))
        image.close()

        os.remove(os.path.join('media', 'profile_images', '1.jpg'))
        os.remove(os.path.join('media', 'profile_images', '1_30x24.jpg'))
コード例 #6
0
    def test_thumbnail_for_file(self):
        user = DummyUser().create_dummy_user()
        picture_path = "koopsite/tests/profile_image.jpg"
        DummyUser().create_dummy_profile(user, picture_path=picture_path)
        picture = user.userprofile.picture
        expected_url = '/media/profile_images/1_30x24.jpg'
        expected_path = os.path.join(MEDIA_ROOT, r"profile_images\1_30x24.jpg")
        mini_url, mini_path = get_thumbnail_url_path(picture)
        self.assertEqual(mini_url, expected_url)
        self.assertEqual(mini_path, expected_path)

        expected_url = '/media/profile_images/1_200x100.jpg'
        expected_path = os.path.join(MEDIA_ROOT,
                                     r"profile_images\1_200x100.jpg")
        mini_url, mini_path = get_thumbnail_url_path(picture, "200x100")
        self.assertEqual(mini_url, expected_url)
        self.assertEqual(mini_path, expected_path)

        os.remove('media/profile_images/1.jpg')
        os.remove('media/profile_images/1_30x24.jpg')
        os.remove('media/profile_images/1_200x100.jpg')
コード例 #7
0
 def test_remove_group(self):
     DummyUser().create_dummy_group(group_name='members')
     add_group(self.user, 'members')
     self.assertTrue(has_group(self.user, 'members'))
     remove_group(self.user, 'members')
     self.assertFalse(has_group(self.user, 'members'))
コード例 #8
0
 def test_has_group(self):
     DummyUser().create_dummy_group(group_name='members')
     DummyUser().add_dummy_group(self.user, group_name='members')
     self.assertTrue(has_group(self.user, 'members'))
コード例 #9
0
 def test_has_group_member_gives_false(self):
     DummyUser().create_dummy_group(group_name='stuff')
     DummyUser().add_dummy_group(self.user, group_name='stuff')
     self.assertFalse(has_group_members(self.user))
コード例 #10
0
 def test_is_staff_only_gives_false_for_two_groups(self):
     DummyUser().create_dummy_group(group_name='staff')
     DummyUser().add_dummy_group(self.user, group_name='staff')
     DummyUser().create_dummy_group(group_name='STAFF')
     DummyUser().add_dummy_group(self.user, group_name='STAFF')
     self.assertFalse(is_staff_only(self.user))
コード例 #11
0
 def test_is_staff_only_gives_true(self):
     DummyUser().create_dummy_group(group_name='staff')
     DummyUser().add_dummy_group(self.user, group_name='staff')
     self.assertTrue(is_staff_only(self.user))
コード例 #12
0
 def test_get_user_is_recognized_gives_proper_value(self):
     DummyUser().create_dummy_profile(self.user, is_recognized=True)
     self.assertEqual(get_user_is_recognized(self.user), True)
コード例 #13
0
 def test_get_user_flat_No_gives_proper_value(self):
     flat = DummyFlat().create_dummy_flat(flat_No='11a')
     DummyUser().create_dummy_profile(self.user, flat=flat)
     self.assertEqual(get_user_flat_No(self.user), "11a")
コード例 #14
0
 def test_get_user_full_name_gives_stripped_names(self):
     user = DummyUser().create_dummy_user(username='******',
                                          first_name=' alfa ',
                                          last_name=' be ta ')
     self.assertEqual(get_user_full_name(user), "Be ta Alfa")
コード例 #15
0
 def setUp(self):
     self.user = DummyUser().create_dummy_user()
コード例 #16
0
ファイル: test_viewsajax.py プロジェクト: wanrumwie/koopsite
 def setUp(self):
     DummyUser().create_dummy_user('fred', id=1)
     DummyUser().create_dummy_user('john', id=2)
     self.bta_cls = BrowseTableArray