Example #1
0
 def test_list_retrieves_all_items_from_logger_user(self, test_client, session, logged_user):
     user_filter = SearchFilterFactory.create(creator=logged_user)
     session.add(user_filter)
     session.commit()
     res = test_client.get(self.url())
     assert res.status_code == 200
     if 'rows' in res.json:
         assert len(res.json['rows']) == 1
     else:
         assert len(res.json) == 1
Example #2
0
    def test_delete_filter_from_another_user(self, test_client, session, logged_user):
        user_filter = SearchFilterFactory.create(creator=logged_user)
        another_user = UserFactory.create()
        session.add(user_filter)
        session.add(another_user)
        session.commit()

        logout(test_client, [302])
        login_as(test_client, another_user)

        res = test_client.delete(self.url(user_filter))
        assert res.status_code == 404
Example #3
0
    def test_retrieve_filter_list_is_empty_from_another_user(self, test_client, session, logged_user):
        user_filter = SearchFilterFactory.create(creator=logged_user)
        another_user = UserFactory.create()
        session.add(user_filter)
        session.add(another_user)
        session.commit()

        logout(test_client, [302])
        login_as(test_client, another_user)

        res = test_client.get(self.url())
        assert res.status_code == 200
        assert res.json == []
Example #4
0
    def test_retrieve_one_object_from_logged_user(self, test_client, session, logged_user):

        filters = []
        for n in range(5):
            user_filter = SearchFilterFactory.create(creator=logged_user)
            session.add(user_filter)
            filters.append(user_filter)

        session.commit()

        print(self.url(filters[randrange(5)]))
        res = test_client.get(self.url(filters[randrange(5)]))
        assert res.status_code == 200
        assert isinstance(res.json, dict)