示例#1
0
    def setUp(self):
        self.user = factory_user()
        self.client.force_login(self.user)

        office = factory_office(name='吉本興業')
        self.combi1 = factory_combi(name='トレンディエンジェル', office=office)
        self.combi2 = factory_combi(name='笑い飯', office=office)
示例#2
0
    def setUp(self):
        self.user = factory_user()
        self.client.force_login(self.user)

        office = factory_office(name='吉本興業')
        factory_combi(name='霜降り明星', office=office)
        factory_combi(name='とろサーモン', office=office)
        factory_combi(name='銀シャリ', office=office)
示例#3
0
    def setUp(self):
        self.user = factory_user(
            username='******',
            email='*****@*****.**'
        )
        self.client.force_login(self.user)

        office = factory_office(name='人力舎')
        self.combi = factory_combi(name='アンタッチャブル', office=office)
        self.url = reverse('app:delete', args=[self.combi.pk])
示例#4
0
def factory_token(**kwargs):
    if 'request' in kwargs:
        return create_token(kwargs['request'])
    else:
        d = {
            'token': ''.join(
                random.choice('abcdefghijklmn') for _ in range(32)
            ),
            'user': factory_user()
        }
        d.update(kwargs)
        return Token.objects.create(**d)
示例#5
0
    def test_invalid_token(self):
        """他のユーザーのトークンでコンビ削除"""
        request1 = RequestFactory()
        request1.user = self.user
        factory_token(request=request1)

        request2 = RequestFactory()
        request2.user = factory_user()
        tk = factory_token(request=request2)

        self.header = {'HTTP_AUTHORIZATION': 'Token ' + tk.token}

        res = self.client.delete(self.url, **self.header)
        self.assertEqual(res.status_code, 400)

        msg = json.loads(res.content)['message']
        self.assertEqual(msg, 'トークンが異なります')
        self.assertEqual(Combi.objects.count(), 1)
示例#6
0
    def test_invalid_token(self):
        """他のユーザーのトークンでコンビ作成"""
        request1 = RequestFactory()
        request1.user = self.user
        factory_token(request=request1)

        request2 = RequestFactory()
        request2.user = factory_user()
        token2 = factory_token(request=request2)

        self.header = {'HTTP_AUTHORIZATION': 'Token ' + token2.token}

        res = self.client.post(COMBI_CREATE_URL, json.dumps({
            'name': 'チュートリアル',
            'office': '吉本興業',
        }), content_type='application/json', **self.header)
        self.assertEqual(res.status_code, 400)

        msg = json.loads(res.content)['message']
        self.assertEqual(msg, 'トークンが異なります')
        self.assertEqual(Combi.objects.count(), 0)
示例#7
0
 def setUp(self):
     self.user = factory_user(
         username='******',
         email='*****@*****.**'
     )
     self.client.force_login(self.user)
示例#8
0
 def setUp(self):
     self.user = factory_user(
         username='******',
         email='*****@*****.**'
     )