def test_not_note_owner(self): self.note.update(author=user_factory()) data = self._attachments(num=2) res = self.client.post(self.attachment_url, data=data, content_type=MULTIPART_CONTENT) eq_(res.status_code, 403)
def test_create_note_existing_thread(self): # Initial note. thread, note = create_comm_note(self.app, self.app.current_version, self.user, 'huehue') # Second note from contact. thread, reply = create_comm_note(self.app, self.app.current_version, self.contact, 'euheuh!', note_type=comm.REJECTION) # Mark read by author. eq_(reply.read_by_users.count(), 1) # Third person joins thread. thread, last_word = create_comm_note(self.app, self.app.current_version, user_factory(), 'euheuh!', note_type=comm.MORE_INFO_REQUIRED) # More checking that joining a thread marks all old notes as read. eq_(thread.thread_cc.count(), 3) eq_(note.read_by_users.count(), 3) eq_(last_word.read_by_users.count(), 1)
def test_ratings_sort(self): app1 = self.webapp app2 = app_factory() user = user_factory() app1._reviews.create(user=user, rating=1) app2._reviews.create(user=user, rating=5) self.refresh() res = self.client.get(self.url, {'sort': 'rating'}) eq_(res.status_code, 200) eq_(res.json['objects'][0]['id'], app2.id) eq_(res.json['objects'][1]['id'], app1.id)
def test_ratings_sort(self): app1 = self.webapp app2 = app_factory() user = user_factory() app1._reviews.create(user=user, rating=1) app2._reviews.create(user=user, rating=5) self.refresh() res = self.client.get(self.url, {"sort": "rating"}) eq_(res.status_code, 200) eq_(res.json["objects"][0]["id"], app2.id) eq_(res.json["objects"][1]["id"], app1.id)
def test_get_attachment_not_note_perm(self): data = self._attachments(num=1) res = self.client.post(self.attachment_url, data=data, content_type=MULTIPART_CONTENT) attachment_id = res.json['attachments'][0]['id'] # Remove perms. self.note.update(author=user_factory()) self.profile.addonuser_set.all().delete() get_attachment_url = reverse('comm-attachment-detail', args=[self.note.id, attachment_id]) res = self.client.get(get_attachment_url) eq_(res.status_code, 403)
def test_basic(self): sample_email = os.path.join(settings.ROOT, 'mkt', 'comm', 'tests', 'emails', 'email.txt') req = self.get_request(data={'body': open(sample_email).read()}) app = app_factory() user = user_factory() self.grant_permission(user, 'Admin:*') t = CommunicationThread.objects.create(_addon=app, _version=app.current_version) t.token.create(user=user, uuid='5a0b8a83d501412589cc5d562334b46b') res = post_email(req) eq_(res.status_code, 201) ok_(t.notes.count())
def test_basic(self): sample_email = os.path.join(settings.ROOT, 'mkt', 'comm', 'tests', 'email.txt') req = self.get_request(data={'body': open(sample_email).read()}) app = app_factory() user = user_factory() self.grant_permission(user, 'Admin:*') t = CommunicationThread.objects.create(addon=app, version=app.current_version) t.token.create(user=user, uuid='5a0b8a83d501412589cc5d562334b46b') res = post_email(req) eq_(res.status_code, 201) ok_(t.notes.count())
def test_create_note_existing_thread(self): # Initial note. thread, note = create_comm_note( self.app, self.app.current_version, self.user, 'huehue') # Second note from contact. thread, reply = create_comm_note( self.app, self.app.current_version, self.contact, 'euheuh!', note_type=comm.REJECTION) # Third person joins thread. thread, last_word = create_comm_note( self.app, self.app.current_version, user_factory(), 'euheuh!', note_type=comm.MORE_INFO_REQUIRED) eq_(thread.thread_cc.count(), 3)
def test_create_note_existing_thread(self): # Initial note. thread, note = create_comm_note(self.app, self.app.current_version, self.user, 'huehue') # Second note from contact. thread, reply = create_comm_note(self.app, self.app.current_version, self.contact, 'euheuh!', note_type=comm.REJECTION) # Third person joins thread. thread, last_word = create_comm_note(self.app, self.app.current_version, user_factory(), 'euheuh!', note_type=comm.MORE_INFO_REQUIRED) eq_(thread.thread_cc.count(), 3)
def test_create_note_existing_thread(self): # Initial note. thread, note = create_comm_note( self.app, self.app.current_version, self.user, 'huehue') # Second note from contact. thread, reply = create_comm_note( self.app, self.app.current_version, self.contact, 'euheuh!', note_type=comm.REJECTION) # Mark read by author. eq_(reply.read_by_users.count(), 1) # Third person joins thread. thread, last_word = create_comm_note( self.app, self.app.current_version, user_factory(), 'euheuh!', note_type=comm.MORE_INFO_REQUIRED) # More checking that joining a thread marks all old notes as read. eq_(thread.thread_cc.count(), 3) eq_(note.read_by_users.count(), 3) eq_(last_word.read_by_users.count(), 1)
def setUp(self): self.create_switch('comm-dashboard') self.contact = user_factory(username='******') self.user = user_factory() self.grant_permission(self.user, '*:*') self.app = app_factory(mozilla_contact=self.contact.email)