Completed
Push — master ( 950d2c...3ea300 )
by Andrea
01:13
created

logout_client_user()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
1
import json
2
import time
3
from django.contrib.auth.models import User
4
#from my_application.models import Category, Thing
5
6
def populate_test_db():
7
    """
8
    Adds records to an empty test database
9
    """
10
    #cat = Category.objects.create(cat_name='Widgets')
11
    #cat_inactive = Category.objects.create(cat_name='Inactive Category',
12
    #                                        cat_active=False)
13
    #thing1 = Thing.objects.create(category=cat,
14
    #                            thing_desc="Test Thing",
15
    #                            thing_model="XYZ1234",
16
    #                            thing_brand="Brand X")
17
18
    User.objects.create_user(
19
        username='admin',
20
        email='[email protected]',
21
        password='secretpassword')
22
23
def login_client_user(self):
24
    self.client.login(username='admin', password='secretpassword')
25
    return self
26
27
def logout_client_user(self):
28
    self.client.logout()
29
    return self
30
31
def is_json(myjson):
32
    """
33
    tests if a string is valid JSON
34
    """
35
    try:
36
        json_object = json.loads(myjson)
37
    except ValueError, e:
38
        return False
39
    return True
40