Exemple #1
0
    def test_listing_page_of_protocols_with_over_30_protocols(self):
        before_add = Protocol.objects.count()
        client.login(username='******', password='******')
        for add_protocol in range(35):
            client.post('/protocols/add/', {
                "topics-TOTAL_FORMS": 2,
                "topics-INITIAL_FORMS": 0,
                "topics-MAX_NUM_FORMS": 1000,
                "institution": self.institution.pk,
                "number": "{}".format(add_protocol),
                "start_time": time(10, 0, 0),
                "scheduled_time": time(9, 0, 0),
                "quorum": 32,
                "excused": self.kril.pk,
                "absent": self.kril.pk,
                "attendents": self.kril.pk,
                "majority": 5,
                "current_majority": 4,
                "voted_for": 2,
                "voted_against": 3,
                "voted_abstain": 0,
                "information": 'this is the best protocol ever', })

        response_1 = client.get('/protocols/archive/1/')
        response_2 = client.get('/protocols/archive/2/')

        after_add = Protocol.objects.count()
        self.assertEqual(200, response_1.status_code)
        self.assertEqual(200, response_2.status_code)
        self.assertEqual(before_add + 35, after_add)
        self.assertEqual(30, len(response_1.context['protocols']))
        self.assertEqual(5, len(response_2.context['protocols']))
Exemple #2
0
    def test_listing_page_of_protocols_with_over_30_protocols(self):
        before_add = Protocol.objects.count()
        client.login(username='******', password='******')
        for add_protocol in range(35):
            client.post(
                '/protocols/add/', {
                    "topics-TOTAL_FORMS": 2,
                    "topics-INITIAL_FORMS": 0,
                    "topics-MAX_NUM_FORMS": 1000,
                    "institution": self.institution.pk,
                    "number": "{}".format(add_protocol),
                    "start_time": time(10, 0, 0),
                    "scheduled_time": time(9, 0, 0),
                    "quorum": 32,
                    "excused": self.kril.pk,
                    "absent": self.kril.pk,
                    "attendents": self.kril.pk,
                    "majority": 5,
                    "current_majority": 4,
                    "voted_for": 2,
                    "voted_against": 3,
                    "voted_abstain": 0,
                    "information": 'this is the best protocol ever',
                })

        response_1 = client.get('/protocols/archive/1/')
        response_2 = client.get('/protocols/archive/2/')

        after_add = Protocol.objects.count()
        self.assertEqual(200, response_1.status_code)
        self.assertEqual(200, response_2.status_code)
        self.assertEqual(before_add + 35, after_add)
        self.assertEqual(30, len(response_1.context['protocols']))
        self.assertEqual(5, len(response_2.context['protocols']))
Exemple #3
0
    def test_showing_members_of_institution(self):
        client.login(username='******', password='******')
        before_add = self.institution.members.count()
        institution_id = self.institution.pk
        kril_id = self.kril.pk
        fake_id = self.fake_kril.pk
        before_add = self.institution.members.count()

        client.get('/protocols/institution/add_member/{}/{}/'.format(institution_id, kril_id))
        client.get('/protocols/institution/add_member/{}/{}/'.format(institution_id, fake_id))
        response = client.get('/protocols/institution/members/{}/'.format(institution_id))

        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 2, response.context['members'].count())
Exemple #4
0
    def test_project_list_GET(self):
        response = Client()

        response = client.get(reverse('list'))

        self.assertEquals(response.status_code, 200)
        self.assertTemplateUsed(response, 900)
Exemple #5
0
 def test_my_evaluation_not_found(self):
     client = Client()
     header = {'HTTP_Authorization': self.access_token}
     response = client.get('/whatthe',
                           content_type='application/json',
                           **header)
     self.assertEqual(response.status_code, 404)
 def test_get_valid_single_customer(self):
     response = client.get(
         reverse("get_delete_update_customer", kwargs={'pk': self.john.pk}))
     customer = Customer.objects.get(pk=self.john.pk)
     serializer = CustomerSerializer(customer)
     self.assertEqual(serializer.data, response.data)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
Exemple #7
0
    def test_valid_flights_page(self):
        valid_flight = Flight.objects.get(pk=1)

        client = Client()
        response = client.get(f"/flights/{valid_flight.id}")

        self.assertEqual(response.status_code, 200)
Exemple #8
0
    def test_display_protocols_by_date(self):
        client.login(username='******', password='******')
        client.post('/protocols/add/', {
            "topics-TOTAL_FORMS": 2,
            "topics-INITIAL_FORMS": 0,
            "topics-MAX_NUM_FORMS": 1000,
            "institution": self.institution.pk,
            "number": "1234",
            "start_time": time(10, 0, 0),
            "scheduled_time": time(9, 0, 0),
            "quorum": 32,
            "absent": self.kril.pk,
            "attendents": self.kril.pk,
            "majority": 5,
            "current_majority": 4,
            "voted_for": 2,
            "voted_against": 3,
            "voted_abstain": 0,
            "information": 'this is the best protocol ever', })

        start_date = str(date.today() - timedelta(days=3))
        end_date   = str(date.today() + timedelta(days=3))

        response = client.get('/protocols/search/{}/{}/'.format(start_date, end_date))

        self.assertEqual(200, response.status_code)
        self.assertEqual(1, len(response.context['protocols']))
Exemple #9
0
    def test_display_protocol_by_id(self):
        client.login(username='******', password='******')
        c_post = client.post('/protocols/add/', {
            "topics-TOTAL_FORMS": 2,
            "topics-INITIAL_FORMS": 0,
            "topics-MAX_NUM_FORMS": 1000,
            "institution": self.institution.pk,
            "number": "1234",
            "start_time": time(10, 0, 0),
            "scheduled_time": time(9, 0, 0),
            "quorum": 32,
            "excused": self.kril.pk,
            "absent": self.kril.pk,
            "attendents": self.kril.pk,
            "majority": 5,
            "current_majority": 4,
            "voted_for": 2,
            "voted_against": 3,
            "voted_abstain": 0,
            "information": 'this is the best protocol ever', })

        response = client.get('/protocols/archive/review/{}/'.format(
                                                c_post.context['protocol'].pk))

        self.assertEqual(200, response.status_code)
Exemple #10
0
    def test_display_protocols_by_date(self):
        client.login(username='******', password='******')
        client.post(
            '/protocols/add/', {
                "topics-TOTAL_FORMS": 2,
                "topics-INITIAL_FORMS": 0,
                "topics-MAX_NUM_FORMS": 1000,
                "institution": self.institution.pk,
                "number": "1234",
                "start_time": time(10, 0, 0),
                "scheduled_time": time(9, 0, 0),
                "quorum": 32,
                "absent": self.kril.pk,
                "attendents": self.kril.pk,
                "majority": 5,
                "current_majority": 4,
                "voted_for": 2,
                "voted_against": 3,
                "voted_abstain": 0,
                "information": 'this is the best protocol ever',
            })

        start_date = str(date.today() - timedelta(days=3))
        end_date = str(date.today() + timedelta(days=3))

        response = client.get('/protocols/search/{}/{}/'.format(
            start_date, end_date))

        self.assertEqual(200, response.status_code)
        self.assertEqual(1, len(response.context['protocols']))
Exemple #11
0
    def test_display_protocol_by_id(self):
        client.login(username='******', password='******')
        c_post = client.post(
            '/protocols/add/', {
                "topics-TOTAL_FORMS": 2,
                "topics-INITIAL_FORMS": 0,
                "topics-MAX_NUM_FORMS": 1000,
                "institution": self.institution.pk,
                "number": "1234",
                "start_time": time(10, 0, 0),
                "scheduled_time": time(9, 0, 0),
                "quorum": 32,
                "excused": self.kril.pk,
                "absent": self.kril.pk,
                "attendents": self.kril.pk,
                "majority": 5,
                "current_majority": 4,
                "voted_for": 2,
                "voted_against": 3,
                "voted_abstain": 0,
                "information": 'this is the best protocol ever',
            })

        response = client.get('/protocols/archive/review/{}/'.format(
            c_post.context['protocol'].pk))

        self.assertEqual(200, response.status_code)
Exemple #12
0
 def test_detail_api_view(self):
     client = self.get_client()
     response = client.get("/api/tweets/1/")
     self.assertEqual(response.status_code, 200)
     data = response.json()
     _id = data.get("id")
     self.assertEqual(_id, 1)
Exemple #13
0
    def test_complex_search(self):
        client.login(username='******', password='******')

        project = Project.objects.create(
            user=self.not_master,
            flp=self.not_master,
            name='New project',
            description='spam',
            tasks='spam',
            targets='spam',
            target_group='spam',
            schedule='spam',
            resources='spam',
            finance_description='spam')

        Project.objects.create(
            user=self.not_master,
            flp=self.not_master,
            name='Old project',
            description='spam',
            tasks='spam',
            targets='spam',
            target_group='spam',
            schedule='spam',
            resources='spam',
            finance_description='spam')

        search_data = urlencode({"name": "New project", "status": "unrevised", "flp": self.not_master.first_name})

        response = client.get('/projects/archive/?{}'.format(search_data))
        projects = Project.objects.filter(name="New project")

        self.assertEqual(200, response.status_code)
        self.assertEqual(len(projects), len(response.context['projects']))
Exemple #14
0
    def test_listing_page_of_reports(self):
        before_add = Report.objects.count()
        copies_before_add = Copy.objects.count()
        client.login(username='******', password='******')
        for report in range(10):
            response = client.post(
                '/reports/add/', {
                    "copies-TOTAL_FORMS": 2,
                    "copies-INITIAL_FORMS": 0,
                    "copies-MAX_NUM_FORMS": 1000,
                    "addressed_to": "Hackfmi",
                    "reported_from": self.kril.pk,
                    "content": "This is a report test",
                    "copies-0-about_topic": self.topic1.pk,
                    "copies-1-about_topic": self.topic2.pk,
                    "copies-2-about_topic": self.topic3.pk,
                    "signed_from": "rozovo zaiche",
                })

        response = client.get('/reports/archive/1/')

        after_add = Report.objects.all().count()
        copies_after_add = Copy.objects.count()

        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 10, after_add)
        self.assertEqual(copies_before_add + 20, copies_after_add)
        self.assertEqual(after_add, len(response.context['reports']))
Exemple #15
0
    def test_listing_page_of_reports(self):
        before_add = Report.objects.count()
        copies_before_add = Copy.objects.count()
        client.login(username='******', password='******')
        for report in range(10):
            response = client.post('/reports/add/', {
                "copies-TOTAL_FORMS": 2,
                "copies-INITIAL_FORMS": 0,
                "copies-MAX_NUM_FORMS": 1000,
                "addressed_to": "Hackfmi",
                "reported_from": self.kril.pk,
                "content": "This is a report test",
                "copies-0-about_topic": self.topic1.pk,
                "copies-1-about_topic": self.topic2.pk,
                "copies-2-about_topic": self.topic3.pk,
                "signed_from": "rozovo zaiche", })

        response = client.get('/reports/archive/1/')

        after_add = Report.objects.all().count()
        copies_after_add = Copy.objects.count()

        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 10, after_add)
        self.assertEqual(copies_before_add + 20, copies_after_add)
        self.assertEqual(after_add, len(response.context['reports']))
Exemple #16
0
    def test_showing_members_of_institution(self):
        client.login(username='******', password='******')
        before_add = self.institution.members.count()
        institution_id = self.institution.pk
        kril_id = self.kril.pk
        fake_id = self.fake_kril.pk
        before_add = self.institution.members.count()

        client.get('/protocols/institution/add_member/{}/{}/'.format(
            institution_id, kril_id))
        client.get('/protocols/institution/add_member/{}/{}/'.format(
            institution_id, fake_id))
        response = client.get(
            '/protocols/institution/members/{}/'.format(institution_id))

        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 2, response.context['members'].count())
 def test_view_user(self, client):
     """
     Method for displaying all users from the database
     """
     response = client.get('/users')
     user_list = User.objects.all()
     serializer = UserSerializer(user_list, many=True)
     assert response.data == serializer.data
     assert response.status_code == status.HTTP_200_OK
def internal_request(path, meta=None):
	client = django.test.client.Client()
	kwargs = dict()
	if meta:
		for k, v in meta.iteritems():
			if k.startswith('HTTP_'):
				kwargs[k] = v
	kwargs['HTTP_INTERNAL'] = '1'
	return client.get(path, {}, **kwargs)
Exemple #19
0
    def test_flight_page_non_passengers(self):
        valid_flight = Flight.objects.get(pk=1)
        passenger_two = Passenger.objects.create(first="Alienvce",
                                                 last="Adnan")

        client = Client()
        response = client.get(f"/flights/{valid_flight.id}")
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.context["non_passengers"].count(), 1)
Exemple #20
0
    def test_cant_add_member_to_institution(self):
        before_add = self.institution.members.count()
        institution_id = self.institution.pk
        user_id = self.kril.pk
        response = client.get('/protocols/institution/add_member/{}/{}/'.format(institution_id, user_id))
        after_add = self.institution.members.count()

        self.assertEqual(302, response.status_code)
        self.assertEqual(before_add, after_add)
Exemple #21
0
    def test_flight_page_passengers(self):
        valid_flight = Flight.objects.get(pk=1)
        passenger_one = Passenger.objects.create(first="Nuruddin",
                                                 last="Syeed")
        valid_flight.passengers.add(passenger_one)

        client = Client()
        response = client.get((f"/flights/{valid_flight.id}"))
        self.assertEqual(response.context["passengers"].count(), 1)
Exemple #22
0
    def test_add_member_to_institution(self):
        client.login(username='******', password='******')
        before_add = self.institution.members.count()
        institution_id = self.institution.pk
        user_id = self.kril.pk
        response = client.get('/protocols/institution/add_member/{}/{}/'.format(institution_id, user_id))
        after_add = self.institution.members.count()

        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 1, after_add)
Exemple #23
0
    def test_cant_add_member_to_institution(self):
        before_add = self.institution.members.count()
        institution_id = self.institution.pk
        user_id = self.kril.pk
        response = client.get(
            '/protocols/institution/add_member/{}/{}/'.format(
                institution_id, user_id))
        after_add = self.institution.members.count()

        self.assertEqual(302, response.status_code)
        self.assertEqual(before_add, after_add)
def _get_bundler_url(client,
                     action,
                     version=TEST_APP_BASE_VERSION,
                     platform=None):
    params = {'app_id': TEST_APP_ID, 'action': action}
    if action == 'pull':
        params['base_version'] = version
        if platform:
            params['platform'] = platform
    response = client.get(reverse('api:bundlers:bundlers'), params)
    return _to_dict(response)
Exemple #25
0
    def test_add_member_to_institution(self):
        client.login(username='******', password='******')
        before_add = self.institution.members.count()
        institution_id = self.institution.pk
        user_id = self.kril.pk
        response = client.get(
            '/protocols/institution/add_member/{}/{}/'.format(
                institution_id, user_id))
        after_add = self.institution.members.count()

        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 1, after_add)
Exemple #26
0
def _get_bundler_url(client, action, version=TEST_APP_BASE_VERSION,
                     platform=None):
    params = {
        'app_id': TEST_APP_ID,
        'action': action
    }
    if action == 'pull':
        params['base_version'] = version
        if platform:
            params['platform'] = platform
    response = client.get(reverse('api:bundlers:bundlers'), params)
    return _to_dict(response)
Exemple #27
0
    def test_listing_page_of_protocols(self):
        before_add = Protocol.objects.count()
        client.login(username='******', password='******')
        client.post(
            '/protocols/add/', {
                "topics-TOTAL_FORMS": 2,
                "topics-INITIAL_FORMS": 0,
                "topics-MAX_NUM_FORMS": 1000,
                "institution": self.institution.pk,
                "number": "1234",
                "start_time": time(10, 0, 0),
                "scheduled_time": time(9, 0, 0),
                "quorum": 32,
                "absent": self.kril.pk,
                "attendents": self.kril.pk,
                "majority": 5,
                "current_majority": 4,
                "information": 'this is the best protocol ever',
            })

        client.post(
            '/protocols/add/', {
                "topics-TOTAL_FORMS": 2,
                "topics-INITIAL_FORMS": 0,
                "topics-MAX_NUM_FORMS": 1000,
                "institution": self.institution.pk,
                "number": "13/11/1992/1235",
                "start_time": time(10, 0, 0),
                "scheduled_time": time(9, 0, 0),
                "quorum": 32,
                "absent": self.kril.pk,
                "attendents": self.kril.pk,
                "majority": 5,
                "current_majority": 4,
                "information": 'this is the best protocol ever',
            })

        response = client.get('/protocols/archive/1/')

        after_add = Protocol.objects.count()
        topic = Topic.objects.filter(name="topic", statement="4").exists()
        topics_count_after = Topic.objects.count()
        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 2, after_add)
        self.assertEqual(after_add, len(response.context['protocols']))
Exemple #28
0
 def test_mypage_success(self):
     client = Client()
     user_star_count = UserStar.objects.filter(user_id=1,
                                               movie_id=1).count()
     header = {'HTTP_Authorization': self.access_token}
     response = client.get('/user/mypage',
                           content_type='application/json',
                           **header)
     self.assertEqual(response.status_code, 200)
     self.assertEqual(
         response.json(), {
             'mypage_data': {
                 'user': '******',
                 'profile':
                 'https://github.com/InahChoi/project_whatthe/blob/main/banner1.jpg?raw=true',
                 'user_star_count': user_star_count
             }
         })
Exemple #29
0
    def test_search_by_status(self):
        client.login(username='******', password='******')

        project = Project.objects.create(user=self.not_master,
                                         flp=self.not_master,
                                         name='New project',
                                         description='spam',
                                         tasks='spam',
                                         targets='spam',
                                         target_group='spam',
                                         schedule='spam',
                                         resources='spam',
                                         finance_description='spam')

        response = client.get('/projects/search/status/Неразгледан/')
        projects = Project.objects.filter(status='Неразгледан')

        self.assertEqual(200, response.status_code)
        self.assertEqual(len(projects), len(response.context['projects']))
Exemple #30
0
 def test_my_evaluation_success(self):
     client = Client()
     user_star = UserStar.objects.filter(user_id=1, movie_id=1)
     header = {'HTTP_Authorization': self.access_token}
     response = client.get('/user/rating',
                           content_type='application/json',
                           **header)
     self.assertEqual(response.status_code, 200)
     self.assertEqual(
         response.json(), {
             "movie_info_data": [{
                 "title": "장고",
                 "image":
                 "https://github.com/InahChoi/project_whatthe/blob/main/banner2.jpg?raw=true",
                 "is_watcha": 1,
                 "star": 5,
                 "release_date": "2018-01-01"
             }]
         })
Exemple #31
0
    def test_search_by_status(self):
        client.login(username='******', password='******')

        project = Project.objects.create(
            user=self.not_master,
            flp=self.not_master,
            name='New project',
            description='spam',
            tasks='spam',
            targets='spam',
            target_group='spam',
            schedule='spam',
            resources='spam',
            finance_description='spam')

        response = client.get('/projects/search/status/Неразгледан/')
        projects = Project.objects.filter(status='Неразгледан')

        self.assertEqual(200, response.status_code)
        self.assertEqual(len(projects), len(response.context['projects']))
Exemple #32
0
    def test_show_project_by_id(self):
        client.login(username='******', password='******')
        before_edit = Project.objects.filter(name='other project name').count()

        project = Project.objects.create(
            user=self.not_master,
            flp=self.not_master,
            name='New project',
            description='spam',
            tasks='spam',
            targets='spam',
            target_group='spam',
            schedule='spam',
            resources='spam',
            finance_description='spam')

        response = client.get('/projects/archive/review/{}/'.format(project.pk))

        self.assertEqual(200, response.status_code)
        self.assertEqual(project.pk, response.context['project_show'].pk)
Exemple #33
0
    def test_show_project_by_id(self):
        client.login(username='******', password='******')
        before_edit = Project.objects.filter(name='other project name').count()

        project = Project.objects.create(user=self.not_master,
                                         flp=self.not_master,
                                         name='New project',
                                         description='spam',
                                         tasks='spam',
                                         targets='spam',
                                         target_group='spam',
                                         schedule='spam',
                                         resources='spam',
                                         finance_description='spam')

        response = client.get('/projects/archive/review/{}/'.format(
            project.pk))

        self.assertEqual(200, response.status_code)
        self.assertEqual(project.pk, response.context['project_show'].pk)
Exemple #34
0
    def test_listing_page_of_protocols(self):
        before_add = Protocol.objects.count()
        client.login(username='******', password='******')
        client.post('/protocols/add/', {
            "topics-TOTAL_FORMS": 2,
            "topics-INITIAL_FORMS": 0,
            "topics-MAX_NUM_FORMS": 1000,
            "institution": self.institution.pk,
            "number": "1234",
            "start_time": time(10, 0, 0),
            "scheduled_time": time(9, 0, 0),
            "quorum": 32,
            "absent": self.kril.pk,
            "attendents": self.kril.pk,
            "majority": 5,
            "current_majority": 4,
            "information": 'this is the best protocol ever', })

        client.post('/protocols/add/', {
            "topics-TOTAL_FORMS": 2,
            "topics-INITIAL_FORMS": 0,
            "topics-MAX_NUM_FORMS": 1000,
            "institution": self.institution.pk,
            "number": "13/11/1992/1235",
            "start_time": time(10, 0, 0),
            "scheduled_time": time(9, 0, 0),
            "quorum": 32,
            "absent": self.kril.pk,
            "attendents": self.kril.pk,
            "majority": 5,
            "current_majority": 4,
            "information": 'this is the best protocol ever', })

        response = client.get('/protocols/archive/1/')

        after_add = Protocol.objects.count()
        topic = Topic.objects.filter(name="topic", statement="4").exists()
        topics_count_after = Topic.objects.count()
        self.assertEqual(200, response.status_code)
        self.assertEqual(before_add + 2, after_add)
        self.assertEqual(after_add, len(response.context['protocols']))
Exemple #35
0
    def test_kakao_signup_success(self, mock_request):
        client = Client()

        class MockResponse:
            def json(self):
                return {
                    'id': '1004',
                    'properties': {
                        'nickname':
                        '최라라',
                        'profile_image':
                        'https://github.com/InahChoi/project_whatthe/blob/main/banner1.jpg?raw=true'
                    },
                }

        mock_request.get = MagicMock(return_value=MockResponse())
        header = {'HTTP_Authorization': 'access_token'}
        response = client.get('/user/login/kakao',
                              content_type='application/json',
                              **header)
        self.assertEqual(response.status_code, 201)
Exemple #36
0
    def test_projects_by_month_and_year(self):
        client.login(username='******', password='******')

        project = Project.objects.create(user=self.not_master,
                                         flp=self.not_master,
                                         name='New project',
                                         description='spam',
                                         tasks='spam',
                                         targets='spam',
                                         target_group='spam',
                                         schedule='spam',
                                         resources='spam',
                                         finance_description='spam')

        year = date.today().year
        month = date.today().month

        response = client.get('/projects/archive/{}/{}/'.format(year, month))
        projects = Project.objects.filter(created_at__year=year,
                                          created_at__month=month)

        self.assertEqual(200, response.status_code)
        self.assertEqual(len(projects), len(response.context['projects']))
Exemple #37
0
    def test_projects_by_month_and_year(self):
        client.login(username='******', password='******')

        project = Project.objects.create(
            user=self.not_master,
            flp=self.not_master,
            name='New project',
            description='spam',
            tasks='spam',
            targets='spam',
            target_group='spam',
            schedule='spam',
            resources='spam',
            finance_description='spam')

        year = date.today().year
        month = date.today().month

        response = client.get('/projects/archive/{}/{}/'.format(year, month))
        projects = Project.objects.filter(created_at__year=year, created_at__month=month)

        self.assertEqual(200, response.status_code)
        self.assertEqual(len(projects), len(response.context['projects']))
Exemple #38
0
    def test_show_projects_archive(self):
        client.login(username='******', password='******')
        for project_number in range(10):
            project = Project.objects.create(
                user=self.not_master,
                flp=self.not_master,
                name='Project{}'.format(project_number),
                description='spam',
                tasks='spam',
                targets='spam',
                target_group='spam',
                schedule='spam',
                resources='spam',
                finance_description='spam')

            if project_number < 4:
                client.post('/projects/edit_status/{}/'.format(project.pk),
                            {'status': 'approved'})

        response = client.get('/projects/archive/')

        self.assertEqual(200, response.status_code)
        self.assertEqual(6, len(response.context['unrevised']))
        self.assertEqual(4, len(response.context['approved']))
Exemple #39
0
    def test_show_projects_archive(self):
        client.login(username='******', password='******')
        for project_number in range(10):
            project = Project.objects.create(
                user=self.not_master,
                flp=self.not_master,
                name='Project{}'.format(project_number),
                description='spam',
                tasks='spam',
                targets='spam',
                target_group='spam',
                schedule='spam',
                resources='spam',
                finance_description='spam')

            if project_number < 4:
                client.post('/projects/edit_status/{}/'.format(project.pk), {
                                'status': 'approved'})

        response = client.get('/projects/archive/')

        self.assertEqual(200, response.status_code)
        self.assertEqual(6, len(response.context['unrevised']))
        self.assertEqual(4, len(response.context['approved']))
Exemple #40
0
    def test_complex_search(self):
        client.login(username='******', password='******')

        project = Project.objects.create(user=self.not_master,
                                         flp=self.not_master,
                                         name='New project',
                                         description='spam',
                                         tasks='spam',
                                         targets='spam',
                                         target_group='spam',
                                         schedule='spam',
                                         resources='spam',
                                         finance_description='spam')

        Project.objects.create(user=self.not_master,
                               flp=self.not_master,
                               name='Old project',
                               description='spam',
                               tasks='spam',
                               targets='spam',
                               target_group='spam',
                               schedule='spam',
                               resources='spam',
                               finance_description='spam')

        search_data = urlencode({
            "name": "New project",
            "status": "unrevised",
            "flp": self.not_master.first_name
        })

        response = client.get('/projects/archive/?{}'.format(search_data))
        projects = Project.objects.filter(name="New project")

        self.assertEqual(200, response.status_code)
        self.assertEqual(len(projects), len(response.context['projects']))
Exemple #41
0
 def test_products_GET(self):
     client = Client()
     response = client.get(reverse('addproduct'))
     self.assertEquals(response.status_code, 200)
     self.assertTemplateUsed(response, 'addproducts.html')
Exemple #42
0
 def test_get_invalid_single_customer(self):
     response = client.get(
         reverse('get_delete_update_customer', kwargs={"pk": 30}))
     self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
Exemple #43
0
 def test_get_all_customers(self):
     response = client.get(reverse('get_post_customer'))
     customers = Customer.objects.all()
     serializer = CustomerSerializer(customers, many=True)
     self.assertEqual(response.data, serializer.data)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
Exemple #44
0
 def test_search_institution_in_bg(self):
     response = client.get('/protocols/search/{}/'.format(self.institution2.name))
     self.assertEqual(200, response.status_code)
     self.assertTrue(response.content)
Exemple #45
0
 def test_search_users_in_en(self):
     response = client.get('/members/search/i/')
     self.assertEqual(response.status_code, 200)
     self.assertTrue(response.content)
Exemple #46
0
 def test_search_users_in_bg(self):
     response = client.get('/members/search/{}/'.format(self.gogo.first_name))
     self.assertEqual(response.status_code, 200)
     self.assertTrue(response.content)
Exemple #47
0
 def test_user_not_found(self):
     response = client.get('/members/search/pe/')
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.content, '[]')
Exemple #48
0
 def test_get_user_projects(self):
     client.login(username='******', password='******')
     response = client.get('/members/profile/')
     self.assertEqual(response.status_code, 200)
     self.assertEqual(len(response.context['projects']), 1)
     self.assertEqual(response.context['projects'][0].pk, self.project.pk)
Exemple #49
0
 def test_institution_not_found(self):
     response = client.get('/protocols/search/pe/')
     self.assertEqual(200, response.status_code)
     self.assertEqual(response.content, '[]')
Exemple #50
0
    def test_index_page(self):
        client = Client()
        response = client.get("/flights/")

        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.context["flights"].count(), 3)
Exemple #51
0
 def test_tweet_list(self):
     client = self.get_client()
     response = client.get("/api/tweets/")
     self.assertEqual(response.status_code, 200)
     self.assertEqual(len(response.json()), 3)
def _get_streamer_url(client, stream_type, app_id):
    response = client.get(reverse('api:streamers:streamers'), {
        'type': stream_type,
        'app_id': app_id
    })
    return _to_dict(response)