Ejemplo n.º 1
0
 def test_logged_in_valid_post(self):
     data = create_valid_empty_tableaux_data(self)
     with self.client:
         login(self.client)
         response = self.client.post(url_for('tools.example_edit'),
                                     data=data)
         self.assert_status(response, 302)
         assert "classical=False" in response.location
         guest_dsets = Dataset.objects(user='******')
         user_dsets = Dataset.objects(user=login_data['username'])
         assert len(guest_dsets) == 2
         assert len(user_dsets) == 1
Ejemplo n.º 2
0
 def test_logged_in(self):
     with self.client:
         login(self.client)
         response = self.client.get(self.url)
         self.assert_redirects(response, url_for('tools.edit',
                                                 dset_name='blank-copy'))
         user_dsets = Dataset.objects(user=login_data['username'])
         assert len(user_dsets) == 2
Ejemplo n.º 3
0
 def test_valid_empty_dataset_gets_random_name(self):
     data = create_valid_empty_tableaux_data(self)
     data.pop("name")
     response = self.client.post(url_for('tools.calculator'), data=data)
     self.assert_status(response, 302)
     dsets = Dataset.objects(user='******')
     assert len(dsets) == 3
     delete_bad_datasets()
Ejemplo n.º 4
0
 def get(self, username):
     if get_username() != username:
         flash("Log in to view your account")
         return redirect(url_for("users.login"))
     else:
         user = User.objects.get_or_404(username=username)
         dsets = Dataset.objects(user=user.username)
         return render_template("account.html", user=user, dsets=dsets)
Ejemplo n.º 5
0
 def test_unlogged_in_valid_post(self):
     data = create_valid_empty_tableaux_data(self)
     with self.client:
         response = self.client.post(url_for('tools.example_edit'),
                                     data=data)
         self.assert_status(response, 302)
         guest_dsets = Dataset.objects(user='******')
         assert len(guest_dsets) == 3
         try:
             session['redirect_url']
         except KeyError:
             assert False
         else:
             assert True
Ejemplo n.º 6
0
    def test_successful_signup(self):
        #import pdb; pdb.set_trace()
        response = self.client.post(url_for('users.signup'),
                                    data={'username': '******',
                                          'password': '******',
                                          'password_conf': 'password'})
        self.assert_redirects(response, url_for('users.login'))
        user = User.objects.get(username='******')
        dsets = Dataset.objects(user=user.username)

        assert user.username == 'jane'
        assert user.is_password_valid('password')
        assert len(dsets) == 2

        for dset in dsets:
            dset.delete()

        user.delete()
Ejemplo n.º 7
0
def delete_bad_datasets():
    dsets = [d for d in Dataset.objects() if is_bad_dset(d)]
    for dset in dsets:
        dset.delete()
Ejemplo n.º 8
0
 def _create_temporary_dset_name(self):
     # keep trying strings until you get a unique one
     temp_name = self._get_temp_name_attempt()
     while Dataset.objects(name=temp_name, user=get_username()):
         temp_name = self._get_temp_name_attempt()
     return temp_name
Ejemplo n.º 9
0
 def make_unique_random_dset_name(self):
     # keep trying until you get something not in the database
     random_name = self._random_name_attempt()
     while Dataset.objects(name=random_name, user=get_username()):
         random_name = self._random_name_attempt()
     return random_name
Ejemplo n.º 10
0
def delete_bad_dsets():
    bad_dsets = filter(is_bad_dset, Dataset.objects())
    for bad in bad_dsets:
        bad.delete()