Skip to content

Commit

Permalink
Merge pull request #8 from sheldonkwoodward/feature/pypi
Browse files Browse the repository at this point in the history
Feature/pypi
  • Loading branch information
sheldonkwoodward authored Sep 7, 2018
2 parents 2f56628 + aa709c0 commit c5301e4
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 39 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
language: python

python:
- 3.5
- 3.6
matrix:
include:
- python: 3.7
Expand Down
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Sheldon Woodward

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 4 additions & 0 deletions marknote/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# sheldon woodward
# 9/6/18

__version__ = '1.0.0'
4 changes: 1 addition & 3 deletions marknote/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# sheldon woodward
# DATE

"""Docstring"""
# 9/6/18
34 changes: 17 additions & 17 deletions marknote/tests/test_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_folder_create(self):
'title': 'title',
}
response = self.client.post(reverse(self.view_name), body)
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
folder = Folder.objects.first()
# test database
self.assertEqual(body['title'], folder.title)
Expand All @@ -59,7 +59,7 @@ def test_folder_create_in_folder(self):
'container': top_folder.id,
}
bottom_response = self.client.post(reverse(self.view_name), body)
bottom_response_body = json.loads(bottom_response.content)
bottom_response_body = json.loads(bottom_response.content.decode('utf-8'))
bottom_folder = Folder.objects.get(title=body['title'])
# test database
self.assertEqual(bottom_folder.container.id, body['container'])
Expand Down Expand Up @@ -92,7 +92,7 @@ def test_folder_create_not_authenticated(self):
'title': 'title',
}
response = client.post(reverse(self.view_name), body)
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
folders = Folder.objects.all()
# test database
self.assertEqual(len(folders), 0)
Expand Down Expand Up @@ -141,7 +141,7 @@ def test_folder_retrieve_none(self):
Tests that no folders are retrieved when none exist.
"""
response = self.client.get(reverse(self.view_name))
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
empty_body = {
'folders': [],
}
Expand All @@ -158,7 +158,7 @@ def test_folder_retrieve_multiple(self):
Folder(title='title2', owner=self.user).save()
# request
response = self.client.get(reverse(self.view_name))
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test response
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(len(response_body['folders']), 2)
Expand All @@ -181,7 +181,7 @@ def test_folder_filter_title(self):
folder_1.save()
# request
response = self.client.get(reverse(self.view_name) + '?title=c')
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test response
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(len(response_body['folders']), 2)
Expand All @@ -198,7 +198,7 @@ def test_folder_retrieve_owned(self):
Folder(title='title', owner=User.objects.create_user(username='other_user')).save()
# request
response = self.client.get(reverse(self.view_name))
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test response
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(len(response_body['folders']), 1)
Expand All @@ -212,7 +212,7 @@ def test_folder_retrieve_not_authenticated(self):
client = APIClient()
# request
response = client.get(reverse(self.view_name))
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test response
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
self.assertFalse('folders' in response_body)
Expand Down Expand Up @@ -242,7 +242,7 @@ def test_folder_retrieve(self):
Folder(title='title2', owner=self.user).save()
# request
response = self.client.get(reverse(self.view_name, args=[folder.id]))
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test response
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response_body['pk'], folder.id)
Expand Down Expand Up @@ -286,7 +286,7 @@ def test_folder_retrieve_not_authenticated(self):
folder.save()
# request
response = client.get(reverse(self.view_name, args=[folder.id]))
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test response
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
self.assertFalse('pk' in response_body)
Expand Down Expand Up @@ -323,7 +323,7 @@ def test_folder_update_full(self):
'container': top_folder.id,
}
response = self.client.put(reverse(self.view_name, args=[bottom_folder.id]), body)
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test database
folder = Folder.objects.get(id=bottom_folder.id)
self.assertEqual(body['title'], folder.title)
Expand All @@ -346,7 +346,7 @@ def test_folder_update_partial(self):
'title': 'title changed',
}
response = self.client.patch(reverse(self.view_name, args=[folder.id]), body)
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test database
folder = Folder.objects.first()
self.assertEqual(body['title'], folder.title)
Expand All @@ -369,7 +369,7 @@ def test_folder_update_container_does_not_exist(self):
'container': '2',
}
response = self.client.patch(reverse(self.view_name, args=[folder.id]), body)
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test database
folder = Folder.objects.first()
self.assertEqual(original_title, folder.title)
Expand All @@ -392,7 +392,7 @@ def test_folder_update_read_only_fields(self):
'updated': '2018-09-04T16:30:28.469865Z',
}
response = self.client.patch(reverse(self.view_name, args=[original_folder.id]), body)
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test database
folder = Folder.objects.first()
self.assertEqual(original_folder, folder)
Expand All @@ -415,7 +415,7 @@ def test_folder_update_not_owned(self):
'title': 'title changed',
}
response = self.client.patch(reverse(self.view_name, args=[folder.id]), body)
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test database
folder = Folder.objects.first()
self.assertEqual(original_title, folder.title)
Expand All @@ -439,7 +439,7 @@ def test_folder_update_not_authenticated(self):
'title': 'title changed',
}
response = client.patch(reverse(self.view_name, args=[folder.id]), body)
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test database
folder = Folder.objects.first()
self.assertEqual(original_title, folder.title)
Expand Down Expand Up @@ -467,7 +467,7 @@ def test_folder_update_not_authorized(self):
'title': 'title changed',
}
response = client.patch(reverse(self.view_name, args=[folder.id]), body)
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test database
folder = Folder.objects.first()
self.assertEqual(original_title, folder.title)
Expand Down
38 changes: 19 additions & 19 deletions marknote/tests/test_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_note_create(self):
'content': 'content',
}
response = self.client.post(reverse(self.view_name), body)
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
note = Note.objects.first()
# test database
self.assertEqual(body['title'], note.title)
Expand Down Expand Up @@ -63,7 +63,7 @@ def test_note_create_in_folder(self):
'container': folder.id,
}
note_response = self.client.post(reverse(self.view_name), note_body)
note_response_body = json.loads(note_response.content)
note_response_body = json.loads(note_response.content.decode('utf-8'))
note = Note.objects.first()
# test database
self.assertEqual(note.container.id, note_body['container'])
Expand Down Expand Up @@ -116,7 +116,7 @@ def test_note_create_not_authenticated(self):
'content': 'content',
}
response = client.post(reverse(self.view_name), body)
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
notes = Note.objects.all()
# test database
self.assertEqual(len(notes), 0)
Expand Down Expand Up @@ -166,7 +166,7 @@ def test_note_retrieve_none(self):
Tests that no notes are retrieved when none exist.
"""
response = self.client.get(reverse(self.view_name))
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
empty_body = {
'notes': [],
}
Expand All @@ -183,7 +183,7 @@ def test_note_retrieve_multiple(self):
Note(title='title2', content='content2', owner=self.user).save()
# request
response = self.client.get(reverse(self.view_name))
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test response
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(len(response_body['notes']), 2)
Expand All @@ -206,7 +206,7 @@ def test_note_filter_title(self):
note_1.save()
# request
response = self.client.get(reverse(self.view_name) + '?title=c')
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test response
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(len(response_body['notes']), 2)
Expand All @@ -225,7 +225,7 @@ def test_note_filter_content(self):
note_1.save()
# request
response = self.client.get(reverse(self.view_name) + '?content=c')
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test response
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(len(response_body['notes']), 2)
Expand All @@ -245,7 +245,7 @@ def test_note_filter_title_and_content(self):
note_1.save()
# request
response = self.client.get(reverse(self.view_name) + '?title=a&content=3')
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test response
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(len(response_body['notes']), 2)
Expand All @@ -262,7 +262,7 @@ def test_note_retrieve_owned(self):
Note(title='title', content='content', owner=User.objects.create_user(username='other_user')).save()
# request
response = self.client.get(reverse(self.view_name))
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test response
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(len(response_body['notes']), 1)
Expand All @@ -276,7 +276,7 @@ def test_note_retrieve_not_authenticated(self):
client = APIClient()
# request
response = client.get(reverse(self.view_name))
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test response
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
self.assertFalse('notes' in response_body)
Expand Down Expand Up @@ -306,7 +306,7 @@ def test_note_retrieve(self):
Note(title='title2', content='content2', owner=self.user).save()
# request
response = self.client.get(reverse(self.view_name, args=[note.id]))
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test response
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response_body['pk'], note.id)
Expand Down Expand Up @@ -350,7 +350,7 @@ def test_note_retrieve_not_authenticated(self):
note.save()
# request
response = client.get(reverse(self.view_name, args=[note.id]))
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test response
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
self.assertFalse('pk' in response_body)
Expand Down Expand Up @@ -388,7 +388,7 @@ def test_note_update_full(self):
'container': folder.id,
}
response = self.client.put(reverse(self.view_name, args=[note.id]), body)
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test database
note = Note.objects.first()
self.assertEqual(body['title'], note.title)
Expand All @@ -414,7 +414,7 @@ def test_note_update_partial(self):
'title': 'title changed',
}
response = self.client.patch(reverse(self.view_name, args=[note.id]), body)
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test database
note = Note.objects.first()
self.assertEqual(body['title'], note.title)
Expand All @@ -440,7 +440,7 @@ def test_note_update_container_does_not_exist(self):
'container': '1',
}
response = self.client.patch(reverse(self.view_name, args=[note.id]), body)
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test database
note = Note.objects.first()
self.assertEqual(original_title, note.title)
Expand All @@ -464,7 +464,7 @@ def test_note_update_read_only_fields(self):
'updated': '2018-09-04T16:30:28.469865Z',
}
response = self.client.patch(reverse(self.view_name, args=[original_note.id]), body)
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test database
note = Note.objects.first()
self.assertEqual(original_note, note)
Expand All @@ -490,7 +490,7 @@ def test_note_update_not_owned(self):
'title': 'title changed',
}
response = self.client.patch(reverse(self.view_name, args=[note.id]), body)
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test database
note = Note.objects.first()
self.assertEqual(original_title, note.title)
Expand All @@ -516,7 +516,7 @@ def test_note_update_not_authenticated(self):
'title': 'title changed',
}
response = client.patch(reverse(self.view_name, args=[note.id]), body)
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test database
note = Note.objects.first()
self.assertEqual(original_title, note.title)
Expand Down Expand Up @@ -546,7 +546,7 @@ def test_note_update_not_authorized(self):
'title': 'title changed',
}
response = client.patch(reverse(self.view_name, args=[note.id]), body)
response_body = json.loads(response.content)
response_body = json.loads(response.content.decode('utf-8'))
# test database
note = Note.objects.first()
self.assertEqual(original_title, note.title)
Expand Down
Loading

0 comments on commit c5301e4

Please sign in to comment.