8000 Created tests for post module · FeverCode/GAwards@7030050 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7030050

Browse files
committed
Created tests for post module
1 parent 11f38f8 commit 7030050

File tree

2 files changed

+155
-4
lines changed

2 files changed

+155
-4
lines changed

README.md

Lines changed: 111 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,111 @@
1-
# GAwards
2-
An application that allows a user to post a project he/she has created and get it reviewed by his/her peers.
1+
# By FeverCode
2+
3+
## GAwards
4+
5+
## Table of Content
6+
7+
+ [Description](#description)
8+
+ [Requirements](#requirements)
9+
+ [Installation](#installation)
10+
+ [Running Project](#running-project)
11+
+ [Running Tests](#running-tests)
12+
+ [Api Endpoints](#api-endpoints)
13+
+ [Project Objectives](#project-objectives)
14+
+ [Technologies Used](#technologies-used)
15+
+ [Licence](#licence)
16+
+ [Authors Info](#authors-info)
17+
18+
## Description
19+
20+
An application that allows a user to post a project he/she has created and get it reviewed by his/her peers.
21+
22+
Live link to the project
23+
[GAwards](https://g-awards.herokuapp.com/)
24+
25+
## Requirements
26+
27+
+ A computer running on either Windows, MacOS or Ubuntu operating system installed with the following:
28+
29+
```-Python version 3.8
30+
-Django
31+
-Pip
32+
-virtualenv
33+
```
34+
35+
## Installation
36+
37+
+ Open Terminal {Ctrl+Alt+T} on ubuntu
38+
39+
+ git clone `https://github.com/FeverCode/GAwards`
40+
+ cd Instagram-clone
41+
+ code . or atom . based on prefered text editor
42+
43+
## Running Project
44+
45+
+ On terminal where you have opened the cloned project
46+
+ `sudo pip3 install virtualenv` - To install virtual enviroment
47+
+ `virtualenv venv` - To create virtual enviroment
48+
+ `source venv/bin/activate` - To activate virtual enviroment
49+
+ `pip install -r requirements.txt` - To install requirements
50+
+ Setup your database User, Password, Host, Port and Database Name.
51+
+ `make makemigrations` - To create migrations
52+
+ `make migrate` - To migrate database
53+
+ `make` - to start the server
54+
55+
## Running Tests
56+
57+
+ To run test for the project
58+
+ `$ make test`
59+
60+
## Api Endpoints
61+
62+
+ <https://g-awards.herokuapp.com/api/posts/>
63+
+ <https://g-awards.herokuapp.com/api/profile/>
64+
+ <https://g-awards.herokuapp.com/api/users/>
65+
66+
## Project Objectives
67+
68+
+ View posted projects and their details
69+
+ Post a project to be rated/reviewed
70+
+ Rate/ review other users' projects
71+
+ Search for projects
72+
+ View projects overall score
73+
+ View my profile page
74+
75+
## Technologies Used
76+
77+
+ python3.8
78+
+ django 3.2
79+
+ Cloudninary (for hosting images)
80+
+ Heroku (for hosting the project)
81+
+ Rest framework (for API)
82+
83+
## Licence
84+
85+
MIT License
86+
87+
Copyright (c) [2022] [FeverCode]
88+
89+
Permission is hereby granted, free of charge, to any person obtaining a copy
90+
of this software and associated documentation files (the "Software"), to deal
91+
in the Software without restriction, including without limitation the rights
92+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
93+
copies of the Software, and to permit persons to whom the Software is
94+
furnished to do so, subject to the following conditions:
95+
96+
The above copyright notice and this permission notice shall be included in all
97+
copies or substantial portions of the Software.
98+
99+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
100+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
101+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
102+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
103+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
104+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
105+
SOFTWARE.
106+
107+
## Authors Info
108+
109+
LinkedIn - [https://www.linkedin.com/in/gedion-onsongo-112543210/]
110+
111+
Reddit - [https://www.reddit.com/user/stainscode]

app/tests.py

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,48 @@ def test_delete(self):
3333
users = User.objects.all()
3434
self.assertTrue(len(users) == 0)
3535

36-
36+
class TestPost(TestCase):
37+
def test_post(self):
38+
self.assertEqual(1, 1)
39+
40+
def setUp(self):
41+
self.user = User.objects.create_user(id=1,username='testuser', password='12345')
42+
self.user.save()
43+
self.post = Post.objects.create(id=1,user=self.user,title='test title')
44+
self.post.save()
45+
46+
def test_instance(self):
47+
self.assertTrue(isinstance(self.post, Post))
48+
49+
50+
def test_save(self):
51+
self.post.save()
52+
post= Post.objects.all()
53+
self.assertTrue(len(post) > 0)
54+
55+
def test_delete(self):
56+
self.post.delete()
57+
post = Post.objects.all()
58+
self.assertTrue(len(post) == 0)
59+
60+
def test_search_projects(self):
61+
self.post.save()
62+
post = Post.search_projects('test')
63+
self.assertTrue(len(post) > 0)
64+
65+
def test_all_posts(self):
66+
self.post.save()
67+
post = Post.all_posts()
68+
self.assertTrue(len(post) > 0)
69+
70+
def get_post(self):
71+
self.post.save()
72+
post = Post.get_post(1)
73+
self.assertTrue(len(post) > 0)
74+
75+
# def test_get_ratings(self):
76+
# self.post.save()
77+
# post = Post.get_ratings(1)
78+
# self.assertTrue(len(post) > 0)
3779

38-
80+

0 commit comments

Comments
 (0)
0