Example #1
0
 def test_google_user_not_logged(self):
     users_mock = Mock()
     users_mock.get_current_user = Mock(return_value=None)
     sites.users = users_mock
     setup = facade.initial_setup()
     self.assertRaises(CommandExecutionException, setup.execute)
     self.assertIsNone(setup.result)
     self.assertDictEqual({'user': '******'},
                          setup.errors)
Example #2
0
 def test_google_user_not_admin(self):
     users_mock = Mock()
     users_mock.get_current_user = Mock(return_value=True)
     users_mock.is_current_user_admin = Mock(return_value=False)
     sites.users = users_mock
     setup = facade.initial_setup()
     self.assertRaises(CommandExecutionException, setup.execute)
     self.assertIsNone(setup.result)
     self.assertDictEqual({'user': '******'},
                          setup.errors)
Example #3
0
    def test_success(self):
        users_mock = Mock()
        google_user = Mock()
        user_email = '*****@*****.**'
        google_user.email = Mock(return_value=user_email)
        users_mock.get_current_user = Mock(return_value=google_user)
        users_mock.is_current_user_admin = Mock(return_value=True)
        sites.users = users_mock
        setup = facade.initial_setup()
        setup.execute()
        site = setup.result

        find = facade.find_current_site()
        find.execute()
        self.assertEqual(site.key, find.result.key)
Example #4
0
 def test_success(self):
     users_mock = Mock()
     google_user = Mock()
     user_email = '*****@*****.**'
     google_user.email = Mock(return_value=user_email)
     users_mock.get_current_user = Mock(return_value=google_user)
     users_mock.is_current_user_admin = Mock(return_value=True)
     sites.users = users_mock
     setup = facade.initial_setup()
     setup.execute()
     site = setup.result
     self.assertEqual(settings.APP_HOST, site.domain)
     find_user = FindOrCreateUser(user_email)
     find_user.execute()
     user = find_user.result
     search = SitesSearch(to_node_key(user))
     search.execute()
     user_sites = search.result
     self.assertListEqual([site.key], [s.key for s in user_sites])