Esempio n. 1
0
    def setUp(self):
        super(CourseResourceTest, self).setUp()
        user = User.objects.get(username='******')
        admin = User.objects.get(username='******')
        staff = User.objects.get(username='******')
        teacher = User.objects.get(username='******')
        self.user_auth = {
            'username': '******',
            'api_key': get_api_key(user=user).key,
        }
        self.admin_auth = {
            'username': '******',
            'api_key': get_api_key(user=admin).key
        }
        self.staff_auth = {
            'username': '******',
            'api_key': get_api_key(user=staff).key
        }
        self.teacher_auth = {
            'username': '******',
            'api_key': get_api_key(user=teacher).key
        }
        self.url = get_api_url('v1', 'course')

        self.copy_test_courses()
Esempio n. 2
0
 def setUp(self):
     super(CourseResourceTest, self).setUp()
     user = User.objects.get(username='******')
     admin = User.objects.get(username='******')
     self.auth_data = {
         'username': '******',
         'api_key': get_api_key(user=user).key,
     }
     self.admin_auth = {
         'username': '******',
         'api_key': get_api_key(user=admin).key
     }
     self.url = get_api_url('course')
Esempio n. 3
0
 def setUp(self):
     super(CourseResourceTest, self).setUp()
     user = User.objects.get(username='******')
     admin = User.objects.get(username='******')
     self.auth_data = {
         'username': '******',
         'api_key': get_api_key(user=user).key,
     }
     self.admin_auth = {
         'username': '******',
         'api_key': get_api_key(user=admin).key
     }
     self.url = get_api_url('course')
 def setUp(self):
     super(QuizAttemptResourceTest, self).setUp()
     self.username = '******'
     user = User.objects.get(username=self.username)
     api_key = get_api_key(user)
     self.api_key = api_key.key
     self.url = get_api_url('quizattempt')
 def setUp(self):
     super(TrackerResourceTest, self).setUp()
     self.username = '******'
     user = User.objects.get(username=self.username)
     api_key = get_api_key(user=user)
     self.api_key = api_key.key
     self.url = get_api_url('v2', 'tracker')
Esempio n. 6
0
 def test_cvr_numre_exists_and_not_exists(self):
     """ Verifies that no virksomhed is returned when both existing and non-existing
     cvr_numre are given.
     """
     with Client(api_key=get_api_key()) as client:
         virksomheder = client.cvr.virksomheder(cvr_numre=[10103940, 1337])
         self.assertEqual(0, len(virksomheder))
Esempio n. 7
0
 def test_navn_and_cvr_numre(self):
     """ Verifies that InvalidRequestError is raised when both navn and
     cvr_numre is given.
     """
     with Client(api_key=get_api_key()) as client:
         with self.assertRaises(InvalidRequestError):
             client.cvr.virksomheder(navn="navn", cvr_numre=[1234])
Esempio n. 8
0
 def test_navn_exists(self):
     """ Verifies that at least one virksomhed is returned when given a navn
     that exists.
     """
     with Client(api_key=get_api_key()) as client:
         virksomheder = client.cvr.virksomheder(navn="statsministeriet")
         self.assertTrue(len(virksomheder) > 0)
 def setUp(self):
     super(DeleteAccountResourceTest, self).setUp()
     self.username = '******'
     user = User.objects.get(username=self.username)
     api_key = get_api_key(user=user)
     self.api_key = api_key.key
     self.url = get_api_url('v2', 'deleteaccount')
 def setUp(self):
     super(QuizAttemptResourceTest, self).setUp()
     self.username = '******'
     user = User.objects.get(username=self.username)
     api_key = get_api_key(user)
     self.api_key = api_key.key
     self.url = get_api_url('quizattempt')
Esempio n. 11
0
 def setUp(self):
     super(PointsResourceTest, self).setUp()
     self.username = '******'
     user = User.objects.get(username='******')
     api_key = get_api_key(user=user)
     self.api_key = api_key.key
     self.url = get_api_url('points')
Esempio n. 12
0
 def test_p_nummer_exists_and_not_exists(self):
     """ Verifies that an empty list is returned if one of the given p numre do not exist.
     """
     with Client(api_key=get_api_key()) as client:
         produktionsenheder = client.cvr.produktionsenheder(
             p_numre=[1004862579, 1337])
         self.assertEqual(0, len(produktionsenheder))
 def setUp(self):
     super(TrackerResourceTest, self).setUp()
     self.username = '******'
     user = User.objects.get(username=self.username)
     api_key = get_api_key(user=user)
     self.api_key = api_key.key
     self.url = get_api_url('tracker')
Esempio n. 14
0
 def test_adresse_not_exists(self):
     """ Verifies that no produktionsenheder are returned when given an address that has
     no produktionsenheder.
     """
     with Client(api_key=get_api_key()) as client:
         produktionsenheder = client.cvr.produktionsenheder(
             adresse="aklsdajhk1kj81342")
         self.assertEqual(0, len(produktionsenheder))
Esempio n. 15
0
 def test_adresse_exists(self):
     """ Verifies that at least one produktionsenhed is returned when given an address
     that has produktionsenheder.
     """
     with Client(api_key=get_api_key()) as client:
         produktionsenheder = client.cvr.produktionsenheder(
             adresse="Prins Jørgens Gård 11")
         self.assertTrue(len(produktionsenheder) > 1)
Esempio n. 16
0
 def test_cvr_nummer_exists(self):
     """ Verifies that a single virksomhed is returned when a single cvr_nummer is given.
     """
     cvr_nummer = 10103940
     with Client(api_key=get_api_key()) as client:
         virksomheder = client.cvr.virksomheder(cvr_numre=[cvr_nummer])
         self.assertEqual(1, len(virksomheder))
         self.assertEqual(cvr_nummer, virksomheder[0].cvr_nummer)
Esempio n. 17
0
 def test_both_p_numre_and_adresse_given(self):
     """ Verifies that InvalidRequestError is raised if both adresse and p_numre
     args are given.
     """
     with Client(api_key=get_api_key()) as client:
         with self.assertRaises(InvalidRequestError):
             client.cvr.produktionsenheder(adresse="adresse",
                                           p_numre=[1234])
Esempio n. 18
0
 def test_navn_not_exists(self):
     """ Verifies that no virksomhed is returned when given a navn that does
     not exist.
     """
     with Client(api_key=get_api_key()) as client:
         virksomheder = client.cvr.virksomheder(
             navn="kfgnkjdfgkjdgkdfhgkdjhgkdjgkjdfhgkjdfkdfngkdfjn")
         self.assertEqual(0, len(virksomheder))
Esempio n. 19
0
 def test_get_unauthorized(self):
     self.username = '******'
     user = User.objects.get(username='******')
     api_key = get_api_key(user=user)
     self.api_key = api_key.key
     self.url = get_api_url('v2', 'points')
     self.assertHttpUnauthorized(self.api_client.get(self.url,
                                                     format='json'))
Esempio n. 20
0
 def setUp(self):
     super(AwardsResourceTest, self).setUp()
     user = User.objects.get(username='******')
     api_key = get_api_key(user=user)
     self.auth_data = {
         'username': '******',
         'api_key': api_key.key,
     }
     self.url = get_api_url('awards')
Esempio n. 21
0
 def setUp(self):
     super(AwardsResourceTest, self).setUp()
     user = User.objects.get(username='******')
     api_key = get_api_key(user=user)
     self.auth_data = {
         'username': '******',
         'api_key': api_key.key,
     }
     self.url = get_api_url('v1', 'awards')
Esempio n. 22
0
 def test_p_nummer_exists(self):
     """ Verifies that a single produktionsenhed is returned when a single p_nummer is given.
     """
     p_nummer = 1004862579
     with Client(api_key=get_api_key()) as client:
         produktionsenheder = client.cvr.produktionsenheder(
             p_numre=[p_nummer])
         self.assertEqual(1, len(produktionsenheder))
         self.assertEqual(p_nummer, produktionsenheder[0].p_nummer)
Esempio n. 23
0
 def test_multiple_p_numre_exists(self):
     """ Verifies that multiple produktionsenheder are returned when multiple p_numre are given
     """
     p_numre = [1004862579, 1003388394, 1020852379]
     with Client(api_key=get_api_key()) as client:
         produktionsenheder = client.cvr.produktionsenheder(p_numre=p_numre)
         self.assertEqual(3, len(produktionsenheder))
         for produktionsenhed in produktionsenheder:
             self.assertTrue(produktionsenhed.p_nummer in p_numre)
Esempio n. 24
0
 def test_multiple_cvr_numre_exists(self):
     """ Verifies that multiple virksomheder are returned when multiple cvr_numre are given
     """
     cvr_numre = {10103940, 10150817, 10213231}
     with Client(api_key=get_api_key()) as client:
         virksomheder = client.cvr.virksomheder(cvr_numre=cvr_numre)
         self.assertEqual(3, len(virksomheder))
         for virksomhed in virksomheder:
             self.assertTrue(virksomhed.cvr_nummer in cvr_numre)
Esempio n. 25
0
 def test_post_not_allowed(self):
     self.username = '******'
     user = User.objects.get(username='******')
     api_key = get_api_key(user=user)
     self.api_key = api_key.key
     self.url = get_api_url('v2', 'points')
     self.assertHttpMethodNotAllowed(self.api_client.post(self.url,
                                                          format='json',
                                                          data={}))
 def setUpClass(cls):
     super(UserProfileBaseTestCase, cls).setUpClass()
     cls.username = '******'
     cls.user = User.objects.get(username=cls.username)
     cls.api_key = get_api_key(user=cls.user).key
     cls.base_data = {
         'email': '*****@*****.**',
         'first_name': 'demo',
         'last_name': 'user'
     }
     cls.url = get_api_url('v2', 'profileupdate')
Esempio n. 27
0
 def test_get_apikeyinvalid(self):
     self.username = '******'
     user = User.objects.get(username='******')
     api_key = get_api_key(user=user)
     self.api_key = api_key.key
     self.url = get_api_url('v2', 'points')
     auth_header = self.create_apikey(username=self.username,
                                      api_key="badbadbad")
     self.assertHttpUnauthorized(
         self.api_client.get(self.url,
                             format='json',
                             authentication=auth_header))
Esempio n. 28
0
 def setUp(self):
     super(ProfileUpdateResourceTest, self).setUp()
     self.username = '******'
     self.user = User.objects.get(username=self.username)
     self.api_key = get_api_key(user=self.user).key
     self.base_data = {
         'email': '*****@*****.**',
         'first_name': 'demo',
         'last_name': 'user',
         'organisation': ''
     }
     self.url = get_api_url('v1', 'profileupdate')
Esempio n. 29
0
 def test_no_objects(self):
     user = User.objects.get(username='******')
     api_key = get_api_key(user=user)
     self.auth_data = {
         'username': '******',
         'api_key': api_key.key,
     }
     self.url = get_api_url('v2', 'awards')
     resp = self.api_client.get(self.url,
                                format='json',
                                data=self.auth_data)
     self.assertValidJSON(resp.content)
     self.assertEqual(len(self.deserialize(resp)['objects']), 0)
Esempio n. 30
0
 def setUp(self):
     super(ProgressResourceTest, self).setUp()
     self.user = User.objects.get(username='******')
     self.admin = User.objects.get(username='******')
     self.staff = User.objects.get(username='******')
     self.teacher = User.objects.get(username='******')
     self.user_auth = {
         'username': '******',
         'api_key': get_api_key(user=self.user).key,
     }
     self.admin_auth = {
         'username': '******',
         'api_key': get_api_key(user=self.admin).key
     }
     self.staff_auth = {
         'username': '******',
         'api_key': get_api_key(user=self.staff).key
     }
     self.teacher_auth = {
         'username': '******',
         'api_key': get_api_key(user=self.teacher).key
     }
     self.url = get_api_url('v2', 'progress')
Esempio n. 31
0
    def setUp(self):
        super(DraftCourseAccessTest, self).setUp()
        self.user = User.objects.get(username='******')
        self.admin = User.objects.get(username='******')
        self.staff = User.objects.get(username='******')
        self.teacher = User.objects.get(username='******')
        self.manager = User.objects.get(username='******')
        self.viewer = User.objects.get(username='******')
        self.user_auth = {
            'username': '******',
            'api_key': get_api_key(user=self.user).key,
        }
        self.admin_auth = {
            'username': '******',
            'api_key': get_api_key(user=self.admin).key
        }
        self.staff_auth = {
            'username': '******',
            'api_key': get_api_key(user=self.staff).key
        }
        self.teacher_auth = {
            'username': '******',
            'api_key': get_api_key(user=self.teacher).key
        }
        self.manager_auth = {
            'username': '******',
            'api_key': get_api_key(user=self.manager).key
        }
        self.viewer_auth = {
            'username': '******',
            'api_key': get_api_key(user=self.viewer).key
        }
        self.live_course_url_pk = get_api_url('v2', 'course', 1) \
            + self.STR_DOWNLOAD
        self.draft_course_url_pk = get_api_url('v2', 'course', 3) \
            + self.STR_DOWNLOAD
        self.live_course_url_shortname = get_api_url('v2',
                                                     'course',
                                                     'anc1-all') \
            + self.STR_DOWNLOAD
        self.draft_course_url_shortname = get_api_url('v2',
                                                      'course',
                                                      'draft-test') \
            + self.STR_DOWNLOAD
        self.tag_url = get_api_url('v2', 'tag')
        self.draft_tag_url = get_api_url('v2', 'tag', 8)
        self.live_tag_url = get_api_url('v2', 'tag', 1)

        self.copy_test_courses()
Esempio n. 32
0
 def setUp(self):
     super(UserResourceTest, self).setUp()
     self.url = '/api/v1/user/'
     user = User.objects.get(username='******')
     self.valid_api_key = get_api_key(user=user)
Esempio n. 33
0
 def setUp(self):
     super(UserResourceTest, self).setUp()
     self.url = '/api/v1/user/'
     user = User.objects.get(username='******')
     self.valid_api_key = get_api_key(user=user)
Esempio n. 34
0
 def test_api_key_valid_api_key(self):
     """ Verifies that test_api_key succeeds with a valid api key. """
     with Client(api_key=get_api_key()) as client:
         client.test_api_key()
Esempio n. 35
0
 def setUp(self):
     super(UploadAPIActivityLogTest, self).setUp()
     self.username = '******'
     user = User.objects.get(username=self.username)
     api_key = get_api_key(user=user)
     self.api_key = api_key.key