Skip to content

Commit

Permalink
Optimized the test run
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Tuck committed Feb 12, 2020
1 parent 127e842 commit 7c2440e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Config/config.py
@@ -1,4 +1,4 @@
# Stores the variables used for all test cases.
# Currently only stores the server address.

SERVER = 'http://localhost:5000'
SERVER = 'http://127.0.0.1:5000'
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -15,7 +15,7 @@ Your steps may differ depending on your operating system but all are supported b
3. Clone this repo, or down it [here](https://github.com/keva161/DocketTests/archive/master.zip).
4. After unzipping the downloaded archive. Navigate to where you downloaded it and open up a terminal in the location.
5. Type: `pipenv install` to install the required dependencies.
6. Type the command 'pipenv run python -m pytest' to run the tests.
6. Type the command `pipenv run python -m pytest` to run the tests.

I hope these example tests are useful to you and they become the basis for your learning about API testing.

Expand Down
4 changes: 3 additions & 1 deletion endpoints/Register.py
Expand Up @@ -8,7 +8,9 @@ def __init__(self):

def CreateUser(self, user):
# A token is passed back by the server if the registration is a success
token = requests.post('http://127.0.0.1:5000/api/Register/', json={'Username': user["Username"],'Email Address': user["Email Address"],'Password': user["Password"]}).text.split()[-1][:-2]
token = requests.post('http://127.0.0.1:5000/api/Register/',
json={'Username': user["Username"], 'Email Address': user["Email Address"],
'Password': user["Password"]}).text.split()[-2][:-1]

# A request is then made to delete the user to reset the server back to its initial state
result = requests.delete(config.SERVER + '/api/Users/', headers={'token': token}).text
Expand Down
2 changes: 1 addition & 1 deletion utils/Generate.py
Expand Up @@ -20,7 +20,7 @@ def GetUser(self):
return new_user

def GetToken(self):
token = requests.post('http://127.0.0.1:5000/api/Register/', json={'Username': self.user["Username"],'Email Address': self.user["Email Address"],'Password': self.user["Password"]}).text.split()[-1][:-2]
token = requests.post('http://127.0.0.1:5000/api/Register/', json={'Username': self.user["Username"],'Email Address': self.user["Email Address"],'Password': self.user["Password"]}).text.split()[-2][:-1]
return token


Expand Down

0 comments on commit 7c2440e

Please sign in to comment.